On Tuesday 22 January 2008, Vespa, Anthony J wrote:
> 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?

You should be fine. (although, you probably need to wrapper them with a 
JAXBElement to get the element name)   I think all the stuff that maps 
to straight xsd schema types are always part of the created JAXBContext.   
The stuff you need to be careful of are the things that would be 
generated from the xjc. 

Dan


>
> ________________________________
>
> 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.ja
> >va
> >
> >:1 48)
> >
> >         at
> > org.apache.cxf.jaxrs.provider.JSONProvider.writeTo(JSONProvider.java
> >:9 0) at
> > org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(J
> >AX RS OutInterceptor.java:99)
> >         at
> > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercep
> >to rC hain.java:208)
> >         at
> > org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(Ou
> >tg oi ngChainInterceptor.java:74)
> >         at
> > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercep
> >to rC hain.java:208)
> >         at
> > org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInit
> >ia ti onObserver.java:78)
> >         at
> > org.apache.cxf.transport.servlet.ServletDestination.doMessage(Servle
> >tD 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(ServletCon
> >tr ol ler.java:123)
> >         at
> > org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractC
> >XF Se rvlet.java:170)
> >         at
> > org.apache.cxf.transport.servlet.AbstractCXFServlet.doGet(AbstractCX
> >FS 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(App
> >li ca tionFilterChain.java:290)
> >         at
> > org.apache.catalina.core.ApplicationFilterChain.doFilter(Application
> >Fi lt erChain.java:206)
> >         at
> > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapper
> >Va lv e.java:233)
> >         at
> > org.apache.catalina.core.StandardContextValve.invoke(StandardContext
> >Va 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(StandardEngineVa
> >lv e. java:109)
> >         at
> > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.ja
> >va
> >
> >:2 63)
> >
> >         at
> > org.apache.coyote.http11.Http11Processor.process(Http11Processor.jav
> >a: 84 4)
> >         at
> > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proc
> >es s( Http11Protocol.java:584)
> >         at
> > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:4
> >47 )
>
> --
> J. Daniel Kulp
> Principal Engineer, IONA
> [EMAIL PROTECTED]
> http://www.dankulp.com/blog



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

Reply via email to