0 Replies Latest reply on Oct 1, 2017 2:03 AM by Ganesh G

    Invalid Json namespace exception thrown in REST using Jettison

    Ganesh G Newbie

      We re using Jboss 6.3.3 GA version for deploying webservices. There is a rest request that supports both Json and XML formats. We have also addded @Mapped annotation to map Xmlns to Json ns.

       @Mapped( namespace = { @XmlNsMap(namespace = aa.bb.cc.dd”, jsonName = ””), @XmlNsMap(namespace = http://www.w3.org/2001/XMLSchema-instance”, jsonName = ”xsi”)  })

      We get responses all the time when using Xml format. But when using Json format, we are getting the following exception.

      We used resteasy-jettison-provider-2.3.5.Final.jar to compile and build the war file. However in Jboss it uses resteasy-jettison-provider-2.3.8.SP4-redhat-2.jar for processing the REST request as seen in the stacktrace below.

      This is happening persistently in one server. Any help on how to resolve this issue would be of great help.

      Failed executing GET <xx/yy/zz>: org.jboss.resteasy.spi.WriterException: ja va.lang.IllegalStateException: Invalid JSON namespace: aa.bb.cc.dd at org.jboss.resteasy.core.ServerResponse.writeTo(ServerResponse.ja
        va
      :262) [resteasy-jaxrs-2.3.8.SP4-redhat-2.jar:]
        at org
      .jboss.resteasy.core.SynchronousDispatcher.writeJaxrsResponse
        
      (SynchronousDispatcher.java:616) [resteasy-jaxrs-2.3.8.SP4-redhat-2.jar:]
        at org
      .jboss.resteasy.core.SynchronousDispatcher.invoke(Synchronous
        
      Dispatcher.java:528) [resteasy-jaxrs-2.3.8.SP4-redhat-2.jar:]
        at org
      .jboss.resteasy.core.SynchronousDispatcher.invoke(Synchronous
        
      Dispatcher.java:126) [resteasy-jaxrs-2.3.8.SP4-redhat-2.jar:]
        at org
      .jboss.resteasy.plugins.server.servlet.ServletContainerDispat
        cher
      .service(ServletContainerDispatcher.java:208) [resteasy-jaxrs-2.3.8.SP4
        
      -redhat-2.jar:]
        at org
      .jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.
        service
      (HttpServletDispatcher.java:55) [resteasy-jaxrs-2.3.8.SP4-redhat-2.j
        ar
      :]
        at org
      .jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.
        service
      (HttpServletDispatcher.java:50) [resteasy-jaxrs-2.3.8.SP4-redhat-2.j
        ar
      :]
        at javax
      .servlet.http.HttpServlet.service(HttpServlet.java:847) [jb
        oss
      -servlet-api_3.0_spec-1.0.2.Final-redhat-1.jar:1.0.2.Final-redhat-1]
        at org
      .apache.catalina.core.ApplicationFilterChain.internalDoFilter
        
      (ApplicationFilterChain.java:295) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.1
        
      0.Final-redhat-1]
        at org
      .apache.catalina.core.ApplicationFilterChain.doFilter(Applica
        tionFilterChain
      .java:214) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-
        redhat
      -1]
        at org
      .apache.catalina.core.StandardWrapperValve.invoke(StandardWra
        pperValve
      .java:231) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redhat
        
      -1]
        at org
      .apache.catalina.core.StandardContextValve.invoke(StandardCon
        textValve
      .java:149) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redhat
        
      -1]
        at org
      .jboss.modcluster.container.jbossweb.JBossWebContext$RequestL
        istenerValve
      .event(JBossWebContext.java:91)
        at org
      .jboss.modcluster.container.jbossweb.JBossWebContext$RequestL
        istenerValve
      .invoke(JBossWebContext.java:72)
        at org
      .jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNon
        
      TxEmCloserValve.java:50) [jboss-as-jpa-7.4.3.Final-redhat-2.jar:7.4.3.Final
        
      -redhat-2]
        at org
      .jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNon
        
      TxEmCloserValve.java:50) [jboss-as-jpa-7.4.3.Final-redhat-2.jar:7.4.3.Final
        
      -redhat-2]
        at org
      .apache.catalina.authenticator.AuthenticatorBase.invoke(Authe
        nticatorBase
      .java:420) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-red
        hat
      -1]
        at org
      .jboss.as.web.security.SecurityContextAssociationValve.invoke
        
      (SecurityContextAssociationValve.java:169) [jboss-as-web-7.4.3.Final-redhat
        
      -2.jar:7.4.3.Final-redhat-2]
        at org
      .apache.catalina.core.StandardHostValve.invoke(StandardHostVa
        lve
      .java:145) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redhat-1]
        at org
      .apache.catalina.valves.ErrorReportValve.invoke(ErrorReportVa
        lve
      .java:97) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redhat-1]
        at org
      .jboss.as.web.sso.ClusteredSingleSignOn.invoke(ClusteredSing
        eSignOn
      .java:356) [jboss-as-web-7.4.3.Final-redhat-2.jar:7.4.3.Final-redhat
        
      -2]
        at org
      .apache.catalina.core.StandardEngineValve.invoke(StandardEngi
        neValve
      .java:102) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redhat-1
        
      ]
        at org
      .apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapte
        r
      .java:344) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redhat-1]
        at org
      .apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:490
        
      ) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redhat-1]
        at org
      .apache.coyote.ajp.AjpProtocol$AjpConnectionHandler.process(A
        jpProtocol
      .java:420) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redha
        t
      -1]
        at org
      .apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.ja
        va
      :926) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redhat-1]
        at java
      .lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_85]
        
      Caused by: java.lang.IllegalStateException: Invalid JSON namespace: aa.bb.cc.dd
        at org
      .codehaus.jettison.mapped.MappedNamespaceConvention.getJSONNa
        mespace
      (MappedNamespaceConvention.java:248) [jettison-1.3.1.redhat-4.jar:1.
        
      3.1.redhat-4]
        at org
      .codehaus.jettison.mapped.MappedNamespaceConvention.createKey
        
      (MappedNamespaceConvention.java:257) [jettison-1.3.1.redhat-4.jar:1.3.1.red
        hat
      -4]
        at org
      .codehaus.jettison.mapped.MappedXMLStreamWriter.writeStartEle
        ment
      (MappedXMLStreamWriter.java:220) [jettison-1.3.1.redhat-4.jar:1.3.1.red
        hat
      -4]
        at com
      .sun.xml.bind.v2.runtime.output.XMLStreamWriterOutput.beginSt
        artTag
      (XMLStreamWriterOutput.java:118) [jaxb-impl-2.2.5.redhat-8.jar:2.2.4]
        at com
      .sun.xml.bind.v2.runtime.output.XmlOutputAbstractImpl.beginSt
        artTag
      (XmlOutputAbstractImpl.java:102) [jaxb-impl-2.2.5.redhat-8.jar:2.2.4]
        at com
      .sun.xml.bind.v2.runtime.output.NamespaceContextImpl$Element.
        startElement
      (NamespaceContextImpl.java:496) [jaxb-impl-2.2.5.redhat-8.jar:2
        
      .2.4]
        at com
      .sun.xml.bind.v2.runtime.XMLSerializer.endNamespaceDecls(XMLS
        erializer
      .java:291) [jaxb-impl-2.2.5.redhat-8.jar:2.2.4]
        at com
      .sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSeri
        alizer
      .java:687) [jaxb-impl-2.2.5.redhat-8.jar:2.2.4]
        at com
      .sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.s
        erializeBody
      (SingleElementNodeProperty.java:158) [jaxb-impl-2.2.5.redhat-8.
        jar
      :2.2.4]
        at com
      .sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(
        
      ElementBeanInfoImpl.java:161) [jaxb-impl-2.2.5.redhat-8.jar:2.2.4]
        at com
      .sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(
        
      ElementBeanInfoImpl.java:205) [jaxb-impl-2.2.5.redhat-8.jar:2.2.4]
        at com
      .sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(El
        ementBeanInfoImpl
      .java:333) [jaxb-impl-2.2.5.redhat-8.jar:2.2.4]
        at com
      .sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(El
        ementBeanInfoImpl
      .java:340) [jaxb-impl-2.2.5.redhat-8.jar:2.2.4]
        at com
      .sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(El
        ementBeanInfoImpl
      .java:76) [jaxb-impl-2.2.5.redhat-8.jar:2.2.4]
        at com
      .sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSeriali
        zer
      .java:498) [jaxb-impl-2.2.5.redhat-8.jar:2.2.4]
        at com
      .sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.
        java
      :323) [jaxb-impl-2.2.5.redhat-8.jar:2.2.4]
        at com
      .sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImp
        l
      .java:178) [jaxb-impl-2.2.5.redhat-8.jar:2.2.4]
        at org
      .jboss.resteasy.plugins.providers.jaxb.json.JettisonMappedMar
        shaller
      .marshal(JettisonMappedMarshaller.java:71) [resteasy-jettison-provid
        er
      -2.3.8.SP4-redhat-2.jar:]
        at org
      .jboss.resteasy.plugins.providers.jaxb.BaseMarshaller.marshal
        
      (BaseMarshaller.java:24) [resteasy-jaxb-provider-2.3.8.SP4-redhat-2.jar:]
        at org
      .jboss.resteasy.plugins.providers.jaxb.AbstractJAXBProvider.w
        riteTo
      (AbstractJAXBProvider.java:138) [resteasy-jaxb-provider-2.3.8.SP4-red
        hat
      -2.jar:]
        at org
      .jboss.resteasy.plugins.providers.jaxb.JAXBXmlTypeProvider.wr
        iteTo
      (JAXBXmlTypeProvider.java:73) [resteasy-jaxb-provider-2.3.8.SP4-redhat
        
      -2.jar:]
        at org
      .jboss.resteasy.core.interception.MessageBodyWriterContextImp
        l
      .proceed(MessageBodyWriterContextImpl.java:117) [resteasy-jaxrs-2.3.8.SP4-
        redhat
      -2.jar:]

        at org
      .jboss.resteasy.core.interception.MessageBodyWriterContextImp
        l
      .proceed(MessageBodyWriterContextImpl.java:123) [resteasy-jaxrs-2.3.8.SP4-
        redhat
      -2.jar:]
        at org
      .jboss.resteasy.core.interception.MessageBodyWriterContextImp
        l
      .proceed(MessageBodyWriterContextImpl.java:123) [resteasy-jaxrs-2.3.8.SP4-
        redhat
      -2.jar:]
        at org
      .jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInt
        erceptor
      .write(GZIPEncodingInterceptor.java:104) [resteasy-jaxrs-2.3.8.SP4-
        redhat
      -2.jar:]
        at org
      .jboss.resteasy.core.interception.MessageBodyWriterContextImp
        l
      .proceed(MessageBodyWriterContextImpl.java:123) [resteasy-jaxrs-2.3.8.SP4-
        redhat
      -2.jar:]
        at org
      .jboss.resteasy.core.ServerResponse.writeTo(ServerResponse.ja
        va
      :250) [resteasy-jaxrs-2.3.8.SP4-redhat-2.jar:]
        
      ... 26 more