Expand my Community achievements bar.

SOLVED

*ERROR* [OsgiInstallerImpl] Cannot register Component (java.lang.IllegalStateException: Invalid BundleContext.)

Avatar

Former Community Member

Hello experts,

The following error occur transiently while I start up my AEM author instance (or when I rebuild and reinstall my bundles):

21.07.2014 13:14:31.849 *INFO* [OsgiInstallerImpl] org.apache.sling.audit.osgi.installer Updated bundle com.tcm.core-bundle [324] from resource TaskResource(url=jcrinstall:/apps/training/install/core-bundle-1.0-SNAPSHOT.jar, entity=bundle:com.tcm.core-bundle, state=INSTALL, attributes=[org.apache.sling.installer.api.tasks.ResourceTransformer=:77:16:, Bundle-SymbolicName=com.tcm.core-bundle, Bundle-Version=1.0.0.SNAPSHOT], digest=1405962870933)
21.07.2014 13:14:31.849 *INFO* [OsgiInstallerImpl] org.apache.sling.audit.osgi.installer Refreshing 1 bundles: [com.tcm.core-bundle [324]]
21.07.2014 13:14:31.849 *INFO* [OsgiInstallerImpl] org.apache.sling.audit.osgi.installer Waiting up to 90 seconds for bundles refresh
21.07.2014 13:14:31.858 *INFO* [FelixDispatchQueue] org.apache.felix.framework FrameworkEvent PACKAGES REFRESHED
21.07.2014 13:14:31.860 *INFO* [OsgiInstallerImpl] org.apache.sling.audit.osgi.installer Done refreshing 1 bundles
21.07.2014 13:14:31.861 *INFO* [FelixDispatchQueue] org.apache.felix.framework FrameworkEvent PACKAGES REFRESHED
21.07.2014 13:14:31.864 *INFO* [OsgiInstallerImpl] com.tcm.core-bundle BundleEvent RESOLVED
21.07.2014 13:14:31.864 *INFO* [OsgiInstallerImpl] com.tcm.core-bundle BundleEvent STARTING

21.07.2014 13:14:31.873 *ERROR* [OsgiInstallerImpl] com.tcm.core-bundle [com.tcm.core.servlets.SearchServlet] Cannot register Component (java.lang.IllegalStateException: Invalid BundleContext.) java.lang.IllegalStateException: Invalid BundleContext.
    at org.apache.felix.framework.BundleContextImpl.checkValidity(BundleContextImpl.java:514)
    at org.apache.felix.framework.BundleContextImpl.getBundle(BundleContextImpl.java:112)
    at org.apache.felix.scr.impl.ComponentRegistry.checkComponentName(ComponentRegistry.java:355)
    at org.apache.felix.scr.impl.BundleComponentActivator.loadDescriptor(BundleComponentActivator.java:240)
    at org.apache.felix.scr.impl.BundleComponentActivator.initialize(BundleComponentActivator.java:149)
    at org.apache.felix.scr.impl.BundleComponentActivator.<init>(BundleComponentActivator.java:113)
    at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:261)
    at org.apache.felix.scr.impl.Activator.bundleChanged(Activator.java:179)
    at org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:868)
    at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:789)
    at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:514)
    at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4385)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2080)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
    at org.apache.sling.installer.core.impl.tasks.BundleStartTask.execute(BundleStartTask.java:93)
    at org.apache.sling.installer.core.impl.OsgiInstallerImpl.executeTasks(OsgiInstallerImpl.java:733)
    at org.apache.sling.installer.core.impl.OsgiInstallerImpl.run(OsgiInstallerImpl.java:247)
    at java.lang.Thread.run(Unknown Source)
21.07.2014 13:14:31.873 *INFO* [OsgiInstallerImpl] com.tcm.core-bundle BundleEvent STARTED
21.07.2014 13:14:31.873 *INFO* [OsgiInstallerImpl] org.apache.sling.audit.osgi.installer Started bundle com.tcm.core-bundle [324]

The problem looks "global" in nature since the same stacktrace is across multiple components of the same bundle:

21.07.2014 13:14:31.870 *ERROR* [OsgiInstallerImpl] com.tcm.core-bundle [com.tcm.core.ReplicationLogger] Cannot register Component (java.lang.IllegalStateException: Invalid BundleContext.) java.lang.IllegalStateException: Invalid BundleContext.

21.07.2014 13:14:31.870 *ERROR* [OsgiInstallerImpl] com.tcm.core-bundle [com.tcm.core.StockDataImporter] Cannot register Component (java.lang.IllegalStateException: Invalid BundleContext.) java.lang.IllegalStateException: Invalid BundleContext.

21.07.2014 13:14:31.870 *ERROR* [OsgiInstallerImpl] com.tcm.core-bundle [com.tcm.core.components.ModifyPermissions] Cannot register Component (java.lang.IllegalStateException: Invalid BundleContext.) java.lang.IllegalStateException: Invalid BundleContext.

21.07.2014 13:14:31.870 *ERROR* [OsgiInstallerImpl] com.tcm.core-bundle [com.tcm.core.components.StockAlertProcess] Cannot register Component (java.lang.IllegalStateException: Invalid BundleContext.) java.lang.IllegalStateException: Invalid BundleContext.

 

I am still able to see my bundle under:

http://localhost:4502/system/console/bundles

I am an AEM newbie.  Your help on the cause and resolution of the error above is much appreciated.

1 Accepted Solution

Avatar

Correct answer by
Level 10

To find parallel thread need numerous log entry just sharing leading up to the error might not help. File a daycare for further assistance. 

View solution in original post

5 Replies

Avatar

Level 10

Is the status of the component is 'Active' ?? 

Avatar

Level 10

From your description assuming it is interment & does not affect any functionality.

The error indicates there is another process in the middle of using the BundleContext and other thread trying to stops the bundle, hence the BundleContext will become invalid. Complete logs could give better picture or you can find yourself by analyzing what is happening in parallel. 

BTB which aem version you are using?  Because "Cannot register Component" should provide complete strack trace OR did you truncated?

Avatar

Former Community Member

I am running AEM 5.6.1

Since some of the components are active and some other are registered, I am not sure if component status = active is the issue (it seems like the root problem occurred before the components are loaded by OSGi).

active:
com.tcm.core.ReplicationLogger
com.tcm.core.components.ModifyPermissions

registered:
com.tcm.core.StockDataImporter
com.tcm.core.servlets.SearchServlet
com.tcm.core.components.StockAlertProcess

My only     @Reference are out of the box sling components as per below, which I confirmed showed correctly from the system console.

    @Reference
    private SlingRepository repo;

http://localhost:4502/system/console/bundles/324
Imported Packages
org.apache.sling.jcr.api,version=2.1.0 from org.apache.sling.jcr.api (74)

http://localhost:4502/system/console/services/141
org.apache.sling.jcr.api.SlingRepository]


    @Reference
    private Scheduler scheduler;

http://localhost:4502/system/console/services/132
org.apache.sling.commons.scheduler,version=2.2.0 from org.apache.sling.commons.scheduler (132)

 

I might have Intellij IDEA open with a Maven bundle build (not running when AEM started up); other than that I do not have any AEM bundle related applications running.

The log entries are numerous; but I have included the log entries leading up to the error.

21.07.2014 09:37:43.354 *INFO* [OsgiInstallerImpl] org.apache.sling.servlets.resolver.internal.resource.ServletResourceProviderFactory create(2585): ServiceReference has no registration settings, ignoring
21.07.2014 09:37:43.354 *INFO* [OsgiInstallerImpl] org.apache.felix.inventory Service [2584] ServiceEvent REGISTERED
21.07.2014 09:37:43.355 *INFO* [OsgiInstallerImpl] org.apache.sling.scripting.jsp Service [2583] ServiceEvent REGISTERED
21.07.2014 09:37:43.355 *INFO* [OsgiInstallerImpl] org.apache.sling.scripting.jsp Service [JSP Script Modification Handler,2586] ServiceEvent REGISTERED
21.07.2014 09:37:43.356 *INFO* [OsgiInstallerImpl] org.apache.sling.scripting.core.impl.ScriptEngineManagerFactory Adding ScriptEngine Apache Sling JST script engine (Sling JavaScript Templates), 1.0 for language JavaScript Templates, 1.0
21.07.2014 09:37:43.356 *INFO* [OsgiInstallerImpl] org.apache.sling.scripting.core.impl.ScriptEngineManagerFactory Adding ScriptEngine Apache Sling Scripting JavaScript Support (Rhino 1.6 release 6 2007 07 26), 2.0.12 for language ECMAScript, 0
21.07.2014 09:37:43.356 *INFO* [OsgiInstallerImpl] org.apache.sling.scripting.core.impl.ScriptEngineManagerFactory Adding ScriptEngine Apache Sling Scripting Java Support, 2.0.6 for language Java Servlet Compiler, 1.5
21.07.2014 09:37:43.356 *INFO* [OsgiInstallerImpl] org.apache.sling.scripting.core.impl.ScriptEngineManagerFactory Adding ScriptEngine Apache Sling Scripting JSP Support, 2.0.28 for language Java Server Pages, 2.1
21.07.2014 09:37:43.356 *INFO* [OsgiInstallerImpl] org.apache.sling.scripting.core.impl.ScriptEngineManagerFactory Script extension 'ecma' is now handled by ScriptEngine 'Apache Sling Scripting JavaScript Support (Rhino 1.6 release 6 2007 07 26)', version='2.0.12', class='org.apache.sling.scripting.javascript.internal.RhinoJavaScriptEngine'
21.07.2014 09:37:43.357 *INFO* [OsgiInstallerImpl] org.apache.sling.scripting.core.impl.ScriptEngineManagerFactory Script extension 'esp' is now handled by ScriptEngine 'Apache Sling Scripting JavaScript Support (Rhino 1.6 release 6 2007 07 26)', version='2.0.12', class='org.apache.sling.scripting.javascript.internal.RhinoJavaScriptEngine'
21.07.2014 09:37:43.357 *INFO* [OsgiInstallerImpl] org.apache.sling.scripting.core.impl.ScriptEngineManagerFactory Script extension 'java' is now handled by ScriptEngine 'Apache Sling Scripting Java Support', version='2.0.6', class='org.apache.sling.scripting.java.impl.JavaScriptEngineFactory$JavaScriptEngine'
21.07.2014 09:37:43.357 *INFO* [OsgiInstallerImpl] org.apache.sling.scripting.core.impl.ScriptEngineManagerFactory Script extension 'jsp' is now handled by ScriptEngine 'Apache Sling Scripting JSP Support', version='2.0.28', class='org.apache.sling.scripting.jsp.JspScriptEngineFactory$JspScriptEngine'
21.07.2014 09:37:43.357 *INFO* [OsgiInstallerImpl] org.apache.sling.scripting.core.impl.ScriptEngineManagerFactory Script extension 'jspf' is now handled by ScriptEngine 'Apache Sling Scripting JSP Support', version='2.0.28', class='org.apache.sling.scripting.jsp.JspScriptEngineFactory$JspScriptEngine'
21.07.2014 09:37:43.357 *INFO* [OsgiInstallerImpl] org.apache.sling.scripting.core.impl.ScriptEngineManagerFactory Script extension 'jspx' is now handled by ScriptEngine 'Apache Sling Scripting JSP Support', version='2.0.28', class='org.apache.sling.scripting.jsp.JspScriptEngineFactory$JspScriptEngine'
21.07.2014 09:37:43.357 *INFO* [OsgiInstallerImpl] org.apache.sling.scripting.core.impl.ScriptEngineManagerFactory Script extension 'jst' is now handled by ScriptEngine 'Apache Sling JST script engine (Sling JavaScript Templates)', version='1.0', class='org.apache.sling.scripting.jst.JstScriptEngine'
21.07.2014 09:37:43.357 *INFO* [OsgiInstallerImpl] com.tcm.core-bundle BundleEvent UNRESOLVED
21.07.2014 09:37:43.357 *INFO* [OsgiInstallerImpl] com.tcm.core-bundle BundleEvent UPDATED
21.07.2014 09:37:43.386 *INFO* [FelixDispatchQueue] org.apache.felix.framework FrameworkEvent PACKAGES REFRESHED
21.07.2014 09:37:43.386 *INFO* [OsgiInstallerImpl] org.apache.sling.audit.osgi.installer Updated bundle com.tcm.core-bundle [324] from resource TaskResource(url=jcrinstall:/apps/training/install/core-bundle-1.0-SNAPSHOT.jar, entity=bundle:com.tcm.core-bundle, state=INSTALL, attributes=[org.apache.sling.installer.api.tasks.ResourceTransformer=:77:16:, Bundle-SymbolicName=com.tcm.core-bundle, Bundle-Version=1.0.0.SNAPSHOT], digest=1405949861300)
21.07.2014 09:37:43.479 *INFO* [OsgiInstallerImpl] org.apache.sling.audit.osgi.installer Refreshing 1 bundles: [com.tcm.core-bundle [324]]
21.07.2014 09:37:43.479 *INFO* [OsgiInstallerImpl] org.apache.sling.audit.osgi.installer Waiting up to 90 seconds for bundles refresh
21.07.2014 09:37:43.480 *INFO* [OsgiInstallerImpl] org.apache.sling.audit.osgi.installer Done refreshing 1 bundles
21.07.2014 09:37:43.481 *INFO* [FelixDispatchQueue] org.apache.felix.framework FrameworkEvent PACKAGES REFRESHED
21.07.2014 09:37:43.489 *INFO* [OsgiInstallerImpl] com.tcm.core-bundle BundleEvent RESOLVED
21.07.2014 09:37:43.495 *INFO* [OsgiInstallerImpl] com.tcm.core-bundle BundleEvent STARTING
21.07.2014 09:37:43.495 *INFO* [OsgiInstallerImpl] com.tcm.core-bundle BundleEvent STARTED


21.07.2014 09:37:43.498 *ERROR* [OsgiInstallerImpl] com.tcm.core-bundle [com.tcm.core.ReplicationLogger] Cannot register Component (java.lang.IllegalStateException: Invalid BundleContext.) java.lang.IllegalStateException: Invalid BundleContext.
    at org.apache.felix.framework.BundleContextImpl.checkValidity(BundleContextImpl.java:514)
    at org.apache.felix.framework.BundleContextImpl.getBundle(BundleContextImpl.java:112)
    at org.apache.felix.scr.impl.ComponentRegistry.checkComponentName(ComponentRegistry.java:355)
    at org.apache.felix.scr.impl.BundleComponentActivator.loadDescriptor(BundleComponentActivator.java:240)
    at org.apache.felix.scr.impl.BundleComponentActivator.initialize(BundleComponentActivator.java:149)
    at org.apache.felix.scr.impl.BundleComponentActivator.<init>(BundleComponentActivator.java:113)
    at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:261)
    at org.apache.felix.scr.impl.Activator.bundleChanged(Activator.java:179)
    at org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:868)
    at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:789)
    at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:514)
    at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4385)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2080)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
    at org.apache.sling.installer.core.impl.tasks.BundleStartTask.execute(BundleStartTask.java:93)
    at org.apache.sling.installer.core.impl.OsgiInstallerImpl.executeTasks(OsgiInstallerImpl.java:733)
    at org.apache.sling.installer.core.impl.OsgiInstallerImpl.run(OsgiInstallerImpl.java:247)
    at java.lang.Thread.run(Unknown Source)

Avatar

Level 10

also, what is the status of all the @reference services you have used in your servlet 

Avatar

Correct answer by
Level 10

To find parallel thread need numerous log entry just sharing leading up to the error might not help. File a daycare for further assistance.