ClassNotFound error when using 3rd party jars in bundle [message #78081] |
Tue, 28 November 2006 14:31  |
Eclipse User |
|
|
|
Originally posted by: ellen_matchey.yahoo.com
Hi,
I am getting a ClassNotFound exception for a class in a jar which I have imported into my bundle project. Does anybody have clues on what is happening?
Here is an overview of my project. I am attempting to create an osgi bundle to use with equinox. The Activator start() code relies on several external jars (each jar has 1 or more packages). I have imported the jars and added them into my build path. At compile time there are no errors. At runtime, I get a ClassNotFound exception when I try to instantiate or use static methods of a class in one of the jars. I have noticed, that I can instantiate ohter classes in the same jar, but in a different package, without a problem. There are also some environment variables that need to be set for the imported jars, but this does not seem to be the problems since a dump of the env looks okay. One last thing to note, I have the exact same project only instead of being a plug-in project its a regular java project. The java project works fine, no problems.
I am thinking it could be the order of the different jars I imported in the classpath? Does anybody know if this is definetly the case? Any other ideas?
Thanks in advance!
|
|
|
Re: ClassNotFound error when using 3rd party jars in bundle [message #78096 is a reply to message #78081] |
Tue, 28 November 2006 15:03   |
Eclipse User |
|
|
|
Originally posted by: tonimenzel.gmx.de
Hi Lena!
Do you have added the libs you need in the PDE-Dialog?
It's only a suggestion, so don't be worry if i'm wrong:
Do you find your jars in META-INF/MANIFEST.MF under key
"Bundle-Classpath:" ??
Maybe you just added it to the build path, but not as a dependency for
your bundle?
Look at the PDE-Dialog for the manifest, Tab: Runtime, Classpath.
I am not that familar with the PDE, but adding the dependency to the
manifest is mandatory by osgi spec. R4. (either with the PDE or direcly
does not matter)
Toni
Lena schrieb:
> Hi,
>
> I am getting a ClassNotFound exception for a class in a jar which I have imported into my bundle project. Does anybody have clues on what is happening?
>
> Here is an overview of my project. I am attempting to create an osgi bundle to use with equinox. The Activator start() code relies on several external jars (each jar has 1 or more packages). I have imported the jars and added them into my build path. At compile time there are no errors. At runtime, I get a ClassNotFound exception when I try to instantiate or use static methods of a class in one of the jars. I have noticed, that I can instantiate ohter classes in the same jar, but in a different package, without a problem. There are also some environment variables that need to be set for the imported jars, but this does not seem to be the problems since a dump of the env looks okay. One last thing to note, I have the exact same project only instead of being a plug-in project its a regular java project. The java project works fine, no problems.
>
> I am thinking it could be the order of the different jars I imported in the classpath? Does anybody know if this is definetly the case? Any other ideas?
>
> Thanks in advance!
|
|
|
|
Re: ClassNotFound error when using 3rd party jars in bundle [message #78167 is a reply to message #78154] |
Wed, 29 November 2006 02:59   |
Eclipse User |
|
|
|
Originally posted by: tonimenzel.gmx.de
ok, I reviewed your initial mail found two possible things:
1. the load-order is like the default classloader in general ("first
come ,first server") you can read this in the osgi core spec. ch. 3.8
(Runtime Classloading). (from www.osgi.org)
You say, that you can load classes from the jars, but only some of them
not, correct? Can you descibe you libs and containing packages?
2. Does your lib probably use it's own classloader ? (certain well known
jars do this and require some preparation, like log4j or jetty,
hibernate needs even more care)
regards,
Toni
Lena schrieb:
> Hi Toni,
>
> I do have all my jars listed under bundle-classpath in the Runtime tab in manifest.mf. I am wondering if it si the order of all the jars in this section that could be causing the problem?
>
> There is also a dependancy tab with a "required plug-ins" section, but as I understnad, this section is only for external plug-ins. IN my case I do not have any, other htan the standard org.eclipse.core.runtime.
>
> Thanks,
> Elena
|
|
|
Re: ClassNotFound error when using 3rd party jars in bundle [message #78263 is a reply to message #78154] |
Thu, 30 November 2006 23:55  |
Eclipse User |
|
|
|
Originally posted by: jeff_mcaffer.REMOVE.ca.ibm.com
Lena wrote:
> Hi Toni,
>
> I do have all my jars listed under bundle-classpath in the Runtime tab in manifest.mf.
> I am wondering if it si the order of all the jars in this section that could be causing
> the problem?
in your original post you said
"The Activator start() code relies on several external jars (each jar
has 1 or more packages). I have imported the jars and added them into my
build path"
I'm a bit confused here. What is an "external JAR" and what does it
mean to you to "add them to your build path"?
My sense here is that you are fighting the tools in this case. If you
have some JARs taht you want to *include* in your bundle, you can *copy*
them into the bundle project and then list them on the Bundle-Classpath
of the bundle manifest. That should be all you have to do. That is, if
you are using plugin projects you should *never* have to mess with the
Java build path in the project properties. This in fact is exactly what
PDE is doing for you automatically.
Jeff
|
|
|
Powered by
FUDForum. Page generated in 0.03083 seconds