Hi folks,
when I deploy a jaxws-webservice which returns a complex type (i.e.
List<MyObject>) and that has it's jaxws classes generated in the
ServiceImpls package + .jaxws. As soon as I called the method [either
with soapUI, or through a generated client], I got a weird
MarshalException, which is pasted below.
[ERROR] javax.xml.bind.MarshalException
- with linked exception:
[javax.xml.bind.JAXBException: java.util.List is not known to this context]
org.apache.axis2.AxisFault: javax.xml.bind.MarshalException
- with linked exception:
[javax.xml.bind.JAXBException: java.util.List is not known to this context]
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at
org.apache.axis2.jaxws.server.JAXWSMessageReceiver.receive(JAXWSMessageReceiver.java:218)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:173)
at
org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:167)
at
org.apache.axis2.transport.http.HTTPWorker.service(HTTPWorker.java:266)
at
org.apache.axis2.transport.http.server.AxisHttpService.doService(AxisHttpService.java:281)
at
org.apache.axis2.transport.http.server.AxisHttpService.handleRequest(AxisHttpService.java:187)
at
org.apache.axis2.transport.http.server.HttpServiceProcessor.run(HttpServiceProcessor.java:82)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:651)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:676)
at java.lang.Thread.run(Thread.java:595)
Caused by: javax.xml.ws.WebServiceException: javax.xml.bind.MarshalException
- with linked exception:
[javax.xml.bind.JAXBException: java.util.List is not known to this context]
at
org.apache.axis2.jaxws.ExceptionFactory.createWebServiceException(ExceptionFactory.java:175)
at
org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:70)
at
org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:128)
at
org.apache.axis2.jaxws.server.JAXWSMessageReceiver.receive(JAXWSMessageReceiver.java:215)
... 9 more
Caused by: javax.xml.bind.MarshalException
- with linked exception:
[javax.xml.bind.JAXBException: java.util.List is not known to this context]
at
com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:331)
at
com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:175)
at
org.apache.axis2.datasource.jaxb.JAXBDSContext$5.run(JAXBDSContext.java:773)
at
org.apache.axis2.java.security.AccessController.doPrivileged(AccessController.java:76)
at
org.apache.axis2.datasource.jaxb.JAXBDSContext.marshalByType(JAXBDSContext.java:675)
at
org.apache.axis2.datasource.jaxb.JAXBDSContext.marshal(JAXBDSContext.java:345)
at
org.apache.axis2.jaxws.message.databinding.impl.JAXBBlockImpl._outputFromBO(JAXBBlockImpl.java:189)
at
org.apache.axis2.jaxws.message.impl.BlockImpl.outputTo(BlockImpl.java:370)
at
org.apache.axis2.jaxws.message.impl.BlockImpl.serialize(BlockImpl.java:294)
at
org.apache.axiom.om.impl.llom.OMSourcedElementImpl.internalSerializeAndConsume(OMSourcedElementImpl.java:738)
at
org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:966)
at
org.apache.axiom.om.impl.llom.OMElementImpl.internalSerializeAndConsume(OMElementImpl.java:995)
at
org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:966)
at
org.apache.axiom.om.impl.llom.OMElementImpl.internalSerializeAndConsume(OMElementImpl.java:995)
at
org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.serializeInternally(SOAPEnvelopeImpl.java:254)
at
org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.internalSerialize(SOAPEnvelopeImpl.java:242)
at
org.apache.axiom.om.impl.llom.OMElementImpl.internalSerializeAndConsume(OMElementImpl.java:995)
at
org.apache.axiom.om.impl.llom.OMNodeImpl.serializeAndConsume(OMNodeImpl.java:486)
at
org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:79)
at
org.apache.axis2.transport.http.CommonsHTTPTransportSender.sendUsingOutputStream(CommonsHTTPTransportSender.java:358)
at
org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:235)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:435)
at
org.apache.axis2.jaxws.server.JAXWSMessageReceiver.receive(JAXWSMessageReceiver.java:196)
... 9 more
Caused by: javax.xml.bind.JAXBException: java.util.List is not known to
this context
at
com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:242)
at
com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:257)
at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:143)
at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:185)
at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:305)
at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:312)
at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:71)
at
com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:490)
at
com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:328)
... 31 more
Caused by: javax.xml.bind.JAXBException: java.util.List is not known to
this context
at
com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:587)
at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:140)
... 37 more
Several hours of debugging later I tracked this problem down to the
ArtifactProcessor, which - in his "private static String
findArtifact(String artifactClassName, ClassLoader classLoader)" - tries
to load the generated Classes in the same package as the
Service-Implementation and fails at this (as they are in the .jaxws.
subpackage).
It then goes on adding the subpackage ".jaxws." to the fully qualified
name and then tries to load the class again, but this time not with the
DeploymentClassLoader, instead it uses the *Context*ClassLoader. This
also fails, as the .jaxws.*-classes are deployed in the *Service.jar (in
servicejars) and are not available through the ContextClassLoader. As
the deployment-classloader is already available I fixed this easily by
just adding the deployment-classloader trying to load it before.
When I used the modified library, I stumbled upon another problem in the
opposite path. This time I got the
following exception:
[ERROR] javax.xml.bind.UnmarshalException
- with linked exception:
[javax.xml.bind.UnmarshalException: unexpected element
(uri:"http://www.wilken.de/testsimpleservice", local:"addBoot").
Expected elements are (none)]
org.apache.axis2.AxisFault: javax.xml.bind.UnmarshalException
- with linked exception:
[javax.xml.bind.UnmarshalException: unexpected element
(uri:"http://www.wilken.de/testsimpleservice", local:"addBoot").
Expected elements are (none)]
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at
org.apache.axis2.jaxws.server.JAXWSMessageReceiver.receive(JAXWSMessageReceiver.java:218)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:173)
at
org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:167)
at
org.apache.axis2.transport.http.HTTPWorker.service(HTTPWorker.java:266)
at
org.apache.axis2.transport.http.server.AxisHttpService.doService(AxisHttpService.java:281)
at
org.apache.axis2.transport.http.server.AxisHttpService.handleRequest(AxisHttpService.java:187)
at
org.apache.axis2.transport.http.server.HttpServiceProcessor.run(HttpServiceProcessor.java:82)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:651)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:676)
at java.lang.Thread.run(Thread.java:595)
Caused by: javax.xml.ws.WebServiceException:
javax.xml.bind.UnmarshalException - with linked exception:
[javax.xml.bind.UnmarshalException: unexpected element
(uri:"http://www.wilken.de/testsimpleservice", local:"addBoot").
Expected elements are (none)]
at
org.apache.axis2.jaxws.ExceptionFactory.createWebServiceException(ExceptionFactory.java:175)
at
org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:70)
at
org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:128)
at
org.apache.axis2.jaxws.marshaller.impl.alt.DocLitWrappedMethodMarshaller.demarshalRequest(DocLitWrappedMethodMarshaller.java:286)
at
org.apache.axis2.jaxws.server.dispatcher.JavaBeanDispatcher.createRequestParameters(JavaBeanDispatcher.java:266)
at
org.apache.axis2.jaxws.server.dispatcher.JavaBeanDispatcher.invoke(JavaBeanDispatcher.java:80)
at
org.apache.axis2.jaxws.server.EndpointController.invoke(EndpointController.java:109)
at
org.apache.axis2.jaxws.server.JAXWSMessageReceiver.receive(JAXWSMessageReceiver.java:159)
... 9 more
Caused by: javax.xml.bind.UnmarshalException
- with linked exception:
[javax.xml.bind.UnmarshalException: unexpected element
(uri:"http://www.wilken.de/testsimpleservice", local:"addBoot").
Expected elements are (none)]
at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:421)
at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:360)
at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:330)
at
org.apache.axis2.datasource.jaxb.JAXBDSContext$6.run(JAXBDSContext.java:802)
at
org.apache.axis2.java.security.AccessController.doPrivileged(AccessController.java:76)
at
org.apache.axis2.datasource.jaxb.JAXBDSContext.unmarshalByElement(JAXBDSContext.java:799)
at
org.apache.axis2.datasource.jaxb.JAXBDSContext.unmarshal(JAXBDSContext.java:293)
at
org.apache.axis2.jaxws.message.databinding.impl.JAXBBlockImpl._getBOFromReader(JAXBBlockImpl.java:96)
at
org.apache.axis2.jaxws.message.impl.BlockImpl._getBOFromOM(BlockImpl.java:475)
at
org.apache.axis2.jaxws.message.databinding.impl.JAXBBlockImpl._getBOFromOM(JAXBBlockImpl.java:136)
at
org.apache.axis2.jaxws.message.impl.BlockImpl.getBusinessObject(BlockImpl.java:148)
at
org.apache.axis2.jaxws.message.impl.XMLSpineImpl._getBlockFromOMElement(XMLSpineImpl.java:594)
at
org.apache.axis2.jaxws.message.impl.XMLSpineImpl.getBodyBlock(XMLSpineImpl.java:334)
at
org.apache.axis2.jaxws.message.impl.XMLPartBase.getBodyBlock(XMLPartBase.java:521)
at
org.apache.axis2.jaxws.message.impl.MessageImpl.getBodyBlock(MessageImpl.java:657)
at
org.apache.axis2.jaxws.marshaller.impl.alt.DocLitWrappedMethodMarshaller.demarshalRequest(DocLitWrappedMethodMarshaller.java:233)
... 13 more
Caused by: javax.xml.bind.UnmarshalException: unexpected element
(uri:"http://www.wilken.de/testsimpleservice", local:"addBoot").
Expected elements are (none)
at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:609)
at
com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:244)
at
com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:239)
at
com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:116)
at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(UnmarshallingContext.java:1015)
at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:452)
at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:433)
at
com.sun.xml.bind.v2.runtime.unmarshaller.MTOMDecorator.startElement(MTOMDecorator.java:107)
at
com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStartElement(StAXStreamConnector.java:275)
at
com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:209)
at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:358)
... 27 more
Caused by: javax.xml.bind.UnmarshalException: unexpected element
(uri:"http://www.wilken.de/testsimpleservice", local:"addBoot").
Expected elements are (none)
... 38 more
It turned out to be pretty much the same problem, but this time in the
PackageSetBuilder - it tries to get the Package for a Classname and
ultimately fails to load the class, assuming then a wrong packagename
and failing to unmarshal the request. It also was fixable by using the
DeploymentClassLoader.
Is there any reason for the weird class-loading implementation, or is it
a bug?
If so, feel free to test with http://debugco.de/files/SimpleService.jar
and to apply the patch from http://debugco.de/files/axis2-1.5.1-fr.patch
- be sure to review the changes in the PackageSetBuilder though, as I'm
not sure if they are compatible to existing deployments.
tl;dr PackageSetBuilder & ArtifactProcessor don't always use the
DeploymentClassLoader. Please fix or explain why.
Greetings,
Florian Roks
Test-Specs:
o SimpleService.jar in servicejars
o axis2 1.5.1 (configuration modified to deploy servicejars)
o jdk 1.5.0-19
o soapUI for accessing webservice [but happens also with "normal"
generated client]