cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jose María Zaragoza <demablo...@gmail.com>
Subject Re: Invalid JSON Namespace
Date Sun, 08 Dec 2013 18:45:30 GMT
I don't know if

<property name="ignoreNamespaces" value="true"/>

is enough for you ( it wasn't in my case )





2013/12/8 Alex O'Ree <spyhunter99@gmail.com>:
> That did it! thanks for the help. Here's the relative parts of beans.xml
>
>
>    <util:map id="jsonNamespaceMap" map-class="java.util.Hashtable" >
>                 <entry key="urn:uddi-org:api_v3" value="urn:uddi-org:api_v3"/>
>   </util:map>
>
>
>   <jaxrs:server id="inquiryRestService" address="/inquiryRest">
>     <jaxrs:serviceBeans>
>       <ref bean="inquiryRest" />
>     </jaxrs:serviceBeans>
> <jaxrs:providers>
>                            <ref bean="jaxbProvider"/>
>                            <ref bean="jsonProvider"/>
>     </jaxrs:providers>
>   </jaxrs:server>
>   <bean id="inquiryRest"
> class="org.apache.juddi.api.impl.rest.UDDIInquiryJAXRS" />
> <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
> <property name="ignoreNamespaces" value="true"/>
> <property name="namespaceMap" ref="jsonNamespaceMap"/>
>   </bean>
>    <bean id="jaxbProvider"
> class="org.apache.cxf.jaxrs.provider.JAXBElementProvider"/>
>
> On Sun, Dec 8, 2013 at 4:10 AM, Jose María Zaragoza
> <demablogia@gmail.com> wrote:
>> Maybe you need to configure providers and declare them with <jaxrs:providers>
.
>> Something like :
>>
>>
>> <util:map id="jsonNamespaceMap" map-class="java.util.Hashtable" >
>>                 <entry key="urn:uddi-org:api_v3" value="uddiv3"/>
>>  </util:map>
>>
>> <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
>> <property name="ignoreNamespaces" value="true"/>
>> <property name="namespaceMap" ref="jsonNamespaceMap"/>
>>  </bean>
>>
>> <bean id="jaxbProvider"
>> class="org.apache.cxf.jaxrs.provider.JAXBElementProvider"/>
>>
>>
>> <jaxrs:server id="inquiryRestService" address="/inquiryRest">
>>     <jaxrs:serviceBeans>
>>       <ref bean="inquiryRest" />
>>     </jaxrs:serviceBeans>
>>
>> <jaxrs:providers>
>>                            <ref bean="jaxbProvider"/>
>>                            <ref bean="jsonProvider"/>
>>     </jaxrs:providers>
>>
>>
>>   </jaxrs:server>
>>
>> 2013/12/8 Alex O'Ree <spyhunter99@gmail.com>:
>>> Thanks for the reply. I've added the map, however i still get the same error
>>>
>>> WARNING: javax.ws.rs.InternalServerErrorException:
>>> java.lang.IllegalStateException: Invalid JSON namespace: urn:uddi-org
>>> :api_v3
>>>         at org.apache.cxf.jaxrs.provider.json.JSONProvider.writeTo(JSONProvider.java:377)
>>>         at org.apache.cxf.jaxrs.utils.JAXRSUtils.writeMessageBody(JAXRSUtils.java:1326)
>>>         at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(JAXRSOutInterceptor.java:282)
>>>         at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processResponse(JAXRSOutInterceptor.java:154)
>>>         at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(JAXRSOutInterceptor.java:85)
>>>         at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
>>>         at org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:77)
>>>         at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
>>>         at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
>>>         at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:239)
>>>         at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:223)
>>>         at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:203)
>>>         at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:137)
>>>         at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:158)
>>>         at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:243)
>>>         at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:168)
>>>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
>>>         at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:219)
>>>         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>>>         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>>>         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
>>>         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
>>>         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:465)
>>>         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
>>>         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>>>         at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:394)
>>>         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>>>         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
>>>         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
>>>         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
>>>         at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
>>>         at java.lang.Thread.run(Thread.java:744)
>>> Caused by: java.lang.IllegalStateException: Invalid JSON namespace:
>>> urn:uddi-org:api_v3
>>>         at org.codehaus.jettison.mapped.MappedNamespaceConvention.getJSONNamespace(MappedNamespaceConvention.java:252)
>>>         at org.codehaus.jettison.mapped.MappedNamespaceConvention.createKey(MappedNamespaceConvention.java:260)
>>>         at org.codehaus.jettison.mapped.MappedXMLStreamWriter.writeStartElement(MappedXMLStreamWriter.java:220)
>>>         at com.sun.xml.bind.v2.runtime.output.XMLStreamWriterOutput.beginStartTag(XMLStreamWriterOutput.java:118)
>>>         at com.sun.xml.bind.v2.runtime.output.XmlOutputAbstractImpl.beginStartTag(XmlOutputAbstractImpl.java:102)
>>>         at com.sun.xml.bind.v2.runtime.output.NamespaceContextImpl$Element.startElement(NamespaceContextImpl.java:496)
>>>         at com.sun.xml.bind.v2.runtime.XMLSerializer.endNamespaceDecls(XMLSerializer.java:288)
>>>         at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:590)
>>>         at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:342)
>>>         at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494)
>>>         at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:323)
>>>         at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:178)
>>>         at org.apache.cxf.jaxrs.provider.json.JSONProvider.marshal(JSONProvider.java:479)
>>>         at org.apache.cxf.jaxrs.provider.json.JSONProvider.marshal(JSONProvider.java:542)
>>>         at org.apache.cxf.jaxrs.provider.json.JSONProvider.writeTo(JSONProvider.java:369)
>>>         ... 31 more
>>>
>>> and the relevant parts of beans.xml
>>>
>>>   <util:map id="jsonNamespaceMap" map-class="java.util.Hashtable" >
>>>                 <entry key="urn:uddi-org:api_v3" value="uddiv3"/>
>>>   </util:map>
>>>   <jaxrs:server id="inquiryRestService" address="/inquiryRest">
>>>     <jaxrs:serviceBeans>
>>>       <ref bean="inquiryRest" />
>>>     </jaxrs:serviceBeans>
>>>   </jaxrs:server>
>>>   <bean id="inquiryRest"
>>> class="org.apache.juddi.api.impl.rest.UDDIInquiryJAXRS" />
>>> <bean id="jaxbProvider" class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
>>> <property name="ignoreNamespaces" value="true"/>
>>> <property name="namespaceMap" ref="jsonNamespaceMap"/>
>>>   </bean>
>>>
>>>
>>> using this pom dependencies
>>>
>>>
>>> <dependency>
>>> <groupId>org.apache.cxf</groupId>
>>> <artifactId>cxf-rt-rs-extension-providers</artifactId>
>>> <version>2.7.5</version>
>>> </dependency>
>>> <dependency>
>>> <groupId>org.codehaus.jettison</groupId>
>>> <artifactId>jettison</artifactId>
>>> <version>1.3.3</version>
>>> </dependency>
>>>
>>> I'll try 1.3.4
>>>
>>>
>>> On Sat, Dec 7, 2013 at 7:19 AM, Jose María Zaragoza
>>> <demablogia@gmail.com> wrote:
>>>> I had the same problem than you and ignoreNamespaces=true didn't work
>>>> for me ( I'm using Apache CXF 2.7.3 and Jettison 1.3.4 )
>>>> I don't know why.
>>>> If you try it and it works for you, please notify to me.
>>>>
>>>>
>>>> To solved that, I had to map my namespace to empty string ( "") **
>>>> only for JSON messages**, not for XML messages:
>>>>
>>>>
>>>> <util:map id="jsonNamespaceMap" map-class="java.util.Hashtable">
>>>>                 <entry key="http://domain.com/ws/type" value=""/>
>>>> </util:map>
>>>>
>>>>
>>>>  <bean id="jsonProvider"
>>>> class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
>>>>              <property name="namespaceMap" ref="jsonNamespaceMap"/>
>>>> </bean>
>>>>
>>>>
>>>> Regards
>>>>
>>>>
>>>>
>>>>
>>>> 2013/12/7 Alex O'Ree <spyhunter99@gmail.com>:
>>>>> Hi I have a JAXB annotated (wsimport) jaxws service that i'm writing
>>>>> an adapter for using jaxrs and jettison with 2.7.5.
>>>>>
>>>>> When service the rest endpoint with XML using the jaxws objects, it
>>>>> works just fine. However when serving JSON encoding data in response,
>>>>> I get this.
>>>>>
>>>>> Caused by: java.lang.IllegalStateException: Invalid JSON namespace:
>>>>> urn:uddi-org:api_v3
>>>>>         at org.codehaus.jettison.mapped.MappedNamespaceConvention.getJSONNamespace(MappedNamespaceConvention.java:252)
>>>>>         at org.codehaus.jettison.mapped.MappedNamespaceConvention.createKey(MappedNamespaceConvention.java:260)
>>>>>         at org.codehaus.jettison.mapped.MappedXMLStreamWriter.writeStartElement(MappedXMLStreamWriter.java:220)
>>>>>         at com.sun.xml.bind.v2.runtime.output.XMLStreamWriterOutput.beginStartTag(XMLStreamWriterOutput.java:118)
>>>>>
>>>>> Beans.xml config file
>>>>>
>>>>>   <jaxrs:server id="inquiryRestService" address="/inquiryRest">
>>>>>        <jaxrs:serviceBeans>
>>>>>       <ref bean="inquiryRest" />
>>>>>     </jaxrs:serviceBeans>
>>>>>   </jaxrs:server>
>>>>>   <bean id="inquiryRest"
>>>>> class="org.apache.juddi.api.impl.rest.UDDIInquiryJAXRS" >
>>>>>     </bean>
>>>>> <bean id="jaxbProvider" class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
>>>>>   <property name="ignoreNamespaces" value="true"/>
>>>>> </bean>
>>>>>
>>>>>
>>>>> this part works
>>>>> @GET
>>>>>     @Path("/XML/businessDetail/{id}")
>>>>>     @Produces("application/xml")
>>>>>     @org.apache.cxf.jaxrs.model.wadl.Description("Returns the details
>>>>> of a business entity in XML")
>>>>>     public org.uddi.api_v3.BusinessEntity
>>>>> getBusinessDetailXML(@PathParam("id") String id) throws
>>>>> WebApplicationException {
>>>>>         return getBusinessDetail(id);
>>>>>     }
>>>>>
>>>>>
>>>>> this part does not
>>>>> @GET
>>>>>     @Path("/JSON/businessDetail/{id}")
>>>>>     @Produces("application/json")
>>>>>     @org.apache.cxf.jaxrs.model.wadl.Description("Returns the details
>>>>> of a business entity in JSON")
>>>>>     public org.uddi.api_v3.BusinessEntity
>>>>> getBusinessDetailJSON(@PathParam("id") String id) throws
>>>>> WebApplicationException {
>>>>>         return getBusinessDetail(id);
>>>>>     }
>>>>>
>>>>> The complete code is over here:
>>>>> http://svn.apache.org/repos/asf/juddi/trunk/juddi-rest-cxf/
>>>>>
>>>>> From googling, I've seen that adding the ignoreNamespaces=true should
>>>>> fix this, but I'm not sure if I have it in the write place. The docs
>>>>> don't have a clear example of this

Mime
View raw message