Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 348499 - tooling must support embedded jars on Bundle-Classpath
Summary: tooling must support embedded jars on Bundle-Classpath
Status: NEW
Alias: None
Product: Virgo
Classification: RT
Component: tooling (show other bugs)
Version: unspecified   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-07 03:01 EDT by Martin Lippert CLA
Modified: 2012-01-17 13:00 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Lippert CLA 2011-06-07 03:01:21 EDT
(moved over from https://issuetracker.springsource.com/browse/STS-1806)

It seems that STS does not properly support the Bundle-Classpath in the BundleClasspathContainer.

create bundle project com.acme.example
copy jar file containing some source, e.g. package com.acme.example with interface ExampleService
add jar to Bundle-Classpath
Now, on the runtime tab of the manifest editor I cannot add the package export com.acme.example. When I manually add the jar to the build path I can select the package in the export package section (note: when adding the Export-Package statement manually, I get a warning saying 'Bundle does export non-existing package').

When I add the com.acme.example bundle (with embedded jar on Bundle-Classpath) to the Virgo repository and try to import com.acme.example, the package is found in the 'Add...' dialog on the dependencies tab of the manifest editor. However, the bundle classpath container seems to be incorrect (under the 'Bundle Dependencies' classpath container the jars appear containing the embedded jars but not showing their content). Any reference to the package com.acme.example creates a compiler error. However, if I deploy the dependent bundle it resolves correctly in Virgo.

So, the Bundle-Classpath and the Jar are definitely ok. However, STS seems to have problems with that setup.

I think it should be pretty easy to reproduce given the above recipe. Let me know if I can be of further assistance.

To fix this issue I expect:
a) that the manifest editor properly recognizes packages in embedded jar files
b) that the bundle classpath container properly reflects types in embedded jar files

PS: I've tried to use the bundle org.apache.httpcomponents.httpcore in one of my projects
Comment 1 Miles Parker CLA 2012-01-16 14:41:43 EST
OK, I'm not sure that we *should* support this. Embedded jars are haveily discouraged for Eclipse bundles in general. Jars should be deployed as plugin-jars. This seems to me to be consistent with an overall OSGi friendly approach. Is this really a use case we need to support for users, or should we instead focus encourage the deploying of jars correctly through project warnings? Thoughts?
Comment 2 Alfredo Aldundi CLA 2012-01-16 16:00:37 EST
My use case was using a library that was so OSGi-hostile that it was simply the easiest way to embed all required Jars in the bundle. OSGi-fying the library would have been close to impossible. Through embedding the library saw all it's required resources and classes on the classpath and worked flawlessly.

While I agree that embedded Jars should be avoided, I still think it would be reasonable to support them. After all, all OSGi containers support it too.
Comment 3 Miles Parker CLA 2012-01-16 18:35:07 EST
Fair enough. Did you try "Plugin-in from Existing  Jar archives"? Were you able to find another decent work-around? Not trying to push back on it, just trying to work through some triage priorities.
Comment 4 Alfredo Aldundi CLA 2012-01-16 23:50:03 EST
I realized that I could live without that particular library, that's how I got around the issue.

I could have unpacked all the jars of the library (there were many), as you've mentioned. So I was just a bit lazy. Still, at least a decent warning / error would be great.
Comment 5 Miles Parker CLA 2012-01-17 13:00:57 EST
OK, thanks for the feedback Alfredo. FWIW, that's how I usually feel about this issue -- it's a PITA to deal with, but it's usually worth the pain. However, we really do need to support it, at the very least so that we don't break people's existing stuff.

If people have an immediate need for this fix, please do comment or vote and we'll move it up the queue.

N.B. for people who don't have background on this: In addition to compatibility issues, embedded jars can cause performance and space issues in Equinox context and won't work in some other contexts. See for example:

http://dev.eclipse.org/mhonarc/lists/equinox-dev/msg02251.html