Shriram
Shriram

Reputation: 4411

OSGi Component factory Objects are created twice though karaf instance is killed

I am using OSGi component factory concept in my project which works as expected. Please find the steps I've done.

Steps:

  1. Login into karaf using ssh command[since it is not a root user so I have created an instance in karaf].

  2. Executed scr:list. It displays the services which I have deployed. Since I have used component factories objects are created by OSGi framework and works as expected.

  3. Shutdown the karaf using "shutdown" command.
  4. Login again into karaf using ssh command.
  5. After executing scr:list the objects are duplicated. i.e. objects are creating one more time and it displays twice.

While shutdown karaf is stopped, deactivate method is getting called and the corresponding java process is getting killed. A new process is getting created once I starts karaf process again[I have verified the same by checking the PID of the java process]. I have raise this question for the below reasons

  1. Since I am using component factories memory management should be automatically handled. i.e) If I shutsdown the karaf instance objects should be deallocated and gets garbage collected.
  2. Though my application is poorly designed, after shutting down the java process scr:list should not display the objects twice. i.e) After java process is down the corresponding memory should be cleared. Eventually It should not affect newly created process.

Environment: RHEL 6.5

Apache-karaf : 3.0.3

JRE : 1.7-u 79

Upvotes: 1

Views: 280

Answers (1)

Christian Schneider
Christian Schneider

Reputation: 19606

It might be a known bug. I assume you are creating a default config using a feature file? This seems to be broken in current karaf versions for managed service factories. So if this is the case then avoid to define a default config in the feature file.

Upvotes: 1

Related Questions