eclipse-ee4j / jersey

Eclipse Jersey Project - Read our Wiki:
https://github.com/eclipse-ee4j/jersey/wiki
Other
692 stars 355 forks source link

Application bundle built with maven-bundle-plugin 4.2.0 fails #4190

Open steinarb opened 5 years ago

steinarb commented 5 years ago

Short description: I have several webapplications consisting of OSGi bundles running in apache karaf, where the REST API is provided by jersey. In the REST API bundles I set the jersey servlet up as an OSGi Declarative Services (DS). The application works when being built with maven-bundle-plugin 3.5.1 but fails when being built with maven-bundle-plugin 4.2.0.

(The reason I'm trying to upgrade maven-bundle-plugin, is that I'm in the process to moving from openjdk-8 to openjdk-11. Note: this failure happens on openjdk-8, when I've built the bundles with maven-bundle-plugin 4.2.0)

Versions of the build and execution environment:

The failing code, is the code I'm using to add OSGi services injected into the Declarative Services components, to HK2, so that they can be injected into the Jersey resources: https://github.com/steinarb/authservice-sampleclient/blob/f37d46b2f3baca87763a0b78f5afa19add8b2828/src/main/java/no/priv/bang/authservice/sampleclient/AuthserviceSampleClientServlet.java#L67

The stack trace from the failed startup, is:

2019-07-05T18:38:22,098 | WARN  | features-3-thread-1 | sampleauthserviceclient          | 101 - org.eclipse.jetty.util - 9.4.18.v20190429 | unavailable
java.lang.NullPointerException: null
    at org.glassfish.hk2.utilities.ServiceLocatorUtilities.addClasses(ServiceLocatorUtilities.java:435) ~[?:?]
    at org.glassfish.hk2.utilities.ServiceLocatorUtilities.enablePerThreadScope(ServiceLocatorUtilities.java:107) ~[?:?]
    at org.glassfish.jersey.inject.hk2.AbstractHk2InjectionManager.createLocator(AbstractHk2InjectionManager.java:116) ~[?:?]
    at org.glassfish.jersey.inject.hk2.AbstractHk2InjectionManager.<init>(AbstractHk2InjectionManager.java:86) ~[?:?]
    at org.glassfish.jersey.inject.hk2.ImmediateHk2InjectionManager.<init>(ImmediateHk2InjectionManager.java:62) ~[?:?]
    at org.glassfish.jersey.inject.hk2.Hk2InjectionManagerFactory$Hk2InjectionManagerStrategy$1.createInjectionManager(Hk2InjectionManagerFactory.java:79) ~[?:?]
    at org.glassfish.jersey.inject.hk2.Hk2InjectionManagerFactory.create(Hk2InjectionManagerFactory.java:97) ~[?:?]
    at org.glassfish.jersey.internal.inject.Injections.createInjectionManager(Injections.java:93) ~[121:org.glassfish.jersey.core.jersey-common:2.27.0]
    at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:282) ~[122:org.glassfish.jersey.core.jersey-server:2.27.0]
    at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:335) ~[119:org.glassfish.jersey.containers.jersey-container-servlet-core:2.27.0]
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:178) ~[119:org.glassfish.jersey.containers.jersey-container-servlet-core:2.27.0]
    at no.priv.bang.authservice.sampleclient.AuthserviceSampleClientServlet.init(AuthserviceSampleClientServlet.java:69) ~[148:no.priv.bang.authservice.sampleclient:1.0.0.SNAPSHOT]
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:370) ~[119:org.glassfish.jersey.containers.jersey-container-servlet-core:2.27.0]
    at javax.servlet.GenericServlet.init(GenericServlet.java:244) ~[53:javax.servlet-api:3.1.0]
    at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:671) ~[99:org.eclipse.jetty.servlet:9.4.18.v20190429]
    at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:428) ~[99:org.eclipse.jetty.servlet:9.4.18.v20190429]
    at org.eclipse.jetty.servlet.ServletHandler.lambda$initialize$0(ServletHandler.java:750) ~[99:org.eclipse.jetty.servlet:9.4.18.v20190429]
    at java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:357) ~[?:?]
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485) ~[?:?]
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[?:?]
    at java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:312) ~[?:?]
    at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735) ~[?:?]
    at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734) ~[?:?]
    at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658) ~[?:?]
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:744) ~[99:org.eclipse.jetty.servlet:9.4.18.v20190429]
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:369) ~[99:org.eclipse.jetty.servlet:9.4.18.v20190429]
    at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.startContext(HttpServiceContext.java:391) ~[140:org.ops4j.pax.web.pax-web-jetty:7.2.10]
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:852) ~[98:org.eclipse.jetty.server:9.4.18.v20190429]
    at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:278) ~[99:org.eclipse.jetty.servlet:9.4.18.v20190429]
    at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doStart(HttpServiceContext.java:267) ~[140:org.ops4j.pax.web.pax-web-jetty:7.2.10]
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) ~[101:org.eclipse.jetty.util:9.4.18.v20190429]
    at org.ops4j.pax.web.service.jetty.internal.JettyServerImpl$1.start(JettyServerImpl.java:329) ~[140:org.ops4j.pax.web.pax-web-jetty:7.2.10]
    at org.ops4j.pax.web.service.internal.HttpServiceStarted.registerServlet(HttpServiceStarted.java:252) ~[?:?]
    at org.ops4j.pax.web.service.internal.HttpServiceStarted.registerServlet(HttpServiceStarted.java:392) ~[?:?]
    at org.ops4j.pax.web.service.internal.HttpServiceProxy.registerServlet(HttpServiceProxy.java:504) ~[?:?]
    at org.ops4j.pax.web.extender.whiteboard.internal.element.ServletWebElement.register(ServletWebElement.java:102) ~[?:?]
    at org.ops4j.pax.web.extender.whiteboard.internal.WebApplication.registerWebElement(WebApplication.java:392) ~[?:?]
    at org.ops4j.pax.web.extender.whiteboard.internal.WebApplication.registerWebElements(WebApplication.java:371) ~[?:?]
    at org.ops4j.pax.web.extender.whiteboard.internal.WebApplication.registerHttpContext(WebApplication.java:283) ~[?:?]
    at org.ops4j.pax.web.extender.whiteboard.internal.WebApplication.setServletContextHelper(WebApplication.java:429) ~[?:?]
    at org.ops4j.pax.web.extender.whiteboard.internal.tracker.ServletContextHelperTracker.addingService(ServletContextHelperTracker.java:173) ~[?:?]
    at org.ops4j.pax.web.extender.whiteboard.internal.tracker.ServletContextHelperTracker.addingService(ServletContextHelperTracker.java:49) ~[?:?]
    at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:941) ~[?:?]
    at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:870) ~[?:?]
    at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) ~[?:?]
    at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229) ~[?:?]
    at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:901) ~[?:?]
    at org.apache.felix.framework.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:990) ~[?:?]
    at org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:838) ~[?:?]
    at org.apache.felix.framework.EventDispatcher.fireServiceEvent(EventDispatcher.java:545) ~[?:?]
    at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4595) ~[?:?]
    at org.apache.felix.framework.Felix.registerService(Felix.java:3587) ~[?:?]
    at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:348) ~[?:?]
    at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:906) ~[?:?]
    at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:892) ~[?:?]
    at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:128) ~[?:?]
    at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:959) ~[?:?]
    at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:732) ~[?:?]
    at org.apache.felix.scr.impl.manager.AbstractComponentManager.enableInternal(AbstractComponentManager.java:666) ~[?:?]
    at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:432) ~[?:?]
    at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:665) ~[?:?]
    at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:338) ~[?:?]
    at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:382) ~[?:?]
    at org.apache.felix.scr.impl.Activator.access$200(Activator.java:49) ~[?:?]
    at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:264) ~[?:?]
    at org.apache.felix.scr.impl.AbstractExtender.createExtension(AbstractExtender.java:196) ~[?:?]
    at org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:169) ~[?:?]
    at org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:49) ~[?:?]
    at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:482) ~[?:?]
    at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:415) ~[?:?]
    at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232) ~[?:?]
    at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444) ~[?:?]
    at org.apache.felix.framework.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:915) ~[?:?]
    at org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:834) ~[?:?]
    at org.apache.felix.framework.EventDispatcher.fireBundleEvent(EventDispatcher.java:516) ~[?:?]
    at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4579) ~[?:?]
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2174) ~[?:?]
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998) ~[?:?]
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:984) ~[?:?]
    at org.apache.karaf.features.internal.service.BundleInstallSupportImpl.startBundle(BundleInstallSupportImpl.java:165) ~[?:?]
    at org.apache.karaf.features.internal.service.FeaturesServiceImpl.startBundle(FeaturesServiceImpl.java:1153) ~[?:?]
    at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:1036) ~[?:?]
    at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1062) ~[?:?]
    at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:998) ~[?:?]
    at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
    at java.lang.Thread.run(Thread.java:834) [?:?]
