No classes from WEB-INF/classes returned by Bundle.getEntryPaths [message #698536] |
Tue, 19 July 2011 12:05  |
Eclipse User |
|
|
|
I have a OSGi bundle faceted dynamic web project. I created a target platform called glassfish and ran the bundle using the same. The WAB gets deployed and am able to access the contents like htmls and JSPs located in the WebContent directory of the project. But, I could not access any servlet. I tried to debug it, so I wrote a little bit of code like this to see what all entries are found in the bundle:
private void getEntryPaths(Collection<String> entries, String path) {
Enumeration<String> subPaths = b.getEntryPaths(path);
if (subPaths != null) {
while (subPaths.hasMoreElements()) {
String next = subPaths.nextElement();
entries.add(next);
getEntryPaths(entries, next);
}
}
}
When I call the above method with "/" it didn't return anything from WEB-INF/classes. In fact, when I look at the bundle location, this is what I see:
osgi> status deleteme7
Framework is launched.
id Bundle Location
State Bundle File Name
216 initial@reference:file:../../EclipseWorkspace/deleteme7/WebContent/
ACTIVE deleteme7_1.0.0.qualifier
So, the root seems to be WebContent directory which does not of course has the compiled servlet class.
This seems like a bug to me.
Sahoo
|
|
|
Re: No classes from WEB-INF/classes returned by Bundle.getEntryPaths [message #698958 is a reply to message #698536] |
Wed, 20 July 2011 10:45   |
Eclipse User |
|
|
|
Hi Sahoo,
It's correct that the bundle root of a WAB is the WebContent folder - in your case:
../../EclipseWorkspace/deleteme7/WebContent/
Then you should have a look at the MANIFEST.MF - you should have something like:
Bundle-ClassPath: WEB-INF/classes/
This is the bundle classpath relative to the bundle root. So, in your case the effective classpath will be:
../../EclipseWorkspace/deleteme7/WebContent/WEB-INF/classes/
Now, the tricky part. The above will work if you export the WAB to JAR and deploy it on your OSGi framework - in your case Glassfish. When exporting the WAB to JAR, PDE will look into build.properties and will export all Java classes to that WEB-INF/classes in the result JAR.
If you install the WAB by reference directly from the Eclipse workspace to Glassfish (as far as I can see this is your use case), avoiding intermediate export to JAR, then you need a small trick. While you WAB is still in the Eclipse workspace the compiled Java classes are not in
deleteme7/WebContent/WEB-INF/classes/
but in
So, when you install the bundles from the Eclipse workspace to Glassfish you need to add ../build/classes to the bundle's classpath. Equinox provide such a feature by using the so called dev.properties file.
The only reference I know for how to use dev.properties is here: http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fruntime-options.html.
However, it's not a rocket science. The Glassfish Server Adapter needs to generate the dev.properties file, which content in your case should look like:
deleteme7=../build/classes
and then pass it as option (-dev) when launching Equinox.
Please, note that this feature is specific to Equinox. I hope Glassfish uses Equinox as OSGi framework. Of course, this approach also assumes that you can request the change in the Glassfish Server Adapter - the one that launches Glassfish from the Eclipse IDE.
Give it a try. If you need further help, let us know.
[Updated on: Wed, 20 July 2011 10:46] by Moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03355 seconds