cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <dk...@apache.org>
Subject Re: ClassCastException while working with Lists
Date Fri, 17 Sep 2010 16:26:19 GMT


You don't mention what version of CXF.

I just used the latest stuff and it seems to work fine.   I did a wsdl2java -
all  on the wsdl which did create that interface.   I started the server, ran 
the client, and got the empty BigInteger[] back.

Can you package up a fully non-working test case?

Dan



On Friday 17 September 2010 4:14:23 am jason wrote:
> Hi,
> 
> I've created a new service using the following WSDL file and the java2wsdl
> tool of cxf:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <wsdl:definitions name="HelloWorld"
> targetNamespace="http://www.tum.de/test"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> xmlns:tns="http://www.tum.de/test"
> 	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
> 	<wsdl:types>
> 		<xsd:schema targetNamespace="http://www.tum.de/test">
> 			<xsd:complexType name="CtMessage">
> 				<xsd:sequence>
> 					<xsd:element name="x" type="xsd:int" />
> 					<xsd:element name="y" type="xsd:string" />
> 				</xsd:sequence>
> 			</xsd:complexType>
> 
> 			<xsd:simpleType name="CtItems">
> 				<xsd:list itemType="xsd:integer" />
> 			</xsd:simpleType>
> 
> 			<xsd:element name="Message" type="tns:CtMessage" />
> 			<xsd:element name="ItemCount" type="xsd:int" />
> 			<xsd:element name="Items" type="tns:CtItems" />
> 
> 		</xsd:schema>
> 	</wsdl:types>
> 
> 	<wsdl:message name="SayHelloResponse">
> 		<wsdl:part name="parameter" element="tns:Items">
> 		</wsdl:part>
> 	</wsdl:message>
> 	<wsdl:message name="SayHelloRequest">
> 		<wsdl:part name="parameter" element="tns:Message">
> 		</wsdl:part>
> 	</wsdl:message>
> 
> 	<wsdl:portType name="HelloServiceInterface">
> 		<wsdl:operation name="sayTest">
> 			<wsdl:input message="tns:SayHelloRequest">
> 			</wsdl:input>
> 			<wsdl:output message="tns:SayHelloResponse">
> 			</wsdl:output>
> 		</wsdl:operation>
> 
> 	</wsdl:portType>
> 
> 	<wsdl:binding name="SayHelloHTTP" type="tns:HelloServiceInterface">
> 		<soap:binding style="document"
> 			transport="http://schemas.xmlsoap.org/soap/http" />
> 		<wsdl:operation name="sayTest">
> 			<wsdl:input>
> 				<soap:body use="literal" />
> 			</wsdl:input>
> 			<wsdl:output>
> 				<soap:body use="literal" />
> 			</wsdl:output>
> 		</wsdl:operation>
> 	</wsdl:binding>
> 	<wsdl:service name="HelloService">
> 		<wsdl:port name="HelloEndpoint" binding="tns:SayHelloHTTP">
> 			<soap:address location="http://localhost:8080/services/TEST.asmx" />
> 		</wsdl:port>
> 	</wsdl:service>
> </wsdl:definitions>
> 
> The service implementation looks like this:
> @WebService(endpointInterface = "de.tum.test.HelloServiceInterface",
> serviceName = "HelloTest")
> public class Implementation implements HelloServiceInterface {
> 
> 	@Override
> 	public BigInteger[] sayTest(CtMessage parameter) {
> 
> 		System.out.println("Say Test");
> 
> 		return new BigInteger[] {};
> 	}
> 
> }
> 
> Now if i call the sayTest method i get the following error:
> org.apache.cxf.interceptor.Fault: Marshalling Error:
> [Ljava.math.BigInteger; cannot be cast to java.util.Collection
> 	at
> org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:249
> ) at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:169)
> at
> org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(Abs
> tractOutDatabindingInterceptor.java:111) at
> org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutIntercep
> tor.java:68) at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
> n.java:244) at
> org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingC
> hainInterceptor.java:78) at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
> n.java:244) at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationO
> bserver.java:110) at
> org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(Jet
> tyHTTPDestination.java:311) at
> org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTT
> PDestination.java:275) at
> org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandle
> r.java:70) at
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
> at
> org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCol
> lection.java:230) at
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
> at org.mortbay.jetty.Server.handle(Server.java:326)
> 	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:536)
> 	at
> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java
> :930) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:747)
> 	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
> 	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:405)
> 	at
> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409
> ) at
> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:58
> 2) Caused by: java.lang.ClassCastException: [Ljava.math.BigInteger; cannot
> be cast to java.util.Collection
> 	at
> com.sun.xml.bind.v2.runtime.reflect.Lister$CollectionLister.iterator(Lister
> .java:265) at
> com.sun.xml.bind.v2.runtime.reflect.ListTransducedAccessorImpl.print(ListTr
> ansducedAccessorImpl.java:107) at
> com.sun.xml.bind.v2.runtime.reflect.DefaultTransducedAccessor.writeLeafElem
> ent(DefaultTransducedAccessor.java:65) at
> com.sun.xml.bind.v2.runtime.property.ListElementProperty.serializeBody(List
> ElementProperty.java:111) at
> com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBean
> InfoImpl.java:157) at
> com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBean
> InfoImpl.java:189) at
> com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanIn
> foImpl.java:316) at
> com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanIn
> foImpl.java:323) at
> com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanIn
> foImpl.java:72) at
> com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:49
> 4) at
> com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:315)
> 	at
> com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:244)
> 	at
> javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImp
> l.java:75) at
> org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:
> 532) at
> org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:222
> ) ... 21 more
> 
> Does anyone have an Idea whats going wrong here?
> 
> Thanks

-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog

Mime
View raw message