steinarb commented 5 years ago

Note: I'm able to debug the failing code using remote debug against apache karaf, so I can debug if someone can tell me what to look for.

steinarb commented 5 years ago

manifest.mf from bundle built with maven-bundle-plugin 3.5.1 (i.e. the bundle that works):

Manifest-Version: 1.0
Bnd-LastModified: 1562341632773
Build-Jdk: 1.8.0_212
Built-By: sb
Bundle-ManifestVersion: 2
Bundle-Name: Sample client for authservice
Bundle-SymbolicName: no.priv.bang.authservice.sampleclient
Bundle-Version: 1.0.0.SNAPSHOT
Created-By: Apache Maven Bundle Plugin
Export-Package: no.priv.bang.authservice.sampleclient.resources;uses:=
 "javax.ws.rs,javax.ws.rs.core,org.jsoup.nodes,org.osgi.service.log";v
 ersion="1.0.0",no.priv.bang.authservice.sampleclient;uses:="javax.ser
 vlet,org.apache.shiro.realm,org.apache.shiro.session.mgt.eis,org.apac
 he.shiro.web.servlet,org.glassfish.jersey.servlet,org.osgi.service.ht
 tp.context,org.osgi.service.log";version="1.0.0"
Import-Package: javax.inject;version="[1.0,2)",javax.servlet;version="
 [3.1,4)",javax.ws.rs;version="[2.1,3)",javax.ws.rs.core;version="[2.1
 ,3)",org.apache.shiro;version="[1.4,2)",org.apache.shiro.authc;versio
 n="[1.4,2)",org.apache.shiro.config;version="[1.4,2)",org.apache.shir
 o.realm;version="[1.4,2)",org.apache.shiro.session.mgt;version="[1.4,
 2)",org.apache.shiro.session.mgt.eis;version="[1.4,2)",org.apache.shi
 ro.subject;version="[1.4,2)",org.apache.shiro.web.config;version="[1.
 4,2)",org.apache.shiro.web.filter.authc;version="[1.4,2)",org.apache.
 shiro.web.filter.mgt;version="[1.4,2)",org.apache.shiro.web.mgt;versi
 on="[1.4,2)",org.apache.shiro.web.servlet;version="[1.4,2)",org.apach
 e.shiro.web.session.mgt;version="[1.4,2)",org.glassfish.jersey.intern
 al.inject;version="[2.27,3)",org.glassfish.jersey.server;version="[2.
 27,3)",org.glassfish.jersey.servlet;version="[2.27,3)",org.jsoup;vers
 ion="[1.11,2)",org.jsoup.nodes;version="[1.11,2)",org.jsoup.select;ve
 rsion="[1.11,2)",org.osgi.service.http.context;version="[1.0,2)",org.
 osgi.service.log;version="[1.3,2)"
