Question

I am currently trying to get a bundled started in Equinox.

This bundle requires commons-logging.

I tried including the latest commons-logging jar from Maven Central. No luck.

I then moved to slf4j. This is my current status from the OSGi console:

11      ACTIVE      jcl.over.slf4j_1.6.6
12      ACTIVE      slf4j.api_1.6.6
                    Fragments=14
14      RESOLVED    slf4j.simple_1.6.6
                    Master=12

In the logs I see the following exception:

!ENTRY org.eclipse.osgi 4 0 2012-07-09 11:36:56.157
!MESSAGE Error starting bundle: initial@file:/C:/test/slf4j-simple-1.6.6.jar
!STACK 0
org.osgi.framework.BundleException: A fragment bundle cannot be started: slf4j.simple_1.6.6 [14]
    at org.eclipse.osgi.framework.internal.core.BundleFragment.startWorker(BundleFragment.java:224)
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:300)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.startBundle(EclipseStarter.java:1119)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.startBundles(EclipseStarter.java:1112)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.loadBasicBundles(EclipseStarter.java:631)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:277)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.main(EclipseStarter.java:151)

!ENTRY org.eclipse.osgi 4 0 2012-07-09 11:36:56.205
!MESSAGE Bundle slf4j.simple_1.6.6 [14] is not active.

What is the best way to get a commons-logging compatible bundle up and running in Equinox 3.8?

Was it helpful?

Solution

slf4j-simple is a fragment and fragments cannot be started.

Did you list it in your config.ini with @start at the end? Just remove that.

OTHER TIPS

From OSGi Service Platform Core Specification

A Fragment bundle must enter the resolved state only if it has been successfully
attached to its host bundle.

All class or resource loading of a fragment is handled through the host’s
class loader, a fragment must never have its own class loader. Fragment bundles
are treated as if they are an intrinsic part of their host.

Many times we start the fragment bundle which then results into the org.osgi.framework.BundleException: A fragment bundle cannot be started Exception.

As per the specification there is no need to start the fragment bundle. Its not a problem of your code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top