cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexandros Karypidis" <kary...@gmail.com>
Subject Re: Controlling the JAXB context [javax.xml.bind.JAXBException: class SomeClass nor any of its super class is known to this context.]
Date Tue, 26 Apr 2011 13:38:01 GMT
Sorry about this question; just realized it's purely JAXB-related.

I've gotten around it by using @XmlSeeAlso as follows:

@XmlRootElement(name = "resultsPage")
@XmlSeeAlso({ ArticleInfo.class })
public class ArticlePage extends ResultsPage<ArticleInfo> {
}

On Tue, 26 Apr 2011 16:23:10 +0300, Alexandros Karypidis  
<karypid@gmail.com> wrote:

> Hello,
>
> I am using CXF 2.4.0 + Spring 3.0.5 to create JAX-RS services. In one  
> case I have a service for which I need to marshal a generic type. When I  
> go about doing this, I end up getting an exception like this:
>
> [javax.xml.bind.JAXBException: class my.package.ArticleInfo nor any of  
> its super class is known to this context.]
> 	at  
> com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:318)
> 	at  
> com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:172)
> 	at  
> org.apache.cxf.jaxrs.provider.JSONProvider.marshal(JSONProvider.java:387)
> 	at  
> org.apache.cxf.jaxrs.provider.JSONProvider.marshal(JSONProvider.java:420)
> 	at  
> org.apache.cxf.jaxrs.provider.JSONProvider.writeTo(JSONProvider.java:300)
> 	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:263)
> 	at  
> org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:77)
> 	at  
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
> 	at  
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:118)
> 	at  
> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:208)
> 	at  
> org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:223)
> 	at  
> org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:166)
> 	at  
> org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:113)
> 	at  
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:184)
> 	at  
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:112)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:575)
>
> My data types are:
>
> @XmlRootElement(name = "resultsPage")
> public class ResultsPage<T> {
> 	int pageOffset;
> 	int count;
> }
>
> @XmlRootElement(name = "resultsPage")
> public class ArticlePage extends ResultsPage<ArticleInfo> {
> 	// no extra fields here; just specializes the generic
> }
>
> @XmlRootElement(name = "resultsPage")
> public class StaffPage extends ResultsPage<StaffInfo> {
> 	// no extra fields here; just specializes the generic
>
> }
>
> How would I instruct CXF to include the classes ArticleInfo/StafInfo/etc  
> in the JAXBContext used to marshal/unmarshal the data?

Mime
View raw message