Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

ServiceA in BundleA injected into ServiceB in BundleB

Avatar

Level 2

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.

1 Accepted Solution

Avatar

Correct answer by
Level 8

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. 

View solution in original post

4 Replies

Avatar

Level 10

Hi, 

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

Avatar

Level 2

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

Thank you for replying

Avatar

Correct answer by
Level 8

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.