users@jersey.java.net

Classloader problem with Felix/Jetty

From: Jörg Richter <jri_at_deepamehta.de>
Date: Sat, 22 May 2010 04:20:23 +0200

Hi,

there is a problem runnig Jersey with Felix/Jetty:

        org.osgi.framework.BundleException: Activator start error in bundle ...
                at org.apache.felix.framework.Felix.activateBundle(Felix.java:1807)
        ...
        Caused by: java.lang.ExceptionInInitializerError
                at com.sun.jersey.core.spi.factory.MessageBodyFactory.initReaders(MessageBodyFactory.java:157)
        ...
        Caused by: java.lang.NullPointerException
                at javax.ws.rs.core.MediaType.valueOf(MediaType.java:119)
                at com.sun.jersey.core.header.MediaTypes.<clinit>(MediaTypes.java:58)

MediaTypes.java line 58 is:

        public final static MediaType WADL = MediaType.valueOf("application/vnd.sun.wadl+xml");

So, apparently the reader for mimetype application/vnd.sun.wadl+xml is missing.
This is possibly because all the provider classes from com.sun.jersey.core.impl.provider.header are not loaded, as suggested by a bunch of preceding warnings. In particular:

        WARNING: The class com.sun.jersey.core.impl.provider.header.MediaTypeProvider implementing the provider interface com.sun.jersey.spi.HeaderDelegateProvider is not found. The provider implementation is ignored.

So, this seems to be a classloader problem in conjunction with Felix.

The software environment is up-to-date:
        - Felix 2.0.5
        - Bundle "Apache Felix Http Jetty" 2.0.4, which embeds Jetty 6.1.21
        - Jersey 1.3-SNAPSHOT (May 21)
With Jersey 1.2 the same problem occurs.

I would love to run Jersey in Felix/Jetty!

Cheers,
Jörg Richter