Hi all,
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.
public static void main(
String [] args )
{
Properties prop = new Properties();
prop.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
prop.setProperty(Context.PROVIDER_URL, "localhost:1099");
prop.setProperty("java.naming.factory.url.pkgs",
"org.jboss.naming

rg.jnp.interfaces");
try
{
Context ctx = new InitialContext(prop);
System.out.println("TestEJB: 1 ");
Object obj = ctx.lookup( "local/PersonnelBean" );
System.out.println("Obj is: " + obj);
System.out.println("TestEJB: 2");
com.btm.ejb.personnel.PersonnelBeanHome home =
(com.btm.ejb.personnel.PersonnelBeanHome)javax.rmi.PortableRemoteObject.narrow(
obj, com.btm.ejb.personnel.PersonnelBeanHome.class );
System.out.println("TestEJB: home object created");
PersonnelLocal personnel = home.create("M001", "Murad", "Iqbal",
"4343", 1, "SE", "PK", "19121979");
System.out.println("TestEJB: object created");
//System.out.println( personnelLocal.hello());
//personnel.remove();
}
catch ( Exception e )
{
e.printStackTrace();
System.out.println( "Exception: " + e );
}
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)