Expand my Community achievements bar.

Moving Service from one bundle to another bundle breaks the service wiring

Avatar

Level 2
 
     

The issue comes when i move a service from one bundle to another new bundle

  • I moved one of the service from bundle aem-core-bundle to bundle aem-core-pim-connector.
  • And then i refer to that service i.e PIMService in a servlet in aem-core-bundle using scr annotation.
    • @Reference
  • This breaks the wiring of the service and the servlet path in which i am refering to PIMService is not visible to the component anymore.

The only error i see during the build is:

29.12.2015 11:41:53.345 ERROR [OsgiInstallerImpl] com.pearson.aem.aem-core-bundle [com.pearson.aem.aemcore.services.content.impl.ContentServicesServiceImpl(1944)] The deactivate method has thrown an exception (java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) previously initiated loading for a different type with name "javax/ws/rs/client/Client").

java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) previously initiated loading for a different type with name "javax/ws/rs/client/Client"

I have already added dependency for aem-core-pim-connector in aem-core-bundle and both the bundle starts up completely fine.

4 Replies

Avatar

Level 10

Have you changed the versions of both the bundles with this change ?? If not can you try with changing the versions of both the bundles 

Avatar

Employee Advisor

Hi,

you should check that the import statements of the bundle are changed and that the correct bundle providing these imports is bound. And as @bsloki already mentioned, make sure that the correct versions of the bundles are actually deployed.

kind regards,
Jörg

Avatar

Level 2

as it is a maven project, i have added the required dependency into the new POM for aem-core-pim-connector also the dependency is of the same version as in the previous bundle.

Also, I have checked the versions of POM are same for all the bundles associated with the project and is loading correctly.

Avatar

Level 9

Hi Tanuj,

Java.lang.LinkageError occurs when there is a problem in ClassLoading. Actually, this happens when same class is loaded by multiple class loader. As you know, in OSGI, Each bundle has their own class loader. 

Below post could guide you more on this. Also, check all your POM.xml and make sure, there are no circular dependencies between bundles.

http://stackoverflow.com/questions/244482/how-to-deal-with-linkageerrors-in-java

Jitendra

tanuj004 wrote...

as it is a maven project, i have added the required dependency into the new POM for aem-core-pim-connector also the dependency is of the same version as in the previous bundle.

Also, I have checked the versions of POM are same for all the bundles associated with the project and is loading correctly.