hstaudacher / osgi-jax-rs-connector

An OSGi - JAX-RS 2.0 Connector, software repository available on the link below
http://hstaudacher.github.io/osgi-jax-rs-connector
Other
191 stars 98 forks source link

NoClassDefFoundError: javax/annotation/Priority #77

Closed mhshams closed 9 years ago

mhshams commented 9 years ago

I am trying to follow the karaf example with the stable versions (released in maven central) of the artifacts, but keep getting following error.

(The "javax.annotation" is provided by other bundle in the container.)

2015-01-26 20:56:45,672 | WARN  | FelixStartLevel  | AbstractLifeCycle                | 46 - org.eclipse.jetty.aggregate.jetty-all-server - 8.1.15.v20140411 | FAILED org.ops4j.pax.web.service.spi.model.ServletModel-2: java.lang.NoClassDefFoundError: javax/annotation/Priority
java.lang.NoClassDefFoundError: javax/annotation/Priority
    at org.glassfish.jersey.model.internal.ComponentBag.modelFor(ComponentBag.java:483)
    at org.glassfish.jersey.model.internal.ComponentBag.access$100(ComponentBag.java:89)
    at org.glassfish.jersey.model.internal.ComponentBag$5.call(ComponentBag.java:408)
    at org.glassfish.jersey.model.internal.ComponentBag$5.call(ComponentBag.java:398)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)[75:com.eclipsesource.jaxrs.jersey-all:2.10.1]
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297)[75:com.eclipsesource.jaxrs.jersey-all:2.10.1]
    at org.glassfish.jersey.internal.Errors.process(Errors.java:228)[75:com.eclipsesource.jaxrs.jersey-all:2.10.1]
    at org.glassfish.jersey.model.internal.ComponentBag.registerModel(ComponentBag.java:398)
    at org.glassfish.jersey.model.internal.ComponentBag.register(ComponentBag.java:309)
    at org.glassfish.jersey.model.internal.CommonConfig.register(CommonConfig.java:463)
    at org.glassfish.jersey.server.ResourceConfig.register(ResourceConfig.java:448)[75:com.eclipsesource.jaxrs.jersey-all:2.10.1]
    at org.glassfish.jersey.server.ResourceConfig.registerInstances(ResourceConfig.java:545)[75:com.eclipsesource.jaxrs.jersey-all:2.10.1]
    at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig$3.run(ResourceConfig.java:1197)[75:com.eclipsesource.jaxrs.jersey-all:2.10.1]
    at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)[75:com.eclipsesource.jaxrs.jersey-all:2.10.1]
    at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)[75:com.eclipsesource.jaxrs.jersey-all:2.10.1]
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)[75:com.eclipsesource.jaxrs.jersey-all:2.10.1]
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297)[75:com.eclipsesource.jaxrs.jersey-all:2.10.1]
    at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286)[75:com.eclipsesource.jaxrs.jersey-all:2.10.1]
    at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.registerComponentsOf(ResourceConfig.java:1190)[75:com.eclipsesource.jaxrs.jersey-all:2.10.1]
    at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.<init>(ResourceConfig.java:1164)[75:com.eclipsesource.jaxrs.jersey-all:2.10.1]
    at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.<init>(ResourceConfig.java:1153)[75:com.eclipsesource.jaxrs.jersey-all:2.10.1]
    at org.glassfish.jersey.server.ResourceConfig.createRuntimeConfig(ResourceConfig.java:1149)[75:com.eclipsesource.jaxrs.jersey-all:2.10.1]
    at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:318)[75:com.eclipsesource.jaxrs.jersey-all:2.10.1]
    at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:285)[75:com.eclipsesource.jaxrs.jersey-all:2.10.1]
    at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:310)[75:com.eclipsesource.jaxrs.jersey-all:2.10.1]
    at org.glassfish.

any idea how to solve this issue?

maggu2810 commented 9 years ago

I test other bundles and get the same error.

e.g.

