-
1. Re: ejb deployment, ClassNotFound in war inside ear, specified in web.xml
jaysensharma Jan 19, 2016 9:48 PM (in response to garyaitken)Your class "org.mystuff.MyServlet" should be actually placed inside the "my_ear.ear/my_war.war/WEB-INF/classes/org/mystuff/MyServlet"
Inside WAR the classes should be either placed inside the "WEB-INF/lib" (as a JAR file), OR inside the "WEB-INF/classes" if not packaged inside a JAR.
This is according to the Servlet Specification: http://download.oracle.com/otn-pub/jcp/servlet-3_1-fr-eval-spec/servlet-3_1-final.pdf
Specification Section "10.5 Directory Structure"
The contents of the WEB-INF directory are:
■ The /WEB-INF/web.xml deployment descriptor.
■ The /WEB-INF/classes/ directory for servlet and utility classes. The classes in this directory must be available to the application class loader.
■ The /WEB-INF/lib/*.jar area for Java Archive files. These files contain servlets, beans, static resources and JSPs packaged in a JAR file and other utility classes useful to the Web application. The Web application class loader must be able to load classes from any of these archive files.
Regards
Jay SenSharma
-
2. Re: ejb deployment, ClassNotFound in war inside ear, specified in web.xml
garyaitken Jan 19, 2016 10:56 PM (in response to jaysensharma)Thank you!
I had seen conflicting descriptions of where the class files went.
That gets past one problem but now I have another;
search comes up with everything except what I need...
This .ear contains libraries used in more than one place.
The ear file spec enumerates 4 kinds of .jar files which may be in an ear:
Web modules (.war)
EJB modules (.jar)
Resource Adapter Modules (.rar)
Application Client Modules (.jar)
None of these are libraries.
For example, if I have a foo.jar that contains things needed by the
web module classes and the EJBs, how do I package them in the .ear?
I have classes and libraries sitting in a .jar file in the "lib" subdirectory of the .ear:
my_ear.ear
lib
my_libraries.jar
org
mystuff
SomeClass.class
lib
one_of_my_libs.jar
my_war.war
Classes in one_of_my_libs.jar are not found when loading the .war file that is in the .ear
-
3. Re: ejb deployment, ClassNotFound in war inside ear, specified in web.xml
jameslivingston Jan 20, 2016 1:17 AM (in response to garyaitken)You can put jar files in the 'lib' directory of the EAR. You cannot however nest jars inside other jars, which is what your tree seems to indicate.
-
4. Re: ejb deployment, ClassNotFound in war inside ear, specified in web.xml
garyaitken Jan 21, 2016 2:17 PM (in response to jameslivingston)Thanks.
You can put jar files in the 'lib' directory of the EAR. You cannot however nest jars inside other jars, which is what your tree seems to indicate.
I'm not sure that's true. According to the spec 8.2.1 (Bundled Libraries):
1. "A JAR format file ... may reference a .jar file or directory by naming the referenced .jar file or directory in a Class-Path header in the referencing JAR file's Manifest file."
2. "... These libraries may reference other libraries, either bundled with the application or installed separately, using any of the techniques describes herein."
However, in my case the problem was that the .war file referenced a class in a jar inside a top-level jar, so it wouldn't do the recursive search in the class loader. I think if it referenced a class in the top-level jar, and that class referenced a class in a jar packaged in the top-level jar's lib subdirectory, it would have worked. But I haven't needed that yet...
Thanks again