سؤال

I did my homework but still unable to find a solution to my problem. I created a WAR file through NetBeans which uses soap with attachments - saaj technology. As suggested, I include: saaj-impl.jar, saaj-ri.jar, saaj-api.jar in my project. However, when I "hot deploy" or place my WAR file into webapps directory I get the following exception:

java.lang.NoClassDefFoundError: com/sun/xml/messaging/saaj/soap/MessageFactoryImpl
source.pkg.SoapClient.sendSoapMessage(SoapClient.java:120)
source.pkg.Air.<init>(Air.java:233)
source.flightops.AirController.<init>(AirController.java:15)
servlets.ResultsDisplay.processRequest(ResultsDisplay.java:40)
servlets.ResultsDisplay.doGet(ResultsDisplay.java:91)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause

java.lang.ClassNotFoundException: com.sun.xml.messaging.saaj.soap.MessageFactoryImpl
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
source.pkg.SoapClient.sendSoapMessage(SoapClient.java:120)
source.pkg.Air.<init>(Air.java:233)
source.flightops.AirController.<init>(AirController.java:15)
servlets.ResultsDisplay.processRequest(ResultsDisplay.java:40)
servlets.ResultsDisplay.doGet(ResultsDisplay.java:91)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621

I tried to explicitly indicate classpath like so:

System.setProperty("java.class.path", wjp.getDataDir() + "/webapps/" + wjp.getAppContext() + "/WEB-INF/lib");

I did more research and tried to call a class loader:

try 
{          
Class.forName("com.sun.xml.messaging.saaj.soap.MessageFactoryImpl").getClassLoader();
} 
catch (ClassNotFoundException ex) 
{
        Logger.getLogger(AirDriver.class.getName()).log(Level.SEVERE, null, ex);
}

But still the same exception as above. This is strange because when I restart the server, sometimes the app works fine - SOAP response received and results are shown, but only after I restart the server. This hints to the fact that saaj classes are somehow found when server is restarted? But, the problem is it must work when I "hot deploy" or place updated WAR into webapps directory without restarting. We cannot afford restarting production server each time WAR is updated.

Another weird issue, is after I restart server, launch this WAR app it works fine. However, other apps which use the same saaj class library throw this same exception! So it's either using this WAR app and others not working, or use other apps and this WAR app throws this exception. Is there some kind of limited saaj library sharing? I have never seen something like this before.

Please, could somebody help me with this very strange (and nasty) problem?

Thank you, Victor.

هل كانت مفيدة؟

المحلول

The problem has been solved by re-implementing the app in the main web container i.e. ROOT/WEB-INF as opposed to as a separate portlet.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top