[EJB 3.0] - Re: EJB client: NullPointerException in StatelessLocalProxy
by yklich
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
19Â years, 2Â months
[EJB/JBoss] - Re: Remote not bound
by kstrunk
Thank you for your answers, but I still have the same problems.
@jaikiran:
When I do like you've posted, I get the following exception:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
@ALRubinger
I tried also your suggestion, but I still get the same exception.
My code looks as following now:
@Stateless
@Local(org.community.ejb.business.local.UserManager.class)
@Remote(org.community.ejb.business.remote.UserManager.class)
public class UserManagerBean implements org.community.ejb.business.local.UserManager, org.community.ejb.business.remote.UserManager {
...
}
@local
public interface UserManager {
...
}
@remote
public interface UserManager {
...
}
Local and remote interfaces are in different packages.
Do you have any more ideas how I can call my bean remote?
Best regards,
Strunker
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4011549#4011549
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4011549
19Â years, 2Â months