Interesting.  Would that mean I would have to use seekAlso and list all of the 
objects that could possibly be returned - I have currently about six types of 
custom objects.  What if I was returning a type like a boolean or just a string?

________________________________

From: Daniel Kulp [mailto:[EMAIL PROTECTED]
Sent: Tue 1/22/2008 5:31 PM
To: cxf-user@incubator.apache.org
Cc: Vespa, Anthony J
Subject: Re: JSON and JAX-RS




Well, looking at the code, it seems to create a new JAXBContext for each
top level type, which really sucks.   IMO, it should use our
JAXBDatabinding in some way which would allow it/you to configure things
via spring or something so one one JAXBContext is created/used that
would have all the required types in it.   Actually, checking if there
is an ObjectFactory in the package and creating the context based on
that would also go a long way to helping. 

That said,  with JAXB 2.1, you can probably add an @XmlSeeAlso annation
on the wsResponse that points to the wsMessage to make the JAXBContext
for the wsResponse be able to marshal the wsMessage as well.

Dan


On Tuesday 22 January 2008, Vespa, Anthony J wrote:
> So I spent some time playing with JAX-RS and I seem to have
> encountered an issue.
>
> I can return single objects from my service as JSON (standard Java
> types as well as my custom objects) but if I try to return my wrapper
> object which contains an anytype generic list, I get an exception.
>
> Effectively I have an object called wsResponse that, in this case, is
> returning an array of messages (wsMessage) - I have decorated both
> objects with the XMLType.  I am looking into this exception and see
> references to JAXB; is it possible to get around this?
>
>
>
> Jan 22, 2008 4:45:26 PM
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor handleMessage
> INFO: Available content types for response is: application/json,
> Jan 22, 2008 4:45:26 PM
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor handleMessage
> INFO: Response EntityProvider is:
> org.apache.cxf.jaxrs.provider.JSONProvider
> Jan 22, 2008 4:45:26 PM
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor handleMessage
> INFO: Response content type is: application/json
> javax.xml.bind.MarshalException
>  - with linked exception:
> [javax.xml.bind.JAXBException: class com.cbs.bos.data.ws.wsMessage nor
> any of its super class is known to this context.]
>         at
> com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:2
>95 )
>         at
> com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java
>:1 48)
>         at
> org.apache.cxf.jaxrs.provider.JSONProvider.writeTo(JSONProvider.java:9
>0) at
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(JAX
>RS OutInterceptor.java:99)
>         at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercepto
>rC hain.java:208)
>         at
> org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(Outg
>oi ngChainInterceptor.java:74)
>         at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercepto
>rC hain.java:208)
>         at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitia
>ti onObserver.java:78)
>         at
> org.apache.cxf.transport.servlet.ServletDestination.doMessage(ServletD
>es tination.java:79)
>         at
> org.apache.cxf.transport.servlet.ServletController.invokeDestination(S
>er vletController.java:264)
>         at
> org.apache.cxf.transport.servlet.ServletController.invoke(ServletContr
>ol ler.java:123)
>         at
> org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXF
>Se rvlet.java:170)
>         at
> org.apache.cxf.transport.servlet.AbstractCXFServlet.doGet(AbstractCXFS
>er vlet.java:152)
>         at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:690) at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appli
>ca tionFilterChain.java:290)
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFi
>lt erChain.java:206)
>         at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVa
>lv e.java:233)
>         at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextVa
>lv e.java:175)
>         at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.ja
>va
>
> :128)
>
>         at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.ja
>va
>
> :102)
>
>         at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValv
>e. java:109)
>         at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java
>:2 63)
>         at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:
>84 4)
>         at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proces
>s( Http11Protocol.java:584)
>         at
> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447
>)



--
J. Daniel Kulp
Principal Engineer, IONA
[EMAIL PROTECTED]
http://www.dankulp.com/blog


Reply via email to