users@jersey.java.net

Re: [Jersey] A message body writer for Java type, class org.apache.camel.model.RouteDefinition, and MIME media type, application/json, was not found

From: Jakub Podlesak <Jakub.Podlesak_at_Sun.COM>
Date: Mon, 18 Jan 2010 13:34:33 +0100

RouteDefinition is a regular JAXB class:

@XmlRootElement(name = "route")
@XmlType(propOrder = {"inputs", "outputs" })
@XmlAccessorType(XmlAccessType.PROPERTY)
public class RouteDefinition extends ProcessorDefinition<ProcessorDefinition> implements CamelContextAware {
...

is the jersey-json module, which should contain the required provider, activated?

~Jakub


On Fri, Jan 15, 2010 at 06:36:46AM -0800, cmoulliard wrote:
>
> Hi,
>
> I get the following error :
>
> 15:21:49,743 | ERROR | 4213137_at_qtp1-11 | ContainerResponse |
> .spi.container.ContainerResponse 259 | A message body writer for Java type,
> class org.apache.camel.model.RouteDefinition, and MIME media type,
> application/json, was not found
> 15:21:49,743 | ERROR | 4213137_at_qtp1-11 | ContainerResponse |
> .spi.container.ContainerResponse 477 | Mapped exception to response: 500
> (Internal Server Error)
> javax.ws.rs.WebApplicationException
> at
> com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:268)
> at
> com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1029)
> at
> com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:941)
> at
> com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:932)
> at
> com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:384)
> at
> com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:451)
> at
> com.sun.jersey.spi.container.servlet.ServletContainer.doFilter(ServletContainer.java:797)
> at
> com.sun.jersey.spi.container.servlet.ServletContainer.doFilter(ServletContainer.java:770)
> at
> com.sun.jersey.spi.container.servlet.ServletContainer.doFilter(ServletContainer.java:731)
> at
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)
> at
> com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:39)
> at
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)
> at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:361)
> at
> org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.handle(HttpServiceServletHandler.java:64)
> at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
> at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
> at
> org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.handle(HttpServiceContext.java:111)
> at
> org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:64)
>
> The code works fine when deployed in Jetty standalone but appears when
> deployed in an OSGI container
>
> Here is the content of the code :
>
> /**
> * A single Camel Route which is used to implement one or more
> * http://camel.apache.org/enterprise-integration-patterns.html Enterprise
> Integration Paterns
> *
> * @version $Revision: 897126 $
> */
> public class RouteResource extends CamelChildResourceSupport {
> public static final String LANGUAGE_XML = "Xml";
> public static final String LANGUAGE_GROOVY = "Groovy";
> public static final String LANGUAGE_RUBY = "Ruby";
> public static final String LANGUAGE_SCALA = "Scala";
> private static final transient Log LOG =
> LogFactory.getLog(RouteResource.class);
>
> private RouteDefinition route;
> private String error = "";
> private String id;
>
> // what language is used to define this route
> private String language = LANGUAGE_XML;
>
> public RouteResource(RoutesResource routesResource, RouteDefinition
> route) {
> super(routesResource.getContextResource());
> this.route = route;
> this.id =
> route.idOrCreate(route.getCamelContext().getNodeIdFactory());
> }
>
> /**
> * Returns the XML or JSON representation of this route
> */
> @GET
> @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML,
> MediaType.APPLICATION_JSON})
> public RouteDefinition getRoute() {
> return route;
> }
>
> and
>
> @ImplicitProduces(Constants.HTML_MIME_TYPES)
> public class CamelChildResourceSupport {
> private static final transient Log LOG =
> LogFactory.getLog(CamelChildResourceSupport.class);
>
> private final CamelContext camelContext;
> private final ProducerTemplate template;
> private CamelContextResource contextResource;
>
> public CamelChildResourceSupport(CamelContextResource contextResource) {
> this.contextResource = contextResource;
> camelContext = contextResource.getCamelContext();
> template = contextResource.getTemplate();
> }
>
> public CamelContext getCamelContext() {
> return camelContext;
> }
>
> public ProducerTemplate getTemplate() {
> return template;
> }
>
> public CamelContextResource getContextResource() {
> return contextResource;
> }
>
> public DefaultTypeConverter getDefaultTypeConverter() {
> TypeConverterRegistry converterRegistry =
> getCamelContext().getTypeConverterRegistry();
> if (converterRegistry instanceof DefaultTypeConverter) {
> return (DefaultTypeConverter) converterRegistry;
> } else {
> LOG.info("Not a default type converter as it is: " +
> converterRegistry);
> }
> return null;
> }
> }
>
>
>
> Regards,
>
> Charles
> --
> View this message in context: http://n2.nabble.com/A-message-body-writer-for-Java-type-class-org-apache-camel-model-RouteDefinition-and-MIME-media-typed-tp4399047p4399047.html
> Sent from the Jersey mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>

-- 
http://blogs.sun.com/japod