[jboss-user] [EJB 3.0] - Re: EJB client: NullPointerException in StatelessLocalProxy
yklich
do-not-reply at jboss.com
Mon Feb 5 15:37:51 EST 2007
I'm having a similar problem. I'm injecting the local EJB into a servlet, and when accesing the bean, the servlet throws a NullPointerException, just as if the bean wasn't instanciated. The servlet runs in the web-container, the bean in the EJB-container. So using the Local interface shouldnt be any problem(?)
| public class ControllerServlet extends HttpServlet
| {
| @EJB
| private ItemManagerLocal itemManager;
|
| protected void processRequest(HttpServletRequest req, HttpServletResponse res)
| {
| itemManager.findItem(itemId); // <--NPE happens
| }
| }
|
The <web-app> tag in the web.xml is defined as version=2.5
Using the JBoss JMX console I found the following entry in the Global JNDI Namespace:
+- klich (class: org.jnp.interfaces.NamingContext)
| +- ItemManager (class: org.jnp.interfaces.NamingContext)
| | +- local (proxy: $Proxy116 implements interface com.klich.ejb.ItemManagerLocal,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
| | +- remote (proxy: $Proxy115 implements interface com.klich.ejb.ItemManagerRemote,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
The servlet runs fine if I add:
| InitialContext ictx = new InitialContext();
| itemManager = (ItemManagerLocal)ictx.lookup("klich/ItemManager/local");
|
without using the @EJB anotation, but we all love our anotations so much :)
Thanks in advance for any help.
Yannik Klich
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4011556#4011556
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4011556
More information about the jboss-user
mailing list