File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Problem making a class in another jar visiable to a ejb in its ejb jar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Problem making a class in another jar visiable to a ejb in its ejb jar" Watch "Problem making a class in another jar visiable to a ejb in its ejb jar" New topic
Author

Problem making a class in another jar visiable to a ejb in its ejb jar

Tony Evans
Ranch Hand

Joined: Jun 29, 2002
Posts: 573
m, I have a ejb which is trying to call a class in another jar.
When I try to laod my ejb jar file I get the following error:

Unable to deploy EJB: .\adminsvr\stage\_appsdir_BrokerEAR_ear\BrokerEJB.jar from BrokerEJB.jar:

[EJB:010106]EJB : TradeObject .Unable to initialize method info for remote or home interface.
The error is java.lang.NoClassDefFoundError: brokearage/broker/co/trade/BrokerTrade.

The class BrokerTrade.class is in a jar called TradeJar.jar

Its is called by and passed as a parameter by TradesBean.java a statless session bean.

The steps I have taken is

1)Create both jars.
2)Add both jars to the META-INF directory in the BrokerEAR.ear file


Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: Apache Ant 1.5.1
Class-Path: TradeJar.jar, BrokerEJB.jar

3)Added both jars to the application.xml

<!DOCTYPE application PUBLIC '-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN'
'http://java.sun.com/dtd/application_1_3.dtd'>
<application>
<display-name></display-name>
<module>
<ejb>BrokerEJB.jar</ejb>
</module>
<module>
<java>TradeJar.jar</java>
</module>
<module>
<web>
<web-uri>BrokerWAR.war</web-uri>
<context-root>BrokerWAR</context-root>
</web>
</module>
</application>

Are there any other steps I need to do to make a class in one jar visiable to a class in another jar.

If I put BrokerTrade.class into the BrokerEJB.jar I solve the problem, but what I want to find out is how classes from one jar can interact with classes from another jar.
Tony Evans
Ranch Hand

Joined: Jun 29, 2002
Posts: 573
Solved the problem in my BrokerEJB.jar under the META-INF directory I need to add the classpath TradeJar.jar to the Manifest.mf

I thought you only needed to add it under the .EAR META-INF, but if a class in one jar is calling a class in another jar then you need to add that jar to the first classes Jar classpath which is the Manifest.mf file.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Exactly. If it is in the same ear, you would use your application.xml to set the "modules". so a module would point to a jar file. In this case the Ear file does not need the information in the META-INF file.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem making a class in another jar visiable to a ejb in its ejb jar