ServiceA in BundleA injected into ServiceB in BundleB | Community
Skip to main content
levif78323183
Level 2
December 2, 2015
Solved

ServiceA in BundleA injected into ServiceB in BundleB

  • December 2, 2015
  • 4 replies
  • 2156 views

Hi,

I got 2 bundles in my project. BundleA and BundleB.

BundleA has a ServiceA (annotated with @Service and @Component) that I want to inject (@Reference) into ServiceB which is in BundleB.

I'm not able to do so. My BundleB appears as Active in the console but it doesn't work.

Can someone shed some light?

Thank you very much.

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

Have you looked not just at the bundles but also the services? Check the following:

  • Is bundle A active
  • Go to services console - check to see if Service A is active and running
  • Go to the services console - check to see if Service B is active? If it isn't why - are there unfilled dependencies? 
  • Try to activate the service then check error.log for message details.

Some potential reasons why you might be having trouble:

  • Service A's package isn't exported by bundle A (verify this in Felix in the package info screen) - this usually an error in your POM file. 
  • Service A's package isn't being imported by bundle B (verify this in Felix in the package info screen) - this is usually an error in your POM file. 
  • Service A is failing to start for some reason - unfulfilled dependencies, fatal errors in the activation method, many possibilities. In the list of steps above if service A isn't running try starting it in the services console and checking error.log after you start it for errors if it fails to start. 
  • Service B is failing to start for some reason unrelated to Service A - again watch error.log after you try to start it manually in Felix for error messages. 

4 replies

smacdonald2008
Level 10
December 2, 2015

See this Stack overflow thread

http://stackoverflow.com/questions/22807377/adobe-cq-injecting-services-via-reference-returns-null

Using @Reference is the correct way if you are referencin a service.

Lokesh_Shivalingaiah
Level 10
December 2, 2015

Hi, 

You need to add the bundle A as a dependency in Bundle B and then use the @reference of service A

levif78323183
Level 2
December 2, 2015

You mean in the pom.xml file? Can you provide me an example?

Thank you for replying

PaulMcMahonAccepted solution
Level 8
December 2, 2015

Have you looked not just at the bundles but also the services? Check the following:

  • Is bundle A active
  • Go to services console - check to see if Service A is active and running
  • Go to the services console - check to see if Service B is active? If it isn't why - are there unfilled dependencies? 
  • Try to activate the service then check error.log for message details.

Some potential reasons why you might be having trouble:

  • Service A's package isn't exported by bundle A (verify this in Felix in the package info screen) - this usually an error in your POM file. 
  • Service A's package isn't being imported by bundle B (verify this in Felix in the package info screen) - this is usually an error in your POM file. 
  • Service A is failing to start for some reason - unfulfilled dependencies, fatal errors in the activation method, many possibilities. In the list of steps above if service A isn't running try starting it in the services console and checking error.log after you start it for errors if it fails to start. 
  • Service B is failing to start for some reason unrelated to Service A - again watch error.log after you try to start it manually in Felix for error messages.