You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by marcelcasado <ma...@ucar.edu> on 2010/08/09 21:20:00 UTC

cxf rest : how to deal with

Hi,

I got a jaxrs:server endpoint with JAXB data bindings running but the
response schema has <xs:any> elements on it. I have the jaxb bindings for
the elements I use but I don't know how to make those available  to the
"context". So I get this error when the service is marshalling the response
:

[2010-08-09 13:15:04.211] ERROR 1423476935@qtp-1025320475-3  NNEW-Business                                                   
edu.ucar.ral.wcsri.rs.RestExceptionMapper - REST exception: 
javax.ws.rs.WebApplicationException: javax.xml.bind.JAXBException:
org.isotc211._2005.gmd.MD_Metadata_Type is not known to this context


I tried to add the @XmlSeeAlso annotation with the factories for those
objects/elements but not luck.

I'm using cxf 2.2.7 in smx 4.2-01

Thanks,

-Marcel
-- 
View this message in context: http://cxf.547215.n5.nabble.com/cxf-rest-how-to-deal-with-xs-any-tp2281907p2281907.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: cxf rest : how to deal with

Posted by marcelcasado <ma...@ucar.edu>.
I figured out how to and I'm posting it here since it can help others :

I created a ContextResolver and added to the jax-rs endpoint :

   <jaxrs:providers>    
      <ref bean="wcsJaxbProvider"/>
   </jaxrs:providers> 


The context resolver looks like :

@SuppressWarnings("unchecked")
@Provider
@Produces("application/xml")
public class WcsJAXBContextResolver implements ContextResolver<JAXBContext>
{

	public static JAXBContext wcsJaxbContext;
	
	static {

		try
    {			
			wcsJaxbContext = JAXBContext.newInstance(
net.opengis.gml.v3_2.ObjectFactory.class,
net.opengis.ows.v1_1_0.ObjectFactory.class,
					org.w3._2001.smil20.ObjectFactory.class,
org.w3._2001.smil20.language.ObjectFactory.class,
edu.ucar.ral.wcsri.iso19139.ObjectFactory.class,
					org.isotc211._2005.gco.ObjectFactory.class,
org.isotc211._2005.gmd.ObjectFactory.class,
org.isotc211._2005.gmx.ObjectFactory.class,
					org.isotc211._2005.gss.ObjectFactory.class,
org.isotc211._2005.srv.ObjectFactory.class);
    }
    catch( JAXBException e )
    {
      throw new RuntimeException( WcsJAXBContextResolver.class.getName() +
": static initializer received a JAXBException when " +
                                  "trying to create a new JAXBContext: " +
e.getMessage(), e );
    }
	}
	
	public JAXBContext getContext(Class<?> type) {	
		return wcsJaxbContext;

	}

}
-- 
View this message in context: http://cxf.547215.n5.nabble.com/cxf-rest-how-to-deal-with-xs-any-tp2281907p2370139.html
Sent from the cxf-user mailing list archive at Nabble.com.