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 | Community
Skip to main content
New Participant
December 12, 2023

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

  • December 12, 2023
  • 2 replies
  • 1459 views

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)

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

kautuk_sahni
Employee
January 2, 2024

@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
Sudheer_Sundalam
New Participant
December 12, 2023

@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.

shivamraAuthor
New Participant
December 13, 2023

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.

aanchal-sikka
New Participant
December 13, 2023

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