Provide-Capability: osgi.service;objectClass:List<String>="javax.servl
 et.Filter",osgi.service;objectClass:List<String>="javax.servlet.Servl
 et",osgi.service;objectClass:List<String>="org.osgi.service.http.cont
 ext.ServletContextHelper"
Require-Capability: osgi.extender;filter:="(&(osgi.extender=osgi.compo
 nent)(version>=1.3.0)(!(version>=2.0.0)))",osgi.service;filter:="(obj
 ectClass=org.apache.shiro.realm.Realm)";effective:=active,osgi.servic
 e;filter:="(objectClass=org.apache.shiro.session.mgt.eis.SessionDAO)"
 ;effective:=active,osgi.service;filter:="(objectClass=org.osgi.servic
 e.log.LogService)";effective:=active,osgi.ee;filter:="(&(osgi.ee=Java
 SE)(version=1.8))"
Service-Component: OSGI-INF/no.priv.bang.authservice.sampleclient.Auth
 serviceSampleClientServlet.xml,OSGI-INF/no.priv.bang.authservice.samp
 leclient.AuthserviceSampleClientServletContextHelper.xml,OSGI-INF/no.
 priv.bang.authservice.sampleclient.AuthserviceSampleClientShiroFilter
 .xml
Tool: Bnd-3.5.0.201709291849
steinarb commented 5 years ago

