This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
We have a scenario in our application that, we have a JAR and WAR file. The JAR contains an MDB. WAR contains a web application. The deployment is on Websphere Application Server. Few of the common classes are required to be present in both the JAR and WAR files. When the JAR and WAR files were packaged as an EAR, the JAR file was getting loaded first, and therefore when the server was loading the WAR file, we encountered problems during loading the common classes by the Class Loader.
Thus, we are currently deploying JAR and WAR files separately. Deployment has been successful. But, now the problem is that when the MDB is getting invoked, we are encountering java.lang.NoClassDefFoundError within the execution of the JAR file, even though the class file is present in the JAR file.
Any ideas or advise please to overcome this error.
What are the common classes you said are required for both ear and jar? I will suggest you dont duplicate them in both the applications but rather create a Shared library in Websphere and link both these applications to this shared library.
Move your common classes into a new java project, and make it a jar. Put that jar into class path of WAR and JAR(MDB related).
Make sure that your MDB related JAR does not depend on WAR.
As the common design principles says, WAR contains your presentaion layer, MDB JAR contains your service layer.
Presentaion layer depends on Service layer. Service layer never depend on Presentation layer.
If there are some common classes used in both the layers, they should go into a separate JAR, which is a simple java project.
Hope that clears the path issues !
SCJP 5, SCWCD 5
Joined: Oct 04, 2005
yes, the error is happening in the JAR file for the common classes, even though the common classes reside within the jar file.
But still, say if we avoid duplicating the common files within JAR and WAR file, instead of creating a separate JAR file as you suggested, say, we have the files within the WAR itself, can we make the code in JAR file refer to the common files within the WAR file?