0

I have a class in a war...

SomeClass.java

This class is embedded into a war which is embedded in an ear. Also, embedded in the ear is an EJB class which references a class in the war (not my design). This class clearly exists and I can see it in the deployed WS app. The ear file looks as follows...

ear file
  META-INF
  war file <Where the .class is found>
  ejb jar file

But I still get a ClassNotFound Exception on SomeClass can anyone think of what I am missing? This is pretty old versions so do I have to set the classpath in the META-INF in the ejb jar even if the jar is in the exploded war?

Thanks

3 Answers 3

0

OMG this is REALLY messy. Glad it's not your design. As you know EJB classes should NEVER depends on libs or classes from war files. That said if you need that your class "SomeClass.java" to be available to both, the war and ejb.jar package, than you should build a third standard.jar file with the class in it and place it under ear/lib folder of your package. This should make the class available to both packages, the .war and .jar(ejb) files.

3
  • Thanks but the project is also monolithic, and I don't get paid by the hour :-P. Is there a way to just get the class on the classpath or something.
    – Jackie
    Apr 1, 2013 at 18:13
  • Also should my ejb.jar be in the ./lib folder as well? Would it be proper to move the files from WEB-INF/lib to there as well?
    – Jackie
    Apr 1, 2013 at 18:20
  • You should move to the ear/lib folder only the standard jars(non ejb jars) that you want the classes in it to be accessible from the war and ejb.jar files.
    – groo
    Apr 1, 2013 at 21:23
0

Since you are using WebSphere, you may want to try setting the WAR class loader policy to "Application", as described in the following document:

http://pic.dhe.ibm.com/infocenter/wasinfo/v7r0/topic/com.ibm.websphere.express.doc/info/exp/ae/crun_classload.html

This would create a single class loader for the entire application, i.e. the EJBs and the classes in the WAR would be loaded by the same class loader. This should solve your problem.

0

Create a lib folder under the EAR file structure and copy all the jar fiels which you want to use as common for both WAR and EJB in it. This should solve the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.