• Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB access issue

 
Murad Iqbal
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have successfully deployed an EJB in JBoss 3.2.3. Following is a snippet from the ejb-jar.xml

<ejb-name>PersonnelBean</ejb-name>
<local-home>com.btm.ejb.personnel.PersonnelLocalHome</local-home>
<local>com.btm.ejb.personnel.PersonnelLocal</local>
<ejb-class>com.btm.ejb.personnel.PersonnelBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>false</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>Personnel</abstract-schema-name>


I guess there may not be an issue with this xml as it is deployed in the jboss server. Now I have written a client to access this EJB and invoke its create method. To my astonishment, the lookup method returns an object, which when printed out, shows 'local/PersonnelBeanHome' which is neither a class name, nor its defined int he ejb-jar.xml

I then changed my localhome interface to comply with this PersonnelBeanHome but it is giving me a nullpointer exception upon narrowing it. The jndi name of this bean is 'local/PersonnelBean' as shown by the JBoss console. Before changing this name, i was getting the same nullpointer exception on .narrow.

Following is hte client code:

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" );
//when i printed the obj it was local/PersonnelBeanHome, which represents nothing according to my classes and the ejb-jar.xml. is it that jboss automatically adds home after the bean's jndi name to lookup the localhome interface?
com.btm.ejb.personnel.PersonnelBeanHome home =
(com.btm.ejb.personnel.PersonnelBeanHome)javax.rmi.PortableRemoteObject.narrow(
obj, com.btm.ejb.personnel.PersonnelBeanHome.class );



Kindly help. this thing has wasted a lot of time.
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Murad,
I see now that my assumption -- which I stated in my reply to your other question in this forum -- was correct:- you have only defined a local interface for your EJB! (Big boo-boo, pal!)

Allow me to also recommend the J2EE Tutorial.

Good Luck,
Avi.
 
Murad Iqbal
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Really? I guess thats one of the most stupid mistakes i have ever made.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!