Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NoClassDefFoundError calling entitybean from a session bean

 
Anil Sequeira
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am trying to call a entity bean named product from a stateless session bean
Customer using the JNDI ENC naming context.At runtime I get the error
java.lang.NoClassDefFoundError as it cannot find the class ProductHome as it
resides in a different package from the customer Bean.
Snippet of my code of the CustomerBean where error is occuring is as
follows...
Context ctx = new InitialContext() ;
Object obj = ctx.lookup("java:comp/env/ejb/product.ProductHome") ;//works
fine
ProductHome home =
(ProductHome)PortableRemoteObject.narrow(obj,ProductHome.class) ;//error
How do get the Customer bean locate this class file?Do I need to explicitly
specify in some build or deployment XML file(s)?

Thanks
 
Dave Landers
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are several ways to solve your problem, probably the simplest is to package both EJBs in the same jar.
If you can't do that, then the entity's home and remote interfaces will need to be accessible from the session's jar. To do this, you can add these classes to the session's jar.
Or you can package both jars in an ear (J2EE Enterprise application archive), with META-INF/application.xml, etc. WebLogic will automatically make sure they can "see each other" when they are in a single application.
There are other options, too - but one of these should get you going.
 
Anil Sequeira
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dave,
I had tried the second option of putting the interfaces into the session jar and it works fine,but I prefer putting both the jar files in a EAR file as it makes more sense.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic