File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes BEA/Weblogic and the fly likes NoClassDefFoundError  calling entitybean from a session bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "NoClassDefFoundError  calling entitybean from a session bean" Watch "NoClassDefFoundError  calling entitybean from a session bean" New topic
Author

NoClassDefFoundError calling entitybean from a session bean

Anil Sequeira
Greenhorn

Joined: Jun 18, 2001
Posts: 12
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


Anil Sequeira
Dave Landers
Ranch Hand

Joined: Jul 24, 2002
Posts: 401
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

Joined: Jun 18, 2001
Posts: 12
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NoClassDefFoundError calling entitybean from a session bean