I have successfully deployed a simple CMP entity bean on JBoss 3.2.3. I am attempting to access the ejb using the following client code. both the client and the jboss server that has the ejb container are on the same machine. However, I experienced a weird behavior from the lookup method. When i did Object obj = ctx.lookup("local/PersonnelBean"), it should return the LocalHome interface of the PersonnelBean which is PersonnelLocalHome (same name in ejb-jar.xml), but it returned me local/PersonnelBeanHome which doesnt exist at all. I got this by printint out the obj object. Thereafter, I changed my PersonnelLocalHome interface to PersonnelBeanHome just to let it go to the next step, but it is giving me the same NullPointer Exception. Kindly help. 'local/PersonnelBean' is the jndi name of the bean as told by JBoss. Following is the client code.
TestEJB: 1 Obj is: local/PersonnelBeanHome TestEJB: 2 java.lang.NullPointerException TestEJB: home object created Exception: java.lang.NullPointerException at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:110) at $Proxy0.create(Unknown Source) at com.test.TestEJB.main(TestEJB.java:45)
Murad, It seems to me that you have misunderstood the purpose of the "local" EJB interfaces (as opposed to the "remote" interfaces). The "local" interface is _not_ for clients that are on the same machine as the EJB container. The local interface is for clients that are in the same JVM as the EJB container. Since I assume your client is not in the same JVM as the EJB container, it is a remote client, and must therefore use the EJB "remote" interface.
The local interface was introduced so that one type of EJB (for example a session bean) could lookup a different type of EJB (for example an entity bean) in the same EJB container.
I think you also need to define remote interfaces for your EJB's -- since it appears you have currently only defined local interfaces.
For your information, TheServerSide Web site has a freely available book on EJB -- which can be downloaded as a single, PDF file.
Good Luck, Avi.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop