Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » How to start bundles in proper order
How to start bundles in proper order [message #929894] Mon, 01 October 2012 17:39 Go to next message
Mariusz Cwikla is currently offline Mariusz Cwikla
Messages: 15
Registered: January 2012
Junior Member
Hello,
I have an issue with starting equinox application from Eclipse IDE. I can't get bundles to start in proper order. It seems that this error does not occur all the time. Sometimes when I create a new launch configuration and select all of the required bundles, I get application running correctly.

My test application uses Apache Aries. I have additionally two projects, one, that contains blueprint.xml that registers some objects in JNDI and second one is a test client. What I need is to start bundles in following order:
1. all of the required Equinox bundles
2. then Apache aries bundles
3. then my component with blueprint.xml
4. then my test application

Instead I have following order of bundles:
ss
"Framework is launched."


id	State       Bundle
0	ACTIVE      org.eclipse.osgi_3.8.0.v20120123-1419
2	ACTIVE      org.eclipse.core.commands_3.6.0.v20111007-1312
3	ACTIVE      org.apache.aries.jndi_1.0.0
4	ACTIVE      org.eclipse.osgi.services_3.3.0.v20111117-1210
5	RESOLVED    com.mc.logback.fragment_1.0.0.qualifier
	            Master=7
6	ACTIVE      javax.jms_1.1.0.v200906010428
7	ACTIVE      ch.qos.logback.classic_1.0.7
	            Fragments=5
8	ACTIVE      ch.qos.logback.core_1.0.7
9	ACTIVE      org.apache.aries.proxy_1.0.0
10	ACTIVE      slf4j.api_1.6.4
11	ACTIVE      org.apache.felix.gogo.runtime_0.8.0.v201108120515
12	ACTIVE      org.eclipse.equinox.common_3.6.100.v20120120-1540
13	ACTIVE      blueprint.jms.activemq.registration_1.0.0.qualifier
14	ACTIVE      org.apache.activemq.kahadb_5.6.0
15	ACTIVE      org.apache.aries.util_1.0.0
16	ACTIVE      org.apache.activemq.activemq-core_5.6.0
17	ACTIVE      org.apache.geronimo.specs.geronimo-jms_1.1_spec_1.1.1
18	ACTIVE      org.eclipse.equinox.console_1.0.0.v20111215-1210
19	ACTIVE      org.apache.geronimo.specs.geronimo-j2ee-management_1.1_spec_1.0.1
20	ACTIVE      org.apache.aries.blueprint_1.0.0
21	ACTIVE      org.apache.felix.gogo.command_0.8.0.v201108120515
22	ACTIVE      org.apache.felix.gogo.shell_0.8.0.v201110170705
23	RESOLVED    blueprint.jms.activemq.test_1.0.0.qualifier

My component is inside blueprint.jms.activemq.registration_1.0.0 (id=13) and my test application is blueprint.jms.activemq.test_1.0.0 (23).
My test application should be registered by org.apache.aries.jndi (id=3) and org.apache.aries.blueprint (20), but my component is in the middle (13).

Right now I get some errors caused by not registering my component by aries properly.
When I "stop 13" & "stop 23" & "start 13" & "start 23" everything goes right.

I also tried to play with start levels (set start level for all apache aries to 3, my component to 4 and client to 5) but it did not solve the problem.

How can I force start order of my bundles inside Eclipse IDE (I use Run->Run Configurations->OSGi Framework)?

When I use Equinox standalone (directly from console, with config.ini) everything is ok.

[Updated on: Mon, 01 October 2012 17:40]

Report message to a moderator

Re: How to start bundles in proper order [message #931714 is a reply to message #929894] Wed, 03 October 2012 09:05 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas Watson
Messages: 419
Registered: July 2009
Senior Member
from what I can tell the framework launcher in PDE places the bundles in the osgi.bundles list in a random order. The only way you can reliably get the bundles to start in the order you need is to assign them a start-level. The launch configuration wizard gives you the ability to assign a default start-level and a specific one per bundle for bundles that you want to start before or after the default start-level.

HTH

Tom
Re: How to start bundles in proper order [message #931715 is a reply to message #931714] Wed, 03 October 2012 09:07 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas Watson
Messages: 419
Registered: July 2009
Senior Member
I will also state that designing your bundles such that they need a specific start-order is not a good practice. OSGi is dynamic in nature and your bundles should be prepared for bundles be started or stopped and react accordingly. If your design can handle the dynamic nature of OSGi then they will also be able to be started in any order.
Re: How to start bundles in proper order [message #933307 is a reply to message #929894] Thu, 04 October 2012 19:15 Go to previous message
Mariusz Cwikla is currently offline Mariusz Cwikla
Messages: 15
Registered: January 2012
Junior Member
Hello Thomas,
thank you very much for your answer.
First of all: I couldn't get start level to work as I wanted to. It seems that Eclipse Launcher does not always respects start level.

I agree, that using start levels is a bad practice and it should be used at last resort.

Secondly, I solved my problem. Actually the problem was that Apache Aries starts a background thread and may register components later, after whole framework has started. My bundle had an Activator that tried to get service by using BundleContext.getServiceReference, but since Aries registered it later than my activator ran, so I had problems. So the solution was to use service tracker or use blueprint for my client. Right now it runs fine.
Previous Topic:Differences between Equinox and other OSGi implementations and general OSGi questions
Next Topic:BridgeServlet problem
Goto Forum:
  


Current Time: Sat Jul 26 09:20:13 EDT 2014

Powered by FUDForum. Page generated in 0.01746 seconds