Tuesday, October 30, 2012

Apache Felix LinkageError

I was getting java.lang.LinkageError when running Felix. I had a big trouble finding out what the problem really was.

Finally, I found that javax.activation was being loaded by two modules differently (See http://frankkieviet.blogspot.no/2009/03/javalanglinkageerror-loader-constraint.html and http://stackoverflow.com/questions/4270950/compile-time-vs-run-time-dependency-java).

I couldn't exclude javax.activation from any of my modules (tried to explicitly ignore it from my pom.xml files (Maven), but that didn't work).

In the end I discovered that felix automatically loads some packages on startup. This is specified in the org.osgi.framework.system.packages.extra variable in config.properties (In the conf folder).
Just adding javax.activation;version=1.1.1 (The version I wanted) there fixed it.
Now Felix loads the package, and my waring modules fetch it from there instead of trying to load it themselves.

Sources: http://devangelist.blogspot.no/2011/04/osgi-bundle-lifecycles.html,

No comments:

Post a Comment