[logback-user] OSGi wiring problems when using SLF4J+Logback

Joel W witt403 at googlemail.com
Fri Jan 29 01:12:59 UTC 2016


Hi all,

I’m switching logging mechanisms from JUL to SLF4J+Logback on an application that is an OSGi bundle - it’s a plugin for an OSGi application. However, I’m getting some wiring problems: many Logback dependencies don’t seem to be resolved. I have the relevant Maven dependencies as follows:

	 <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-api</artifactId>
         <version>1.7.12</version>
     </dependency>
     <dependency>
         <groupId>ch.qos.logback</groupId>
         <artifactId>logback-core</artifactId>
         <version>1.1.3</version>
     </dependency>
     <dependency>
         <groupId>ch.qos.logback</groupId>
         <artifactId>logback-classic</artifactId>
         <version>1.1.3</version>
     </dependency>

All 3 of these are specified in the class path of the application runner script. This script also points to a basic logback.xml configuration file that just prints to stdout. For bundling I use the maven-bundle-plugin v3.0.1, where the relevant directives are:

<Export-Package>
	org.slf4j*, ch.qos.logback* 
</Export-Package>
<Embed-Transitive>true</Embed-Transitive>

The application gets assembled using maven-assembly-plugin v2.6; I’ve attempted to have the above 3 dependencies start as bundles, before the main application, or simply included them in my /lib/ folder. Upon attempting to initialize the application, I get the error:

14:13:01.540 [FelixStartLevel] ERROR o.p.o.framework.FrameworkSlf4jLogger - Error starting file:/…/app-name/target/distribution/bundles/app.jar
org.osgi.framework.BundleException: Unresolved constraint in bundle app [15]: Unable to resolve 15.0: missing requirement [15.0] osgi.wiring.package; (osgi.wiring.package=groovy.lang)
	at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4002) ~[org.apache.felix.main-4.4.1.jar:na]
	at org.apache.felix.framework.Felix.startBundle(Felix.java:2045) ~[org.apache.felix.main-4.4.1.jar:na]
	at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1299) ~[org.apache.felix.main-4.4.1.jar:na]
	at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:304) [org.apache.felix.main-4.4.1.jar:na]
	at java.lang.Thread.run(Thread.java:745) [na:1.8.0_25]

If I include groovy.lang* in the <Export-Package> directive, then I get another missing requirement: javax.jms, and this keeps going with packages that Logback depends on (javax.mail, java.mail.internet, javax.servlet…). I’ve experimented quite a bit, but unfortunately I can’t spot what I’m missing or doing wrong. Does anyone have any idea what might be wrong?

Any help would be greatly appreciated!

Many thanks,
Joel


More information about the logback-user mailing list