I use jetty 9.3.11.v20160721 , pax-cdi 1.0.0.RC1, pax-web 4.2.7 and weld
2.2.11.Final. The problem appears when I stop bundle.
This is the exception I get:
ERROR: Bundle com.example.site.fend [63] EventDispatcher: Error during
dispatch. (java.lang.IllegalStateException: Invalid BundleContext.)
java.lang.IllegalStateException: Invalid BundleContext.
at
org.apache.felix.framework.BundleContextImpl.checkValidity(BundleContextImpl.java:511)
at
org.apache.felix.framework.BundleContextImpl.getBundle(BundleContextImpl.java:114)
at
org.ops4j.pax.cdi.extension.impl.compat.Osgi6ServiceObjectsWrapper.init(Osgi6ServiceObjectsWrapper.java:56)
at
org.ops4j.pax.cdi.extension.impl.compat.OsgiScopeUtils.createServiceObjectsWrapper(OsgiScopeUtils.java:59)
at
org.ops4j.pax.cdi.extension.impl.ServiceEventBridge.serviceChanged(ServiceEventBridge.java:73)
at
org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:991)
at
org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:839)
at
org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:546)
at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4557)
at org.apache.felix.framework.Felix.access$000(Felix.java:106)
at org.apache.felix.framework.Felix$1.serviceChanged(Felix.java:420)
at
org.apache.felix.framework.ServiceRegistry.unregisterService(ServiceRegistry.java:170)
at
org.apache.felix.framework.ServiceRegistrationImpl.unregister(ServiceRegistrationImpl.java:144)
at
org.apache.felix.framework.ServiceRegistry.unregisterServices(ServiceRegistry.java:235)
at org.apache.felix.framework.Felix.stopBundle(Felix.java:2635)
at org.apache.felix.framework.BundleImpl.stop(BundleImpl.java:1038)
at org.apache.felix.framework.BundleImpl.stop(BundleImpl.java:1024)
I found out that the problem is in the process how services are
unregistered when bundle stops. When I call bundle.stop,the
following services are unregistered (in this order):
Reference:[org.ops4j.pax.cdi.spi.CdiContainer]
Implementation:org.ops4j.pax.cdi.weld.impl.WeldCdiContainer
Reference:[javax.enterprise.inject.spi.BeanManager]
Implementation:org.jboss.weld.manager.BeanManagerImpl
Reference:[org.ops4j.pax.web.service.WebAppDependencyHolder]
Implementation:org.ops4j.pax.cdi.web.impl.CdiWebAppDependencyHolder
AND AT THIS POINT BUNDLE IS STOPPED -> Activator.stop() ->
bundlecontext is invalidated and context from this point will throw
Invalid BundleContext
Now, [javax.servlet.ServletContext] will be unregistered -> I get this
exception.
I can't understand why bundle stops although not all listeners have got
events. If someone gives me a hint I could solve this problem and post the
solution.
--
--
------------------
OPS4J - http://www.ops4j.org - [email protected]
---
You received this message because you are subscribed to the Google Groups
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.