I have a 3rd party JAR that I have converted to an OSGI bundle using bnd. The code I need to call to use it from my own bundle looks something like this:
ThirdParty.setRegKey(myRegKey);
ThirdParty thirdParty = new ThirdParty();
thirdParty.callMethod();
What seems to be causing me problems is the first line – the static method call. Outside of the OSGI container, using the standard JAR, this works fine. Inside OSGI, however, I get an error at line 3 stating that no registration key has been set.
Are there any issues with static method calls across bundles like this? It’s almost as if the static context is not being shared across the bundles.
Have you debugged the code? Since you don’t tell us which 3rd-party library you are working with and we don’t know your full environment, it could be the
setRegKey()orcallMethod()are trying to do something ‘smart’ which doesn’t work inside OSGi.The JDBC driver manager has this problem where your bundle imports the JDBC driver class but the driver manager decides that the calling thread from your bundle shouldn’t ‘see’ the JDBC driver class, so it fails when run inside OSGi.