Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
currently, we need provide class XmlRootElement annotation for rest binding, otherwise we will get exception like
INFO: Interceptor has thrown exception, unwinding now
java.lang.ClassCastException: org.apache.ws.commons.schema.XmlSchemaComplexType
at org.apache.cxf.binding.http.interceptor.URIParameterInInterceptor.mergeParams(URIParameterInInterceptor.java:129)
at org.apache.cxf.binding.http.interceptor.URIParameterInInterceptor.handleMessage(URIParameterInInterceptor.java:105)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:147)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:63)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:220)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:180)
at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:54)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:690)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:191)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
at org.mortbay.jetty.Server.handle(Server.java:285)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:457)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:751)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:500)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:209)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:357)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:329)
at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:475)
The reason is without @XmlRootElement, schema generated from the java class is XmlSchemaComplexType, but currently what we expect is XmlSchemaElement
we can see
oc = IriDecoderHelper.buildDocument((XmlSchemaElement)part.getXmlSchema(),
schemas,
params);
cause this exception, part.getXmlSchema() return XmlSchemaComplexType if without @XmlRootElement
more details are in the mail
Hiya
I got the following exception when querying the following URL of a modified
version of the restful_http_binding sample.
<ns1:XMLFault>
<ns1:faultstring>
java.lang.ClassCastException :
org.apache.ws.commons.schema.XmlSchemaComplexType
</ns1:faultstring>
</ns1:XMLFault>
The only change I made between this faulty version and a working one is
about the GetBook class that was rewriten and compiled in Groovy. The
schema generated in now
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema elementFormDefault="qualified" version=" 1.0" targetNamespace="
http://book.acme.com" xmlns:xs=" http://www.w3.org/2001/XMLSchema">
<xs:complexType name="getBook">
<xs:sequence>
<xs:element name="id" type="xs:long"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
instead of
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema elementFormDefault="qualified" version="1.0" targetNamespace="
http://book.acme.com" xmlns:tns="http://book.acme.com"
xmlns:xs="http://www.w3.org/2001/XMLSchema
">
<xs:element name="GetBook" type="tns:getBook"/>
<xs:complexType name="getBook">
<xs:sequence>
<xs:element name="id" type="xs:long"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
would these changes lead to that error ? My feeling is no since I did the
same change for other classes and this did not cause the same exception.
Thoughts ?
Cheers
Guillaume