Classes not being found [message #1731237] |
Tue, 03 May 2016 16:38 |
|
When deploying a bundle I'm getting a NoClassDefFoundError for "javax.naming.NameNotFoundException".
javax.naming has been part of the platform since Java 1.3 I think, so what is going on?
I tried adding import package "javax.naming", then "javax.naming.directory" but then Virgo complains with a ClassNotFoundException for "org.apache.naming.java.javaURLContextFactory". I don't refer to this package anywhere in my bundle (a "javax.naming.NoInitialContext" was in the stack) so it has to be an implementation/configuration issue somewhere.
I don't want to have to declare "all" the core API packages like "javax.naming" and "javax.naming.directory" as package imports, nor do I want think about what classes the platform "might" use to implement the functionality (e.g. org.apache.**).
What do I need to add to the Virgo server configuration to get my bundles to work?
Indeed, if this can be configured, shouldn't this be part of the standard configuration?
|
|
|
|
Re: Classes not being found [message #1731320 is a reply to message #1731292] |
Wed, 04 May 2016 09:24 |
|
Hi GianMaria,
I've looked at the alternative solutions you referred to.
The tooling for PDE and OSGi has indeed been leading me a stray.
It is not apparent that javax.* has to be explicitly imported and I never saw this behaviour when running an "equinox" server.
Is there a plugin available that can alert me to the missing imports?
Also, the DNS issue was me "just" creating an InitialDirContext without explicitly requesting a DNS factory instance.
I am now undecided as to whether I should use the "osgi.compatibility.bootdelegation" option or not. I would love it if the PDE or maybe even the Virgo tooling could flag up missing imports.
-
Bill
[Updated on: Wed, 04 May 2016 10:31] Report message to a moderator
|
|
|
Re: Classes not being found [message #1733283 is a reply to message #1731320] |
Thu, 26 May 2016 00:41 |
GianMaria Romanato Messages: 57 Registered: November 2015 |
Member |
|
|
Sorrt for the late reply, I did not notice this message.
Bill Mair wrote on Wed, 04 May 2016 11:24Hi GianMaria,
It is not apparent that javax.* has to be explicitly imported and I never saw this behaviour when running an "equinox" server.
Is there a plugin available that can alert me to the missing imports?
That's probably because of a different boot delegation policy. Eclipse itself, configures Equinox to make automatically available a large number of packages that you would otherwise need to import explicitly. I guess this is because in Eclipse RCP it's more common to use Require-Bundle than Import-Package so Equinox is configured to reduce the learning curve of plug-in developers.
I am not aware of any plug-in that can help you. However, if you compile with Maven/Tycho for example, I think Tycho will refuse to compile your code if a javax.* package is not imported. So if you use some sort of continuous integration you may be alerted soon. In any case, this is really something to which I am sure you will get used very soon.
Quote:
I am now undecided as to whether I should use the "osgi.compatibility.bootdelegation" option or not. I would love it if the PDE or maybe even the Virgo tooling could flag up missing imports.
I am not aware of a way PDE can be extended to overcome this limitation. I believe it's a non trivial issue otherwise the PDE team would have already solved it.
The Virgo tools just integrate Virgo in Eclipse and I cannot really work around the PDE limitations.
Personally I would avoid to tweak with bootdelegation, unless you are 100% sure you will never want to try another Application Server, because not all OSGi application servers allow to configure all aspects of the OSGi runtime.
For example, IBM WebSphere Liberty does not allow to control bundle start level and activation order.
GianMaria
|
|
|
Powered by
FUDForum. Page generated in 0.03563 seconds