2015-01-27 15:54:26,844 | ERROR | jaxrs.connector) | configadmin                      | 4 - org.apache.felix.configadmin - 1.8.0 | [org.osgi.service.cm.ManagedService, id=99, bundle=52/file:base/repo/oh2/com.eclipsesource.jaxrs.publisher_4.1.0.201407131319.jar]: Unexpected problem updating configuration com.eclipsesource.jaxrs.connector
java.lang.NoClassDefFoundError: javax/annotation/Priority
        at org.glassfish.jersey.model.internal.ComponentBag.modelFor(ComponentBag.java:483)
        at org.glassfish.jersey.model.internal.ComponentBag.access$100(ComponentBag.java:89)
        at org.glassfish.jersey.model.internal.ComponentBag$5.call(ComponentBag.java:408)
        at org.glassfish.jersey.model.internal.ComponentBag$5.call(ComponentBag.java:398)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
        at org.glassfish.jersey.model.internal.ComponentBag.registerModel(ComponentBag.java:398)
        at org.glassfish.jersey.model.internal.ComponentBag.register(ComponentBag.java:309)
        at org.glassfish.jersey.model.internal.CommonConfig.register(CommonConfig.java:463)
        at org.glassfish.jersey.server.ResourceConfig.register(ResourceConfig.java:448)
        at org.glassfish.jersey.server.ResourceConfig.registerInstances(ResourceConfig.java:545)
        at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig$3.run(ResourceConfig.java:1197)
        at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)
        at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
        at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286)
        at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.registerComponentsOf(ResourceConfig.java:1190)
        at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.(ResourceConfig.java:1164)
        at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.(ResourceConfig.java:1153)
        at org.glassfish.jersey.server.ResourceConfig.createRuntimeConfig(ResourceConfig.java:1149)
        at org.glassfish.jersey.server.ApplicationHandler.(ApplicationHandler.java:318)
        at org.glassfish.jersey.server.ApplicationHandler.(ApplicationHandler.java:285)
        at org.glassfish.jersey.servlet.WebComponent.(WebComponent.java:310)
        at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
        at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358)
        at javax.servlet.GenericServlet.init(GenericServlet.java:244)
        at org.eclipse.equinox.http.servlet.internal.ServletRegistration.init(ServletRegistration.java:49)
        at org.eclipse.equinox.http.servlet.internal.ProxyServlet.registerServlet(ProxyServlet.java:184)
        at org.eclipse.equinox.http.servlet.internal.HttpServiceImpl.registerServlet(HttpServiceImpl.java:66)
        at com.eclipsesource.jaxrs.publisher.internal.JerseyContext.registerServlet(JerseyContext.java:111)
        at com.eclipsesource.jaxrs.publisher.internal.JerseyContext.registerApplication(JerseyContext.java:89)
        at com.eclipsesource.jaxrs.publisher.internal.JerseyContext.registerServletWhenNotAlreadyRegistered(JerseyContext.java:81)
        at com.eclipsesource.jaxrs.publisher.internal.JerseyContext.addResource(JerseyContext.java:66)
        at com.eclipsesource.jaxrs.publisher.internal.JAXRSConnector.registerResource(JAXRSConnector.java:140)
        at com.eclipsesource.jaxrs.publisher.internal.JAXRSConnector.registerResource(JAXRSConnector.java:122)
        at com.eclipsesource.jaxrs.publisher.internal.JAXRSConnector.clearCache(JAXRSConnector.java:83)
        at com.eclipsesource.jaxrs.publisher.internal.JAXRSConnector.doAddHttpService(JAXRSConnector.java:75)
        at com.eclipsesource.jaxrs.publisher.internal.JAXRSConnector.doUpdateConfiguration(JAXRSConnector.java:61)
        at com.eclipsesource.jaxrs.publisher.internal.JAXRSConnector.updateConfiguration(JAXRSConnector.java:51)
        at com.eclipsesource.jaxrs.publisher.internal.Configuration.updated(Configuration.java:31)
        at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:148)[4:org.apache.felix.configadmin:1.8.0]
        at org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:81)[4:org.apache.felix.configadmin:1.8.0]
        at org.apache.felix.cm.impl.ConfigurationManager$UpdateConfiguration.run(ConfigurationManager.java:1744)[4:org.apache.felix.configadmin:1.8.0]
        at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:103)[4:org.apache.felix.configadmin:1.8.0]
        at java.lang.Thread.run(Thread.java:745)[:1.8.0_25]
 52 | Active |  60 | 2.10.1.SR1             | com.eclipsesource.jaxrs.jersey-all
 53 | Active |  60 | 2.0.0.201407131319     | com.eclipsesource.jaxrs.provider.gson
 54 | Active |  60 | 4.1.0.201407131319     | com.eclipsesource.jaxrs.publisher
mhshams commented 9 years ago

@maggu2810 you fixed by adding import package to which bundle?

maggu2810 commented 9 years ago

I thought it would be solved, but it wasn't.

hstaudacher commented 9 years ago

I'm do not know well the the karaf integration but maybe you need the javax.annotation bundle started?

maggu2810 commented 9 years ago

Your bundle com.eclipsesource.jaxrs.jersey-all exports javax.annotation and is active... com.eclipsesource.jaxrs.publisher does not import javax.annotation, is this correct?

hstaudacher commented 9 years ago

yes I know. And it works well with Equinox. Bu just to let you know, the com.eclipsesource.jaxrs.jersey-all bundle isa convenient bundle. The only thing the jax-rs connector needs are some package exported by Jersey. I was sick adding all 15 bundles or so and decided to provide the all bundle. But maybe you need to add the jersey bundles directly from maven central instead of using the all bundle.

As I said, the all bundle is just are packaging of the jersey bundles.

maggu2810 commented 9 years ago

Do not know why this is working using equinox, perhaps this is relevant: https://wiki.eclipse.org/index.php/Equinox_Boot_Delegation

Will try to use the jersey bundles directly and report the results.

hstaudacher commented 9 years ago

There is also a maven build to create the all-bundle: https://github.com/hstaudacher/osgi-jax-rs-connector/tree/master/build/com.eclipsesource.jaxrs.jersey.all

Maybe you have a better idea how to create it... the current status is the first iteration, so it's far from perfect ;)

mhshams commented 9 years ago

@hstaudacher looking at pom file, I think the problem is that your are not importing "javax.annotation".

javax.annoation is provided by other bundles and jersey is a consumer only. so I believe it should import the package.

I will try to update the pom and build it locally, to see if can solve the issue.

maggu2810 commented 9 years ago

https://issues.apache.org/jira/browse/KARAF-2660

maggu2810 commented 9 years ago

There was no class definition: java.lang.NoClassDefFoundError: javax/annotation/Priority

So, uncommenct the stuff in the jre.properties of karaf is enough.

My errors are gone.

mhshams commented 9 years ago

@maggu2810 thanks for the info. Updating jre.properties solved my issue two. I am using jre-8, so in jre-8 segment, updated the javax.annotation version to 1.1 (was 1.2) solved the issue.