Hi,
I wanted the ejb references have been injected by container. When I use context.lookup, it
is working. This is my code:
| Context context = new InitialContext();
| PrStaffLocalInterface prstaff =
(PrStaffLocalInterface)context.lookup("surgeonfish/PrStaffHome/local");
| prstaff.findById(new Integer(username));
|
But if I use @EJB annotation I am taking null pointer exception.
| package com.atosorigin.jdbc;
|
| import javax.ejb.EJB;
| import javax.naming.Context;
| import javax.naming.InitialContext;
| import javax.persistence.EntityManager;
| import javax.persistence.PersistenceContext;
|
| import com.atosorigin.utils.pojo.PrStaff;
| import com.atosorigin.utils.pojo.PrStaffHome;
| import com.atosorigin.utils.pojo.PrStaffLocalInterface;
|
| public class DBSecurity {
| @EJB
| PrStaffLocalInterface prStaff;
|
| public boolean checkUserPassword(String username, String password) throws
Exception {
| /*Context context = new InitialContext();
| PrStaffLocalInterface prstaff =
(PrStaffLocalInterface)context.lookup("surgeonfish/PrStaffHome/local");
| prstaff.findById(new Integer(username));*/
|
| prStaff.findById(new Integer(username));
|
| return false;
| }
| }
|
|
| //I HAVE USED ALL OF THIS POSSIBILITIES BY ONE BY
|
|
| @EJB(mappedName="surgeonfish/PrStaffHome/local")
| PrStaffLocalInterface prStaff;
|
| @EJB(beanName="surgeonfish/PrStaffHome/local")
| PrStaffLocalInterface prStaff;
|
| @EJB(name="surgeonfish/PrStaffHome/local")
| PrStaffLocalInterface prStaff;
|
| @EJB(name="PrStaffHome")
| PrStaffLocalInterface prStaff;
|
| @EJB(name="PrStaffHome/local")
| PrStaffLocalInterface prStaff;
|
| @EJB(mappedName="PrStaffHome/local")
| PrStaffLocalInterface prStaff;
|
| @EJB(beanName="PrStaffHome/local")
| PrStaffLocalInterface prStaff;
|
| @EJB(beanName="PrStaffHome")
| PrStaffLocalInterface prStaff;
|
Where am I missing? Thanks for your helps.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4159251#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...