Yep, classes are bundlized and deployed in an osgi environment. 

And yes, I imported "javax.ws.rs.ext". As I said, my provider is well 
instantiated but JSONProvider seems to have an higher priority.

Regards,
Anthony


-----Original Message-----
From: Sergey Beryozkin [mailto:[email protected]] 
Sent: vendredi 30 septembre 2011 15:58
To: [email protected]
Subject: Re: CXF 2.3.3 - JSON output - java.lang.IllegalStateException: Invalid 
JSON namespace

Hi

I've checked that the code in CXF 2.3.3, CXF 2.4.2 and 2.5.0 that deals 
with getting providers from Applications is identical and I have a test 
where exception mappers are registered from CXFNonSpringJaxrsServlet and 
Application.

I'm wondering if it is an OSGI issue ? Do you have javax.ws.rs.ext 
imported ?


On 30/09/11 11:23, Muller, Anthony wrote:
> Thanks for your help Sergey. Sorry, it's configured through an Application 
> instance!
>
> Anthony
>
> -----Original Message-----
> From: Sergey Beryozkin [mailto:[email protected]]
> Sent: vendredi 30 septembre 2011 12:14
> To: [email protected]
> Subject: Re: CXF 2.3.3 - JSON output - java.lang.IllegalStateException: 
> Invalid JSON namespace
>
> That looks OK.
> How do you register it ? From Application instance or via servlet init
> params ? Give me more info please
>
> Cheers, Sergey
>
> On 30/09/11 11:10, Muller, Anthony wrote:
>> Yes, it's what I did. Do you see something wrong?
>>
>>
>> import javax.ws.rs.Consumes;
>> import javax.ws.rs.Produces;
>> import javax.ws.rs.ext.Provider;
>>
>> import org.apache.cxf.jaxrs.provider.JSONProvider;
>>
>> @Produces({"application/json"})
>> @Consumes({"application/json"})
>> @Provider
>> public class ExtendedJSONProvider extends JSONProvider {
>>
>>      public ExtendedJSONProvider() {
>>              setIgnoreNamespaces(true);
>>      }
>> }
>>
>>
>> -----Original Message-----
>> From: Sergey Beryozkin [mailto:[email protected]]
>> Sent: vendredi 30 septembre 2011 12:02
>> To: [email protected]
>> Subject: Re: CXF 2.3.3 - JSON output - java.lang.IllegalStateException: 
>> Invalid JSON namespace
>>
>> Hi, yea it does, but as I said CXF (CXFNonSpringJaxrsServlet) does not
>> check superclasses for @Provider which will need to be fixed, so for now
>> please add another @Provider to your custom provider and that will do -
>>
>> Cheers, Sergey
>>
>> On 30/09/11 10:47, Muller, Anthony wrote:
>>> Hi Sergey,
>>>
>>> Are you sure that "org.apache.cxf.jaxrs.provider.JSONProvider" doesn't have 
>>> the @Provider annotation?
>>>
>>> I found it in "cxf-2.3.3.jar" yet :-/
>>>
>>> Anthony
>>>
>>>
>>>
>>> -----Original Message-----
>>> From: Sergey Beryozkin [mailto:[email protected]]
>>> Sent: vendredi 30 septembre 2011 11:20
>>> To: [email protected]
>>> Subject: Re: CXF 2.3.3 - JSON output - java.lang.IllegalStateException: 
>>> Invalid JSON namespace
>>>
>>> Hi Anthony
>>>
>>> How do you register it, using jaxrs.providers parameter ?
>>> A custom provider should be preferred to a default one.
>>> That warning suggests that you probably use a jaxrs.serviceClasses
>>> parameter ?
>>>
>>> Or do use register it from the Application implementation ? In that case
>>> this custom provider needs to have a JAX-RS @Provider annotation,
>>> for it to be distinguished from other singletons. JSONProvider does have
>>> it - but in 2.3.3 no checks are made on superclasses - that will need to
>>> be improved in CXF
>>>
>>> Let me know please if that works
>>>
>>> Cheers, Sergey.
>>>
>>> On 30/09/11 09:38, Muller, Anthony wrote:
>>>> Hey Sergey,
>>>>
>>>> I'm trying to follow your advice and I inherited from JSONProvider class 
>>>> and just set "ignoreNamespace" to true.
>>>>
>>>> At the beginning, I didn't inherit from JSONProvider, but only 
>>>> instantiated this class, set the "ignoreNamespace" property and add it as 
>>>> a provider: however I get an exception because this provider was already 
>>>> registered (by CXF itself I guess).
>>>>
>>>> SO, I add the provider bellow, but I still have the same exception about 
>>>> namespace :(
>>>>
>>>> In the stack trace, I see that JSONProvider is still used... Not my new 
>>>> instance... I guess CXF takes the first provider which is able to handle 
>>>> application/json MIME type?
>>>>
>>>> Moreover, I see this warning in log:
>>>>
>>>> org.apache.cxf.jaxrs.utils.ResourceUtils checkMethodDispatcher
>>>> ATTENTION: No resource methods have been found for resource class 
>>>> com.test.ExtendedJSONProvider
>>>>
>>>> The code of the inherited JSONProvider.
>>>>
>>>> import javax.ws.rs.Consumes;
>>>> import javax.ws.rs.Produces;
>>>> import javax.ws.rs.ext.Provider;
>>>>
>>>> import org.apache.cxf.jaxrs.provider.JSONProvider;
>>>>
>>>> @Produces({"application/json"})
>>>> @Consumes({"application/json"})
>>>> @Provider
>>>> public class ExtendedJSONProvider extends JSONProvider {
>>>>
>>>>    public ExtendedJSONProvider() {
>>>>            setIgnoreNamespaces(true);
>>>>    }
>>>> }
>>>>
>>>>
>>>> Thanks for help!
>>>>
>>>> Cheers,
>>>> Anthony
>>>>
>>>>
>>>> -----Original Message-----
>>>> From: Sergey Beryozkin [mailto:[email protected]]
>>>> Sent: mardi 27 septembre 2011 12:36
>>>> To: [email protected]
>>>> Subject: Re: CXF 2.3.3 - JSON output - java.lang.IllegalStateException: 
>>>> Invalid JSON namespace
>>>>
>>>> Hi
>>>>
>>>> The default Jettison provider expects a namespace-to-prefix map set up.
>>>> If you don't realy need the prefixes on the receiving end then the
>>>> simplest option is to configure JSONProvider with an "ignoreNamespaces"
>>>> property, otherwise you'd need to provide a map, here is more info:
>>>>
>>>> http://cxf.apache.org/docs/jax-rs-data-bindings.html#JAX-RSDataBindings-ConfiguringJSONprovider
>>>>
>>>> The thing is how to configure it given that you are using
>>>> CXFNonSpringJAXRSServlet.
>>>>
>>>> One option is to extend JSONProvider and only set "ignoreNamespace" or
>>>> "namespaceMap" property as needed on the superclass. And register it
>>>> with the servlet using a jaxrs.providers parameter.
>>>>
>>>> Another option is try registering Jackson.
>>>>
>>>> I should probably do some enhancement for users be able to set simple
>>>> properties on providers registered from web.xml...
>>>>
>>>> Cheers, Sergey
>>>>
>>>>
>>>> On 27/09/11 10:41, Muller, Anthony wrote:
>>>>> Hello,
>>>>>
>>>>> I have an issue when I try to get a JSON output, using a JAXB object, of 
>>>>> my REST webservice. (XML output is ok.)
>>>>>
>>>>> My webservice is running without using Spring.
>>>>>
>>>>> Can you help me? I don't know how to fix it despite browsing many 
>>>>> websites from Google.
>>>>>
>>>>> Cheers,
>>>>> Anthony
>>>>>
>>>>>
>>>>> The exception is:
>>>>> javax.ws.rs.WebApplicationException: java.lang.IllegalStateException: 
>>>>> Invalid JSON namespace: http://www.w3.org/2001/XMLSchema-instance
>>>>>                      at 
>>>>> org.apache.cxf.jaxrs.provider.JSONProvider.writeTo(JSONProvider.java:291)
>>>>>                      at 
>>>>> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(JAXRSOutInterceptor.java:256)
>>>>>                      at 
>>>>> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processResponse(JAXRSOutInterceptor.java:144)
>>>>>                      at 
>>>>> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(JAXRSOutInterceptor.java:83)
>>>>>                      at 
>>>>> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:255)
>>>>>                      at 
>>>>> org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:77)
>>>>>                      at 
>>>>> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:255)
>>>>>                      at 
>>>>> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:113)
>>>>>                      at 
>>>>> org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:97)
>>>>>                      at 
>>>>> org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:461)
>>>>>                      at 
>>>>> org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:149)
>>>>>                      at 
>>>>> com.sap.bip.rs.server.servlet.BIPServletController.invoke(BIPServletController.java:90)
>>>>>                      at 
>>>>> org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:148)
>>>>>                      at 
>>>>> org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:179)
>>>>>                      at 
>>>>> org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:108)
>>>>>                      at 
>>>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
>>>>>                      at 
>>>>> org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:159)
>>>>>                      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.core.StandardHostValve.invoke(StandardHostValve.java:127)
>>>>>                      at 
>>>>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>>>>>                      at 
>>>>> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:555)
>>>>>                      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:722)
>>>>> Caused by: java.lang.IllegalStateException: Invalid JSON namespace: 
>>>>> http://www.w3.org/2001/XMLSchema-instance
>>>>>                      at 
>>>>> org.codehaus.jettison.mapped.MappedNamespaceConvention.getJSONNamespace(MappedNamespaceConvention.java:248)
>>>>>                      at 
>>>>> org.codehaus.jettison.mapped.MappedNamespaceConvention.createAttributeKey(MappedNamespaceConvention.java:233)
>>>>>                      at 
>>>>> org.codehaus.jettison.mapped.MappedXMLStreamWriter.writeAttribute(MappedXMLStreamWriter.java:216)
>>>>>                      at 
>>>>> org.apache.cxf.staxutils.DelegatingXMLStreamWriter.writeAttribute(DelegatingXMLStreamWriter.java:71)
>>>>>                      at 
>>>>> org.apache.cxf.jaxrs.provider.JSONUtils$IgnoreContentJettisonWriter.writeAttribute(JSONUtils.java:204)
>>>>>                      at 
>>>>> org.apache.cxf.staxutils.DelegatingXMLStreamWriter.writeAttribute(DelegatingXMLStreamWriter.java:71)
>>>>>                      at 
>>>>> com.sun.xml.internal.bind.v2.runtime.output.XMLStreamWriterOutput.attribute(XMLStreamWriterOutput.java:122)
>>>>>                      at 
>>>>> com.sun.xml.internal.bind.v2.runtime.XMLSerializer.attribute(XMLSerializer.java:403)
>>>>>                      at 
>>>>> com.sun.xml.internal.bind.v2.runtime.XMLSerializer.writeXsiNilTrue(XMLSerializer.java:764)
>>>>>                      at 
>>>>> com.sun.xml.internal.bind.v2.runtime.property.SingleElementLeafProperty.serializeBody(SingleElementLeafProperty.java:91)
>>>>>                      at 
>>>>> com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:306)
>>>>>                      at 
>>>>> com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:664)
>>>>>                      at 
>>>>> com.sun.xml.internal.bind.v2.runtime.property.ArrayElementNodeProperty.serializeItem(ArrayElementNodeProperty.java:54)
>>>>>                      at 
>>>>> com.sun.xml.internal.bind.v2.runtime.property.ArrayElementProperty.serializeListBody(ArrayElementProperty.java:157)
>>>>>                      at 
>>>>> com.sun.xml.internal.bind.v2.runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:141)
>>>>>                      at 
>>>>> com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:306)
>>>>>                      at 
>>>>> com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:561)
>>>>>                      at 
>>>>> com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:290)
>>>>>                      at 
>>>>> com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:462)
>>>>>                      at 
>>>>> com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:314)
>>>>>                      at 
>>>>> com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:161)
>>>>>                      at 
>>>>> org.apache.cxf.jaxrs.provider.JSONProvider.marshal(JSONProvider.java:344)
>>>>>                      at 
>>>>> org.apache.cxf.jaxrs.provider.JSONProvider.marshal(JSONProvider.java:377)
>>>>>                      at 
>>>>> org.apache.cxf.jaxrs.provider.JSONProvider.writeTo(JSONProvider.java:283)
>>>>
>>>
>>
>

Reply via email to