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 15:59:41 +0100

On Mon, Jan 18, 2010 at 05:00:48AM -0800, cmoulliard wrote:
>
> Hi Jacob,
>
> What do you mean by jersey-json module activated ? How can I check that
> jersey-json module is activated ?

I meant you could connect to the felix console and issue
the "find jersey" command to see the list of jersey modules together with their state.

Now, as you wrote privately, you bundle the jersey deps in the war
and set the bundle classpath to it and it works fine.

~Jakub

>
> Here is the list of providers retrieved in debug mode :
>
> writers ArrayList<E> (id=1365)
> elementData Object[16] (id=1368)
> [0] FormProvider (id=1369)
> [1] StringProvider (id=1370)
> [2] ByteArrayProvider (id=1371)
> [3] FileProvider (id=1372)
> [4] InputStreamProvider (id=1373)
> [5] DataSourceProvider (id=1374)
> [6] XMLJAXBElementProvider$General (id=1375)
> [7] ReaderProvider (id=1376)
> [8] DocumentProvider (id=1377)
> [9] StreamingOutputProvider (id=1378)
> [10] SourceProvider$SourceWriter (id=1379)
> [11] ViewableMessageBodyWriter (id=1380)
> [12] XMLRootElementProvider$General (id=1381)
> [13] XMLListElementProvider$General (id=1382)
> [14] null
> [15] null
>
> No Json providers are listed.
>
> Regards,
>
> Charles
>
> Jakub Podlesak wrote:
> >
> >
> > 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
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> > For additional commands, e-mail: users-help_at_jersey.dev.java.net
> >
> >
> >
>
> --
> 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-tp4399047p4413486.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