Uploaded image for project: 'TomEE'
  1. TomEE
  2. TOMEE-515

NoClassDefFoundError Exception while marshaling data in CXF RS to JSON

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.1
    • Fix Version/s: 1.5.1
    • Component/s: None
    • Labels:
    • Environment:
      1.5.1-SNAPSHOT from today, Nov 1st 2012

      Description

      Hi,

      I have very strange phenomena when using CXF RS. For different methods I
      get different class not found exceptions for the classes that are
      definitely in either lib or endorsed folder of TomEE itself.

      It is to be noted that the exception in the first method (processSchedule) occurs only with accept="application/json". If accept="application/xml", marshaling works as expected and correct result (formatted as xml) is returned!

      Bean is defined as:

      @Path("/schedule")
      @Stateless
      @WebService(targetNamespace = "http://mythingy.de/")
      public class SchedulerServiceRS {

      This method:

      @Produces(

      {"application/json", "application/xml"})
      @Consumes({"application/json", "application/xml"}

      )
      @POST
      @Path("/process")
      public Schedule processSchedule(Schedule initialSchedule) throws
      ScheduleConfigurationException

      cause

      java.lang.NoClassDefFoundError:
      com/sun/xml/bind/marshaller/NamespacePrefixMapper
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
      at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
      at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
      at org.apache.cxf.jaxrs.provider.AbstractJAXBProvider.setNamespaceMapper(AbstractJAXBProvider.java:137)
      at org.apache.cxf.jaxrs.provider.json.JSONProvider.marshal(JSONProvider.java:515)
      at org.apache.cxf.jaxrs.provider.json.JSONProvider.writeTo(JSONProvider.java:361)
      at org.apache.cxf.jaxrs.utils.JAXRSUtils.writeMessageBody(JAXRSUtils.java:1173)
      at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(JAXRSOutInterceptor.java:259)
      at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processResponse(JAXRSOutInterceptor.java:155)
      at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(JAXRSOutInterceptor.java:86)
      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:238)
      at org.apache.openejb.server.cxf.rs.CxfRsHttpListener.onMessage(CxfRsHttpListener.java:70)
      at org.apache.openejb.server.rest.RsServlet.service(RsServlet.java:53)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
      at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:45)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
      at java.lang.Thread.run(Thread.java:722)
      Caused by: java.lang.ClassNotFoundException:
      com.sun.xml.bind.marshaller.NamespacePrefixMapper
      at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
      ... 43 more
      Nov 01, 2012 5:16:09 PM org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor writeResponseErrorMessage

      ----------------------------------------------------------------------

      and this method:

      @Produces(

      {"application/json"}

      )
      @Consumes(

      {"appllication/json","application/xml"}

      )
      @GET
      @Path("/get")
      public Schedule getSchedule()

      produce:

      WARNING: Error serializing the response, please check the server logs,
      response class : Schedule.
      java.lang.NoClassDefFoundError: org/apache/cxf/common/jaxb/NamespaceMapper
      at
      org.apache.cxf.jaxrs.provider.AbstractJAXBProvider.setNamespaceMapper(AbstractJAXBProvider.java:137)
      at
      org.apache.cxf.jaxrs.provider.json.JSONProvider.marshal(JSONProvider.java:515)
      at
      org.apache.cxf.jaxrs.provider.json.JSONProvider.writeTo(JSONProvider.java:361)
      at
      org.apache.cxf.jaxrs.utils.JAXRSUtils.writeMessageBody(JAXRSUtils.java:1173)
      at
      org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(JAXRSOutInterceptor.java:259)
      at
      org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processResponse(JAXRSOutInterceptor.java:155)
      at
      org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(JAXRSOutInterceptor.java:86)
      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:238)
      at
      org.apache.openejb.server.cxf.rs.CxfRsHttpListener.onMessage(CxfRsHttpListener.java:70)
      at org.apache.openejb.server.rest.RsServlet.service(RsServlet.java:53)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      at
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      at
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at
      org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
      at
      org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
      at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:45)
      at
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
      at
      org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
      at
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
      at
      org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
      at
      org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      at
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
      at
      org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
      at
      org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
      at
      org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
      at
      java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
      at
      java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
      at java.lang.Thread.run(Thread.java:722)
      Nov 01, 2012 5:37:07 PM
      org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor
      writeResponseErrorMessage
      WARNING: Error serializing the response, please check the server logs,
      response class : Schedule.

      br
      Reinis

        Attachments

        1. cxf-json-fails.tar.gz
          10 kB
          Reinis Vicups

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              reinis_v Reinis Vicups
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: