Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

Cannot register component (org.osgi.service.component.ComponentException: The component name 'com.products.servlets.DataImportServlet' has already been registered by Bundle 622 (product-importer) as Component of Class com.products.servlet

Avatar

Level 2

Hi all,

I am seeing the below warning coming in my error log.  I have two packages in my AEM project one is aem.core and another one is aem.product-importer. Can anyone tell why Bundle for second package is giving error which is given below:

12.12.2023 11:11:43.861 *ERROR* [OsgiInstallerImpl] aem.product-importer bundle aem.product-importer:1.0.0.SNAPSHOT (622)[com.aem.products.servlets.DataImportServlet] : Cannot register component (org.osgi.service.component.ComponentException: The component name 'com.mchp.products.servlets.DataImportServlet' has already been registered by Bundle 622 (aem.product-importer) as Component of Class com.aem.products.servlets.DataImportServlet)
org.osgi.service.component.ComponentException: The component name 'com.aem.products.servlets.DataImportServlet' has already been registered by Bundle 622 (aem.product-importer) as Component of Class com.aem.products.servlets.DataImportServlet
at org.apache.felix.scr.impl.ComponentRegistry.checkComponentName(ComponentRegistry.java:240) [org.apache.felix.scr:2.1.20]
at org.apache.felix.scr.impl.BundleComponentActivator.validateAndRegister(BundleComponentActivator.java:489) [org.apache.felix.scr:2.1.20]
at org.apache.felix.scr.impl.BundleComponentActivator.loadDescriptor(BundleComponentActivator.java:450) [org.apache.felix.scr:2.1.20]
at org.apache.felix.scr.impl.BundleComponentActivator.initialize(BundleComponentActivator.java:328) [org.apache.felix.scr:2.1.20]
at org.apache.felix.scr.impl.BundleComponentActivator.<init>(BundleComponentActivator.java:263) [org.apache.felix.scr:2.1.20]
at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:551) [org.apache.felix.scr:2.1.20]
at org.apache.felix.scr.impl.Activator.access$200(Activator.java:69) [org.apache.felix.scr:2.1.20]
at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:424) [org.apache.felix.scr:2.1.20]
at org.apache.felix.scr.impl.AbstractExtender.createExtension(AbstractExtender.java:196) [org.apache.felix.scr:2.1.20]
at org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:169) [org.apache.felix.scr:2.1.20]
at org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:49) [org.apache.felix.scr:2.1.20]
at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:488)
at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:420)
at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232)
at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:450)
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:4817)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2336)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:984)
at org.apache.sling.installer.core.impl.tasks.BundleStartTask.execute(BundleStartTask.java:97) [org.apache.sling.installer.core:3.9.0.B002]
at org.apache.sling.installer.core.impl.OsgiInstallerImpl.doExecuteTasks(OsgiInstallerImpl.java:914) [org.apache.sling.installer.core:3.9.0.B002]
at org.apache.sling.installer.core.impl.OsgiInstallerImpl.executeTasks(OsgiInstallerImpl.java:749) [org.apache.sling.installer.core:3.9.0.B002]
at org.apache.sling.installer.core.impl.OsgiInstallerImpl.run(OsgiInstallerImpl.java:298) [org.apache.sling.installer.core:3.9.0.B002]
at java.base/java.lang.Thread.run(Thread.java:834)

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

5 Replies

Avatar

Community Advisor

@shivamra ,

Check if you have this class com.aem.products.servlets.DataImportServlet in both the bundles. If possible, delete this class from one of the bundles and try the build again.

Avatar

Level 2

Hi @Sudheer_Sundalam All servlets related to second bundles are unique. The reason that I created the two packages is that the first one is main package and second one is used in other application and if i place all servlets of one package into another then it will increase size of package. That's why the project has two packages.

Avatar

Community Advisor

Hello @shivamra 

 

If you have 2 bundles the packages names should also be different. It helps you easily map classes to bundles, by just looking at the package statement.

 

  • Does Bundle-2 have any dependency on Bundle-1?
  • Why do you need the servlet to have same fully-qualified name in 2 different bundles? 

 


Aanchal Sikka

Avatar

Level 2

Hi @aanchal-sikka The bundle 2 has no dependency on bundle 1 we have just included bundle 2  as it is used in different application. I have checked both bundles and all servlets mentioned in the error are unique and used only in bundle 2 only. Maybe the servlets is registered two times due to problem of parallel threads or something.

Avatar

Administrator

@shivamra Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Kautuk Sahni