Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Libra » No classes from WEB-INF/classes returned by Bundle.getEntryPaths
No classes from WEB-INF/classes returned by Bundle.getEntryPaths [message #698536] Tue, 19 July 2011 16:05 Go to next message
Sahoo Missing name is currently offline Sahoo Missing nameFriend
Messages: 26
Registered: July 2009
Junior Member
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 14:45 Go to previous messageGo to next message
Kaloyan Raev is currently offline Kaloyan RaevFriend
Messages: 201
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
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
deleteme7/build/classes

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 14:46]

Report message to a moderator

Re: No classes from WEB-INF/classes returned by Bundle.getEntryPaths [message #701433 is a reply to message #698958] Mon, 25 July 2011 05:36 Go to previous messageGo to next message
Sahoo Missing name is currently offline Sahoo Missing nameFriend
Messages: 26
Registered: July 2009
Junior Member
I must be doing something wrong, because I can't get the dev properties working. I am using a custom target and in the target settings, I added an argument as shown below:
-dev file:/tmp/dev.properties

The content of the above properties file is shown below:

ss141213@Sahoo:/tmp$ cat /tmp/dev.properties 
wab1=../build/classes

The manifest shows:
Bundle-Name: Wab1
Bundle-SymbolicName: wab1

I tried using Wab1 in the properties file as well. I added an activator, but the runtime is failing to locate the activator class which is present in the filesystem as the following find output shows:
ss141213@Sahoo:/tmp$ find /home/ss141213/EclipseWorkspace/wab1/ -name "*.class"
/home/ss141213/EclipseWorkspace/wab1/build/classes/wab1/MyServlet.class
/home/ss141213/EclipseWorkspace/wab1/build/classes/wab1/Activator.class



Thank you very much.
Re: No classes from WEB-INF/classes returned by Bundle.getEntryPaths [message #701467 is a reply to message #701433] Mon, 25 July 2011 06:43 Go to previous messageGo to next message
Sahoo Missing name is currently offline Sahoo Missing nameFriend
Messages: 26
Registered: July 2009
Junior Member
Just an update. I have made some progress. The relative path in dev.properties seems to be resolved against the current working directory as opposed to the root of the bundle. If I use absolute path in dev.properties, the framework is able to load the activator class. I still have a problem about processing bundle entries which does not include entries found in the additional dev classpath of the bundle, so in dev mode, GlassFish is not able to discover all the classes that are part of the bundle.

Can Libra provide an option to export the bundle as a WAB and then install it in the target OSGi platform?

Sahoo
Re: No classes from WEB-INF/classes returned by Bundle.getEntryPaths [message #701496 is a reply to message #701467] Mon, 25 July 2011 07:33 Go to previous message
Dimitar Giormov is currently offline Dimitar GiormovFriend
Messages: 13
Registered: July 2009
Junior Member
Hi Sahoo,

It sounds like you are using equinox 3.7.0
There was a bug, which prevented the web project class path to be loaded by the class loader in case of relative path outside the bundle root. This is fixed in 3.7.1
details you can see here:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=351083


Can you elaborate a bit on this:
Quote:
Can Libra provide an option to export the bundle as a WAB and then install it in the target OSGi platform?


Dimitar
Previous Topic:Exporting bundles as deployable plugins seems broken
Next Topic:[WAR Product] Validation issue for classes provided by the application server
Goto Forum:
  


Current Time: Wed Dec 11 19:36:09 GMT 2024

Powered by FUDForum. Page generated in 0.03506 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top