commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles Dodinet <>
Subject [jasper] compiling jsp in osgi context
Date Mon, 05 Sep 2005 22:56:03 GMT

i'm trying to execute jsp in an osgi context with no luck as of today. 
i've embedded jetty as an osgi bundle and registered a BundleListener 
which registers installed bundles as webapp if they contain a web 
descriptor file. so far so good. it plays nice with simple html files. 
however i'm encountering troubles when it comes to jsp. generated 
servlets don't compile anything because javax.servlet.* classes are not 
found (please note that the transformation process is successfull).

in the manifest i declare javax.servlet as Import-Package (most prolly 
this seems to cause the issue) and jetty, jasper and related 
dependencies as bundled libs. Also as jasper seems to require an 
urlclassloader i've come up with a (pretty simple) custom urlclassloader 
which delegates all calls to either the target bundle (i.e. the 
installed bundle which wraps the webapp) or the current bundle.  jasper 
classes are succesfully loaded, but not the javax.servlet.* classes. 
googling about this using various criteria gives me in only three 
relevant results :

1/ embedded pagebox whose earlier version (2001) targets the same 
problematic as me. since it is released under lgpl i've tried to use it 
to match my specific needs, however it pretty quick became total hackery 
- 2000 lines src files not maintained since 2001 or so and they 
duplicate lot of services already provided by containers.
2/ a thread on oscar user list with no anwer
3/ a wiki page (entitled 'Tomcat as osgi bundles' and hosted on safehaus 
- with just a listing of bundles i'm unable to find) so i thought i 
could ask here if someone came to a solution to this problem. Has it 
already be done yet ?

below are the relevant manifest entries and webapp registration code. 
the target bundle as no Import-Package and no classes (just the simplest 
hello world). webapp registration [1] assigns the currentThead 
contextClassLoader to the simple delegating classloader discussed above 
- needed to start the webapp, and [2] sets the WebApplicationContext 
ClassLoader to the exact same ClassLoader - which i thought would have 
provided javax.servlet.* classes.

this may not be the best list for this question (should i rather ask on 
jetty or triplesec user lists ?), anyway thanks for any input.

Import-Package: org.osgi.service.http,javax.servlet,
Bundle-Classpath: .,

class JettyWrapper
     public void createApplication(final String appName, final File app, 
final Bundle fromBundle)
        Thread thread = new Thread()
                public void run()
                        ClassLoader loader = new DelegatingClassLoader(

Thread.currentThread().setContextClassLoader(loader);    [1]

                        String location = app.getAbsolutePath();

                        WebApplicationContext context =
                            jetty.addWebApplication("/" + appName, 
                        context.setClassLoader(loader);    [2]
                    catch (Exception e)
                        LOG.error("Unable to start '" + appName + "' 
context", e);

-- gd

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message