JAXB Servlet ClassLoader Problem
I need to consume XML sent to a Servlet from a vendor. My JUnit test can unmarshall and marshall the XML via the same Controller used by the Servlet. It works fine on Tomcat, but for some reason it does not work on WebSphere Application Server (WAS).
The code in the Servlet code looks like this:
ClassLoader classLoader =null;
// This ClassLoader works on Tomcat but gets NoClassDefNotFoundError on WAS
// classLoader = this.getClass().getClassLoader();
// This ClassLoader works on Tomcat but gets NoClassDefNotFoundError on WAS
// classLoader = Thread.currentThread().getContextClassLoader(); // works on Tomcat
// This ClassLoader gets "unable to locate jaxb.properties" on WAS and Tomcat
classLoader = ClassLoader.getSystemClassLoader();
GetWorkItem item = WorkItemController.unmarshalGetWorkItem(bais, classLoader);
[A note about the funky class nameGetWorkItem. That was generated by JAXB based on the vendor's XSD schema.]
All three ClassLoaders work with JUnit. The first two work in the Servlet on Tomcat. The last one causes "unable to locate jaxb.properties" on both Tomcat and WebSphere.
None of these work on WebSphere. The first two result in NoClassDefNotFoundError for one of the Unmarshaller classes. I can get past that error by using ClassLoader.getSystemClassLoader(), but then I get the "unable to locate jaxb.properties" like I do on Tomcat.
Any ideas why the ClassLoaders that work on Tomcat woudl not work on WAS?
Steve Mitchell
http://www.byteworksinc.com
Here's a stack trace:
Using Thread.currentThread().getContextClassLoader()
[12/29/05 13:03:58:637 CST] 00000045 ServletWrappe ESRVE0068E: Could not invoke the service() method on servlet ArtsIntegrationSe
rvlet. Exception thrown : java.lang.NoClassDefFoundError: pivot/powerimageweb/xsd/powerimage/pivotworkflow/pigetworkitem/impl/GetWor
kItemTypeImpl$AvailablestatusTypeImpl$Unmarshaller
at pivot.powerimageweb.xsd.powerimage.pivotworkflow.pigetworkitem.impl.GetWorkItemTypeImpl$AvailablestatusTypeImpl.createUnm
arshaller(GetWorkItemTypeImpl.java:166)
at pivot.powerimageweb.xsd.powerimage.pivotinfo.pidocumentcontent.impl.runtime.AbstractUnmarshallingEventHandlerImpl.spawnCh
ild(AbstractUnmarshallingEventHandlerImpl.java:207)
at pivot.powerimageweb.xsd.powerimage.pivotinfo.pidocumentcontent.impl.runtime.AbstractUnmarshallingEventHandlerImpl.spawnCh
ildFromEnterElement(AbstractUnmarshallingEventHandlerImpl.java:214)
at pivot.powerimageweb.xsd.powerimage.pivotworkflow.pigetworkitem.impl.GetWorkItemTypeImpl$Unmarshaller.enterElement(GetWork
ItemTypeImpl.java:473)
at pivot.powerimageweb.xsd.powerimage.pivotinfo.pidocumentcontent.impl.runtime.SAXUnmarshallerHandlerImpl.startElement(SAXUn
marshallerHandlerImpl.java:126)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at pivot.powerimageweb.xsd.powerimage.pivotinfo.pidocumentcontent.impl.runtime.UnmarshallerImpl.unmarshal(UnmarshallerImpl.j
ava:140)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:131)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:178)
at com.umb.arts.controller.WorkItemController.unmarshalGetWorkItem(WorkItemController.java:93)
at com.umb.arts.htmlview.ArtsIntegrationServlet.processRequest(ArtsIntegrationServlet.java:107)
at com.umb.arts.htmlview.ArtsIntegrationServlet.doPost(ArtsIntegrationServlet.java:77)
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:2837)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:220)
at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:204)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java(Compiled Code))
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminaters(NewConnectionInitialReadCallback.java(C
ompiled Code))
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java(Compiled Code
))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))

