• Post Reply Bookmark Topic Watch Topic
  • New Topic

Calling EJB from a normal Java Class  RSS feed

 
Rahul Juneja
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I am calling an EJB from a normal java class by lookup. If I do a plain Lookup with the JNDI name it goes pretty fine and I am able to get the EJBObject instance. but If i try to call with the reference i mean creating reference which we create when we are calling one EJB from the other or when we call and EJB from a web layer it is giving namenotfound exception. Can anybody let me know whether we can call the ejb from a normal java class with a reference when both the ejb and the java class are in the same package.

Below give is the code which demonstrates my problem.


Cheers,
Rahul
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37256
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rahul,
Whether the classes are in the same package has nothing to do with it. They are running in different JVMs. This means you have to get a reference to the remote JNDI to look up the bean. In other words, you need the machine name and port number.
 
Rahul Juneja
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne,

Thanks for the reply but i have allready done all that stuff u are talking about and yes i understand that there is nothing to do with the package but what i meant was actually they are in the same ear file and are deployed on the same jvm.

Just to update you if i try with just the JNDI name it goes fine and if i try with the reference created for that particular bean to same bean it doesn't work.

It is really appreciated if u can help me further on this.

Cheers,
Rahul
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!