Ear, war, sar => NoClassDefFoundError
gretel Jan 14, 2004 10:48 PM
"gretel" wrote:
I'm having a lot of difficulty with classloading, specifically my web app can't resolve a class from a third-party jar file present in my ear. I get a NoClassDefFoundError from one of my (struts) action classes in the web app. No matter what I do I just can't seem to have the webapp find the third-party jar. Everything seems to deploy OK, problem arises when I try to log in to the web app.
Here's the stack trace:
2004-01-14 22:56:53,531 WARN [my.package.web.struts.action.BaseAction] my.package.web.struts.action.BaseAction: refreshUser
java.lang.NoClassDefFoundError: util/data/time/Time^M
at java.lang.Class.forName0(Native Method)^M
at java.lang.Class.forName(Class.java:140)^M
at my.package.web.struts.action.BaseAction.refreshUser(BaseAction.java:73)^M
at my.package.web.struts.action.LoginAction.execute(LoginAction.java:119)^M
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)^M
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)^M
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)^M
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)^M
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)^M
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)^M
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:360)^M
at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:294)^M
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:558)^M
at org.mortbay.http.HttpContext.handle(HttpContext.java:1714)^M
at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:507)^M
at org.mortbay.http.HttpContext.handle(HttpContext.java:1664)^M
at org.mortbay.http.HttpServer.service(HttpServer.java:863)^M
at org.jboss.jetty.Jetty.service(Jetty.java:460)^M
at org.mortbay.http.HttpConnection.service(HttpConnection.java:775)^M
at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:939)^M
at org.mortbay.http.HttpConnection.handle(HttpConnection.java:792)^M
at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:201)^M
at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)^M
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:455)^M
I have an ear deployed on JBoss 3.2.0 as follows:
myapp.ear
- META-INF/MANIFEST.MF
- META-INF/application.xml
- META-INF/jboss-app.xml
- lib/util.jar
- myejb.jar
----- various ejb interfaces, bean classes, data classes, etc.
----- META-INF/MANIFEST.MF
----- META-INF/ejb-jar.xml
----- META-INF/jboss.xml
----- META-INF/jboss-cmp-jdbc.xml
- myservice.sar
----- various common and service specific classes
----- META-INF/MANIFEST.MF
----- META-INF/jboss-service.xml
- myweb.war
----- jsps, etc
----- META-INF/MANIFEST.MF
----- WEB-INF/classes/[various common and web-related classes]
----- WEB-INF/lib/[other jars]
The class which can't be found resides in the util.jar in the lib directory of the ear. The MANIFEST files in myweb.war, ejb.jar and myservice.sar all have a classpath entry for the util.jar (including crlf) as follows:
Class-Path: lib/util.jar
The ear's application.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application PUBLIC '-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN' 'http://java.sun.com/dtd/application_1\
_3.dtd'>
<application>
<display-name>My App</display-name>
<module>
<web>
<web-uri>myweb.war</web-uri>
<context-root>/myweb</context-root>
</web>
</module>
<module>
<ejb>myejb.jar</ejb>
</module>
</application>
The ear's jboss-app.xml (not sure if all three archives should be listed here?)
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE jboss-app
PUBLIC "-//JBoss//DTD J2EE Application 1.3V2//EN"
"http://www.jboss.org/j2ee/dtd/jboss-app_3_2.dtd">
<jboss-app>
<loader-repository>user:ear=myapp.ear</loader-repository>
<module>
<service>myservice.sar</service>
</module>
<module>
<service>myweb.war</service>
</module>
<module>
<service>myejb.jar</service>
</module>
</jboss-app>
The myservice.sar jboss-service.xml:
<?xml version="1.0" encoding="UTF-8"?>
<server>
<mbean code="com.my.package.Service"
name="user:service=MyService">
</mbean>
</server>
Any ideas? I've read numerous postings on ear, war, jar classpath configuration and remain baffled.
TIA