Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unable to lookup remote EJB

 
maha laxmi
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am using jboss-4.0.2;i have deployed one ear say A.ear in one machine and B.ear deployed in machine;


in A.ear i have some utility classes ;one utility class is looking up session bean located in B.ear;but i am getting this exception

Error : javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundException: No ClassLoaders found for: com.blah.blah.CalRHome (no security manager: RMI class loader disabled)]

JNDI properties
contextProperty.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
contextProperty.put(Context.SECURITY_PRINCIPAL, "admin") ;
contextProperty.put(Context.SECURITY_CREDENTIALS, "welcome");
contextProperty.put(Context.PROVIDER_URL, "jnp://211.80.70.1:1099");
 
Dave Salter
Ranch Hand
Posts: 293
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error seems to be saying that it cant find the remote home interface for the session bean. I don't think this is a lookup problem, rather just a class loader problem. Is the CalRHome interface available to both ears?
 
maha laxmi
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dave Salter:
The error seems to be saying that it cant find the remote home interface for the session bean. I don't think this is a lookup problem, rather just a class loader problem. Is the CalRHome interface available to both ears?




I deployed one A.ear in my windows machine and i deoployed B.ear in linux machine;

from utility class that is in A.ear i am trying to lookup EJB located in B.ear.

InitialContexttaxEngineContext= new InitialContext(contextProperty);
Object objhome = taxEngineContext.lookup("CalR");
CalRHome home = (CalRHome) PortableRemoteObject.narrow(objhome,CalRHome.class);

one thing i dont understand, previously i used oc4j server it works well but in JBoss it is giving classloader problems.

why should i specify CalRHome interface in A.ear?

should i specify all home ,remote ,bean classes in A.ear file;

u mean to say i should specify CalRHome interface in ejb-jar.xml of A.ear
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

why should i specify CalRHome interface in A.ear?

If you are going to try to use CalRHome interface in A.ear it will need to be available to the class loaders that A.ear uses. There are no hard and fast rules about his, but typically the clases available to an ear (other than those on the system classpath) are those contained in the ear.


one thing i dont understand, previously i used oc4j server it works well but in JBoss it is giving classloader problems.

Different app. servers implement this in different ways. There is nothing in the J2EE spec. to define this which is why there are differences.
 
maha laxmi
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Sturrock:

Different app. servers implement this in different ways. There is nothing in the J2EE spec. to define this which is why there are differences.


"If you are going to try to use CalRHome interface in A.ear it will need to be available to the class loaders that A.ear uses"

A.ear is not using CalRHome interface but just looking up CalRHome interface that is located in B.ear;
 
maha laxmi
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
should i deploy home ,remote ,bean classes in A.ear file or just specifying JNDI name, home interface and remote interface in ejb-jar.xml is enough?
 
Sanju Thomas
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you talking abt .jar or .ear ?, If you are trying to look an ejb deployed in say server A from Server B, then you should have remote and home classes of remote bean in Server B. may be in your classpath, or you can pack it in the jar.
 
maha laxmi
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sanju Thomas:
Are you talking abt .jar or .ear ?, If you are trying to look an ejb deployed in say server A from Server B, then you should have remote and home classes of remote bean in Server B. may be in your classpath, or you can pack it in the jar.


i also added bean class in ejb-jar.xml in A.ear then what i expected is coming correctly;


one thing i dont understand is if u have same classes in A.ear and also in B.ear then i dont think it is remote lookup it is still has local lookup because whatever classes it is trying to use in B.ear those classes are available in A.ear ;

my point is how can u say that it is remote look up?


without adding those classes in my A.ear it works well oc4j server but in jboss its giving problem.
 
Dave Salter
Ranch Hand
Posts: 293
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to use a remote session bean, you need to look up the remote interface for it using its remote JNDI name.

IIRC, JBoss is clever enough to use a local interface if one is available instead of a remote one.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic