You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Glen Mazza <gl...@verizon.net> on 2008/06/21 17:52:29 UTC

Re: javax.xml.bind.JAXBException: java.sql.Date is not known to this context

If, in your binding file, you change name="java.sql.Date" to
"java.sql.Banana", do you get the same error message: "java.sql.Date is
not known to this context"?  That would indicate that at runtime your
binding file is not being detected.

Glen


2008-06-20 Maurer Uwe wrote:
> Hello,
> 
> I like to write a test client for my Webservice using CXF 2.1.
> 
> This is the code creating my client proxy:
> 
>    ctx = new ClassPathXmlApplicationContext("test/wstest-client-context.xml"
> );
>    String url = "http://localhost:8080/FooService";
>    ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
>  
> factory.setServiceClass(KonzessionsAbgabenSatzBereitstellenV1Document.class)
> ;
>    factory.setAddress(url);
>    client = (FooServiceDocument) factory.create();
> 
> The Interface FooServiceDocument is the webservice interface generated from
> the WSDL2Java Tool. I use the following JAXB binding file to map xs:dateTime
> to java.sql.Date:
> 
> <jaxb:bindings version="2.0"
>     xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" 
>     xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
>     xmlns:xs="http://www.w3.org/2001/XMLSchema">
> 
>     <jaxb:bindings schemaLocation="porttypes/Http_FooService_document.wsdl">
>         <jaxb:bindings node="/xs:schema">
>             <jaxb:globalBindings>
>  
> <xjc:generateElementProperty>false</xjc:generateElementProperty>
>                 <jaxb:javaType name="java.sql.Date" xmlType="xs:dateTime"
>  
> parseMethod="com.enbw.foo.soa.tools.wsdl2java.DateConverter.parseDateTime"
>  
> printMethod="com.enbw.foo.soa.tools.wsdl2java.DateConverter.printDateTime"/>
>             </jaxb:globalBindings>
>         </jaxb:bindings>
>     </jaxb:bindings>
> </jaxb:bindings>
> 
> 
> This is the code calling the service:
> 
>    ...
>    java.sql.Date now = new java.sql.Date(System.currentTimeMillis());
>    ArrayOfFoo result = client.getFoo("DE", now, now);
>    assertNotNull(result);
>    ...
>  
> 
> Running my client i get an JAXBException at the line where I call the client
> ("client.getFoo(...)"):
> 
> [javax.xml.bind.JAXBException: java.sql.Date 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:257)
> 	at
> javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl
> .java:75)
> 	at
> org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:4
> 36)
> 	at
> org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:189)
> 	... 28 more
> Caused by: javax.xml.bind.JAXBException: java.sql.Date 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(ElementBeanI
> nfoImpl.java:143)
> 	at
> com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanI
> nfoImpl.java:185)
> 	at
> com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInf
> oImpl.java:305)
> 	at
> com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInf
> oImpl.java:312)
> 	at
> com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInf
> oImpl.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)
> 	... 32 more
> Caused by: javax.xml.bind.JAXBException: java.sql.Date 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(ElementBeanI
> nfoImpl.java:140)
> 	... 38 more
> 
> I searched in the list archive but didn't find a real answer to my problem.
> java.sql.Date is part of the jdk 1.5, so I assume it's not a class loading
> problem.
> 
> Any hints?
> 
> Uwe
>