javax.xml.bind.JAXBException: class nl.knowledgeplaza.profiler.services.support.Users nor any of its super class is known to this context.]

Apache's JIRA Issue Tracker | Tom | 8 years ago
  1. 0

    The UserService: @javax.jws.WebService public interface UserService extends AbstractService<User, Users> { } The AbstractService: @javax.jws.WebService public interface AbstractService<T, Ts> { public Ts list(); } The UserServiceImpl: @javax.jws.WebService(endpointInterface = "nl.knowledgeplaza.profiler.services.UserService", serviceName = "users") // the "ws" prefix is handled by the container public class UserServiceImpl implements UserService { public Users list() { try { if (slf4j.isDebugEnabled()) slf4j.debug("list User"); // find all List<User> lList = User.findAll(); if (slf4j.isDebugEnabled()) slf4j.debug("list User size={}", lList.size()); // create a collection so JAXB knows what to do Users lUsers= new Users(lList); // done return lUsers; } catch (RuntimeException e) { slf4j.error(ExceptionUtil.describe(e), e); throw e; } } } UnitTests start the SOAP end point as follows: javax.xml.ws.Endpoint.publish(cWSUserAddress, new UserServiceImpl()); The unittest: @org.junit.Test public void listUsersSOAP() { // create a proxy to the service JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.getInInterceptors().add(new LoggingInInterceptor()); factory.getOutInterceptors().add(new LoggingOutInterceptor()); factory.setServiceClass(UserService.class); factory.setAddress(cWSUserAddress); UserService lUserService = (UserService)factory.create(); // make the call Users lUsers = lUserService.list(); // check it org.fest.assertions.Assertions.assertThat( lUsers.getUser().size() ).isGreaterThan(0); } The call arrives serverside, the code is correctly executed and 4 User entities have been fetched from the database. The JAXB marshalling then runs into problems, resulting in a value of null being returned on the clients side, and failing the unittest on a NPE. The trace: May 22, 2009 11:29:00 AM org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback onClose INFO: Outbound Message --------------------------- ID: 2 Address: http://localhost:9000/ws/user Encoding: UTF-8 Content-Type: text/xml Headers: {SOAPAction=[""], Accept=[*/*]} Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:list xmlns:ns1="http://services.profiler.knowledgeplaza.nl/" /></soap:Body></soap:Envelope> -------------------------------------- [33299971@qtp-22864463-1] 2009-05-22 11:29:06,296 DEBUG nl.knowledgeplaza.profiler.services.UserServiceImpl.list(UserServiceImpl.java:48) list User [EL Fine]: 2009-05-22 11:29:07.093--ServerSession(15545028)--Connection(13749345)--Thread(Thread[33299971@qtp-22864463-1,5,main])--SELECT id, username, middlename, email, lastname, callname, firstname, version FROM KP_USER [33299971@qtp-22864463-1] 2009-05-22 11:29:08,750 DEBUG nl.knowledgeplaza.profiler.services.UserServiceImpl.list(UserServiceImpl.java:52) list User size=4 May 22, 2009 11:29:11 AM org.apache.cxf.phase.PhaseInterceptorChain doIntercept INFO: Interceptor has thrown exception, unwinding now org.apache.cxf.interceptor.Fault: Marshalling Error: class nl.knowledgeplaza.profiler.services.support.Users nor any of its super class is known to this context. at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:159) at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:169) at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:105) at org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236) at org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:74) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:89) at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:302) at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:265) at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:70) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765) at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:324) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535) at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:880) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:747) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409) at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520) Caused by: javax.xml.bind.MarshalException - with linked exception: [javax.xml.bind.JAXBException: class nl.knowledgeplaza.profiler.services.support.Users nor any of its super class is known to this context.] at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:328) at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:254) at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:75) at org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:441) at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:138) ... 21 more Caused by: javax.xml.bind.JAXBException: class nl.knowledgeplaza.profiler.services.support.Users nor any of its super class is 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.XMLSerializer.childAsXsiType(XMLSerializer.java:649) at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:151) at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:185) at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:305) at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:312) at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.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:325) ... 25 more Caused by: javax.xml.bind.JAXBException: class nl.knowledgeplaza.profiler.services.support.Users nor any of its super class is known to this context. at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:566) at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:644) ... 32 more May 22, 2009 11:29:12 AM org.apache.cxf.interceptor.LoggingInInterceptor logging INFO: Inbound Message ---------------------------- ID: 2 Encoding: UTF-8 Content-Type: text/xml; charset=utf-8 Headers: {content-type=[text/xml; charset=utf-8], Content-Length=[415], Server=[Jetty(6.1.15)]} Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:listResponse xmlns:ns1="http://services.profiler.knowledgeplaza.nl/"><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Marshalling Error: class nl.knowledgeplaza.profiler.services.support.Users nor any of its super class is known to this context.</faultstring></soap:Fault></ns1:listResponse></soap:Body></soap:Envelope> -------------------------------------- The Users class is just a collection workaround as suggested in CXF's documentation: @XmlRootElement(name = "users") public class Users implements Serializable { public Users() { setUser(new ArrayList<User>()); } // upon JAXB unmarshalling of an empty collection, the setUser is NOT called and the collection would be null instead of empty public Users(Collection<User> c) { setUser(c); } private Collection<User> iCollection; public Collection<User> getUser() { return iCollection; } public void setUser(Collection<User> c) { iCollection = c; } public List<User> asList() { return new ArrayList<User>(iCollection); } }

    Apache's JIRA Issue Tracker | 8 years ago | Tom
    javax.xml.bind.JAXBException: class nl.knowledgeplaza.profiler.services.support.Users nor any of its super class is known to this context.]
  2. 0

    The UserService: @javax.jws.WebService public interface UserService extends AbstractService<User, Users> { } The AbstractService: @javax.jws.WebService public interface AbstractService<T, Ts> { public Ts list(); } The UserServiceImpl: @javax.jws.WebService(endpointInterface = "nl.knowledgeplaza.profiler.services.UserService", serviceName = "users") // the "ws" prefix is handled by the container public class UserServiceImpl implements UserService { public Users list() { try { if (slf4j.isDebugEnabled()) slf4j.debug("list User"); // find all List<User> lList = User.findAll(); if (slf4j.isDebugEnabled()) slf4j.debug("list User size={}", lList.size()); // create a collection so JAXB knows what to do Users lUsers= new Users(lList); // done return lUsers; } catch (RuntimeException e) { slf4j.error(ExceptionUtil.describe(e), e); throw e; } } } UnitTests start the SOAP end point as follows: javax.xml.ws.Endpoint.publish(cWSUserAddress, new UserServiceImpl()); The unittest: @org.junit.Test public void listUsersSOAP() { // create a proxy to the service JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.getInInterceptors().add(new LoggingInInterceptor()); factory.getOutInterceptors().add(new LoggingOutInterceptor()); factory.setServiceClass(UserService.class); factory.setAddress(cWSUserAddress); UserService lUserService = (UserService)factory.create(); // make the call Users lUsers = lUserService.list(); // check it org.fest.assertions.Assertions.assertThat( lUsers.getUser().size() ).isGreaterThan(0); } The call arrives serverside, the code is correctly executed and 4 User entities have been fetched from the database. The JAXB marshalling then runs into problems, resulting in a value of null being returned on the clients side, and failing the unittest on a NPE. The trace: May 22, 2009 11:29:00 AM org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback onClose INFO: Outbound Message --------------------------- ID: 2 Address: http://localhost:9000/ws/user Encoding: UTF-8 Content-Type: text/xml Headers: {SOAPAction=[""], Accept=[*/*]} Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:list xmlns:ns1="http://services.profiler.knowledgeplaza.nl/" /></soap:Body></soap:Envelope> -------------------------------------- [33299971@qtp-22864463-1] 2009-05-22 11:29:06,296 DEBUG nl.knowledgeplaza.profiler.services.UserServiceImpl.list(UserServiceImpl.java:48) list User [EL Fine]: 2009-05-22 11:29:07.093--ServerSession(15545028)--Connection(13749345)--Thread(Thread[33299971@qtp-22864463-1,5,main])--SELECT id, username, middlename, email, lastname, callname, firstname, version FROM KP_USER [33299971@qtp-22864463-1] 2009-05-22 11:29:08,750 DEBUG nl.knowledgeplaza.profiler.services.UserServiceImpl.list(UserServiceImpl.java:52) list User size=4 May 22, 2009 11:29:11 AM org.apache.cxf.phase.PhaseInterceptorChain doIntercept INFO: Interceptor has thrown exception, unwinding now org.apache.cxf.interceptor.Fault: Marshalling Error: class nl.knowledgeplaza.profiler.services.support.Users nor any of its super class is known to this context. at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:159) at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:169) at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:105) at org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236) at org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:74) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:89) at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:302) at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:265) at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:70) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765) at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:324) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535) at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:880) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:747) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409) at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520) Caused by: javax.xml.bind.MarshalException - with linked exception: [javax.xml.bind.JAXBException: class nl.knowledgeplaza.profiler.services.support.Users nor any of its super class is known to this context.] at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:328) at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:254) at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:75) at org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:441) at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:138) ... 21 more Caused by: javax.xml.bind.JAXBException: class nl.knowledgeplaza.profiler.services.support.Users nor any of its super class is 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.XMLSerializer.childAsXsiType(XMLSerializer.java:649) at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:151) at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:185) at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:305) at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:312) at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.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:325) ... 25 more Caused by: javax.xml.bind.JAXBException: class nl.knowledgeplaza.profiler.services.support.Users nor any of its super class is known to this context. at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:566) at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:644) ... 32 more May 22, 2009 11:29:12 AM org.apache.cxf.interceptor.LoggingInInterceptor logging INFO: Inbound Message ---------------------------- ID: 2 Encoding: UTF-8 Content-Type: text/xml; charset=utf-8 Headers: {content-type=[text/xml; charset=utf-8], Content-Length=[415], Server=[Jetty(6.1.15)]} Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:listResponse xmlns:ns1="http://services.profiler.knowledgeplaza.nl/"><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Marshalling Error: class nl.knowledgeplaza.profiler.services.support.Users nor any of its super class is known to this context.</faultstring></soap:Fault></ns1:listResponse></soap:Body></soap:Envelope> -------------------------------------- The Users class is just a collection workaround as suggested in CXF's documentation: @XmlRootElement(name = "users") public class Users implements Serializable { public Users() { setUser(new ArrayList<User>()); } // upon JAXB unmarshalling of an empty collection, the setUser is NOT called and the collection would be null instead of empty public Users(Collection<User> c) { setUser(c); } private Collection<User> iCollection; public Collection<User> getUser() { return iCollection; } public void setUser(Collection<User> c) { iCollection = c; } public List<User> asList() { return new ArrayList<User>(iCollection); } }

    Apache's JIRA Issue Tracker | 8 years ago | Tom
    javax.xml.bind.JAXBException: class nl.knowledgeplaza.profiler.services.support.Users nor any of its super class is known to this context.]
  3. 0

    [jira] Created: (CXF-2234) Unmarshalling with JAXB of a method that is defined in an inherited interface results in an NPE exception

    apache.org | 1 year ago
    javax.xml.bind.JAXBException: class nl.knowledgeplaza.profiler.services.support.Users nor any of its super class is known to this context.]
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    problem calling an asmx C# webservice from grails

    Stack Overflow | 6 years ago | Derek
    javax.xml.bind.JAXBException: class [Ljava.lang.String; nor any of its super class is known to this context.]
  6. 0

    grails webservices returning an object List

    Stack Overflow | 7 years ago | pbanfi
    javax.xml.bind.JAXBException: java.util.ArrayList is not known to this context]

    2 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. javax.xml.bind.JAXBException

      class nl.knowledgeplaza.profiler.services.support.Users nor any of its super class is known to this context.

      at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo()
    2. Old JAXB Runtime
      MarshallerImpl.marshal
      1. com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:566)
      2. com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:644)
      3. com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:242)
      4. com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:257)
      5. com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:649)
      6. com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:151)
      7. com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:185)
      8. com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:305)
      9. com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:312)
      10. com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:71)
      11. com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:490)
      12. com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:325)
      13. com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:328)
      14. com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:254)
      14 frames
    3. Java RT
      AbstractMarshallerImpl.marshal
      1. javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:75)
      1 frame
    4. Apache CXF Runtime JAXB DataBinding
      JAXBEncoderDecoder.marshall
      1. org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:441)
      2. org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:138)
      2 frames