2
votes

I have written an OSGi bundle which has dependency on following spring framework bundle and some other similar JARs.

org.springframework.core-3.2.3.RELEASE.jar

Most of the times, the spring framework core bundle starts without any problem. But at times, the bundle fails to resolve dependency. Following error is thrown on click of start button in felix console:

*ERROR* [FelixDispatchQueue] org.springframework.core FrameworkEvent ERROR (org.osgi.framework.BundleException: Unresolved constraint in bundle org.springframework.core [494]: Unable to resolve 494.0: missing requirement [494.0] osgi.wiring.package; (&(osgi.wiring.package=javax.xml.stream.events)(version>=0.0.0)))
org.osgi.framework.BundleException: Unresolved constraint in bundle org.springframework.core [494]: Unable to resolve 494.0: missing requirement [494.0] osgi.wiring.package; (&(osgi.wiring.package=javax.xml.stream.events)(version>=0.0.0))
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4095)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2114)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1368)
at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
at java.lang.Thread.run(Unknown Source)

Also, some other spring framework JAR's too throw the same error and fail to resolve/start.

*ERROR* [FelixDispatchQueue] org.springframework.beans FrameworkEvent ERROR (org.osgi.framework.BundleException: Unresolved constraint in bundle org.springframework.beans [495]: Unable to resolve 495.0: missing requirement [495.0] osgi.wiring.package; (&(osgi.wiring.package=org.apache.commons.logging)(version>=1.1.1)(!(version>=2.0.0))))
org.osgi.framework.BundleException: Unresolved constraint in bundle org.springframework.beans [495]: Unable to resolve 495.0: missing requirement [495.0] osgi.wiring.package; (&(osgi.wiring.package=org.apache.commons.logging)(version>=1.1.1)(!(version>=2.0.0)))
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4095)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2114)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1368)
at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
at java.lang.Thread.run(Unknown Source)

As per my understanding, javax.* packages are provided by system bundle. Can anyone please help me in solving this ?

EDIT:

This is happening when I kill the java process. Also this is happening for all bundles which have following imports :

javax.jcr
javax.swing
javax.xml.stream.events
org.apache.commons.logging
javax.servlet
javax.sql
javax.script
javax.net

When I kill the java process and I restart my AEM, I am facing this issue. When I uninstall the bundle and restart my AEM and reinstall the bundle, it works just fine.

1

1 Answers

0
votes

Only the java.* packages are provided by the system bundle by default. All other packages have to be defined using the framework property org.osgi.framework.system.packages. Each OSGi framework has a default config for this property that is also often dependent on the Java Runtime Version used.

If a javax package is not exported by the system bundle but you know it is available in your jra then you can use the framework property org.osgi.framework.system.packages.extra . It allows to define packages that are to be exported in addition to the default ones.

One thing that is strange is that you write that you only sometimes have the error. I would expect it to either work all the time or fail all the time.