manifest.mf from bundle built with maven-bundle-plugin 4.2.0 (i.e. the bundle that fails):

Manifest-Version: 1.0
Bnd-LastModified: 1562341874560
Build-Jdk: 1.8.0_212
Built-By: sb
Bundle-ManifestVersion: 2
Bundle-Name: Sample client for authservice
Bundle-SymbolicName: no.priv.bang.authservice.sampleclient
Bundle-Version: 1.0.0.SNAPSHOT
Created-By: Apache Maven Bundle Plugin
Export-Package: no.priv.bang.authservice.sampleclient.resources;uses:=
 "javax.ws.rs,javax.ws.rs.core,org.jsoup.nodes,org.osgi.service.log";v
 ersion="1.0.0",no.priv.bang.authservice.sampleclient;uses:="javax.ser
 vlet,org.apache.shiro.realm,org.apache.shiro.session.mgt.eis,org.apac
 he.shiro.web.servlet,org.glassfish.jersey.servlet,org.osgi.service.ht
 tp.context,org.osgi.service.log";version="1.0.0"
Import-Package: javax.inject,javax.servlet;version="[3.1,4)",javax.ws.
 rs;version="[2.1,3)",javax.ws.rs.core;version="[2.1,3)",no.priv.bang.
 authservice.sampleclient,org.apache.shiro;version="[1.4,2)",org.apach
 e.shiro.authc;version="[1.4,2)",org.apache.shiro.config;version="[1.4
 ,2)",org.apache.shiro.realm;version="[1.4,2)",org.apache.shiro.sessio
 n.mgt;version="[1.4,2)",org.apache.shiro.session.mgt.eis;version="[1.
 4,2)",org.apache.shiro.subject;version="[1.4,2)",org.apache.shiro.web
 .config;version="[1.4,2)",org.apache.shiro.web.filter.authc;version="
 [1.4,2)",org.apache.shiro.web.filter.mgt;version="[1.4,2)",org.apache
 .shiro.web.mgt;version="[1.4,2)",org.apache.shiro.web.servlet;version
 ="[1.4,2)",org.apache.shiro.web.session.mgt;version="[1.4,2)",org.gla
 ssfish.jersey.internal.inject;version="[2.27,3)",org.glassfish.jersey
 .server;version="[2.27,3)",org.glassfish.jersey.servlet;version="[2.2
 7,3)",org.jsoup;version="[1.11,2)",org.jsoup.nodes;version="[1.11,2)"
 ,org.jsoup.select;version="[1.11,2)",org.osgi.service.http.context;ve
 rsion="[1.0,2)",org.osgi.service.log;version="[1.3,2)"
Provide-Capability: osgi.service;objectClass:List<String>="javax.servl
 et.Filter",osgi.service;objectClass:List<String>="javax.servlet.Servl
 et",osgi.service;objectClass:List<String>="org.osgi.service.http.cont
 ext.ServletContextHelper"
Require-Capability: osgi.extender;filter:="(&(osgi.extender=osgi.compo
 nent)(version>=1.3.0)(!(version>=2.0.0)))",osgi.service;filter:="(obj
 ectClass=org.apache.shiro.realm.Realm)";effective:=active,osgi.servic
 e;filter:="(objectClass=org.apache.shiro.session.mgt.eis.SessionDAO)"
 ;effective:=active,osgi.service;filter:="(objectClass=org.osgi.servic
 e.log.LogService)";effective:=active,osgi.contract;osgi.contract=Java
 Inject;filter:="(&(osgi.contract=JavaInject)(version=1.0.0))",osgi.ee
 ;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Service-Component: OSGI-INF/no.priv.bang.authservice.sampleclient.Auth
 serviceSampleClientServlet.xml,OSGI-INF/no.priv.bang.authservice.samp
 leclient.AuthserviceSampleClientServletContextHelper.xml,OSGI-INF/no.
 priv.bang.authservice.sampleclient.AuthserviceSampleClientShiroFilter
 .xml
Tool: Bnd-4.2.0.201903051501