Classloading issues with JSF / Facelets

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Classloading issues with JSF / Facelets

Hi folks,

I got a little question upon jetty classloading (by the way, I'm relatively new to Jetty).

Currently, I'm developing a little jsf-based web project with an embedded jetty beneath. To get the jsf-Pages on the jetty is use a WebAppContext. My little project is based on the OSGi framework, so I further set the parent classloader of the WebAppContext to the one of the surrounding OSGi bundle. See the following snippet:

WebAppContext webappcontext = new WebAppContext(DeploymentManager.getDeploymentPath(),"/");

//Change the classloader to OSGi specific issues
WebAppClassloader pspfcl = new WebAppClassloader(Thread.currentThread().getContextClassLoader(), webappcontext);        

HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] { webappcontext, new DefaultHandler() });


It works all fine, the path (resolved by a call to DeploymentManager.getDeploymentPath()) also includes a WEB-INF directory with web.xml and faces-config.xml in it.

Now, here comes the problem :-) On serveral points during developement I ran into a dead end and all my researches hinted on classloading issues. I worked around this but it would be nice to get it all working :-)

One example: when I try to access the FacesContext (javax.faces.context.FacesContext) out of a backing bean by calling


I get a null pointer. Another example, I tried to set up a dynamic navigation menu upon the following example

<t:panelNavigation2 id="nav1">
    <t:navigationMenuItems id="navitems" value="#{navigationMenu.panelNavigationItems}" />

This makes it necessary to return a list / collection of NavigationMenuItems (org.apache.myfaces.custom.navmenu.NavigationMenuItem with superclass javax.faces.model.SelectItem) out of a backing bean. So, when I added the above listed code in a jsf-site, an exception told me that the collection wasn't one of the type "NavigationMenuItem", but it indeed was.

Next example, i tried to hook in a PhaseListener (javax.faces.event.PhaseListener). When I added the listener in my web.xml, a warning hinted, that my implementation of this PhaseListener wasn't of the correct type, but it also indeed was.

After googling around for some hours I found this FAQ-answer on the jetty website:

Is it possible, that theses errors are all caused by a classloading issue - as you can see, all the examples are associated with javax class or interface? What can I try to test this? The "setClassLoaderJava2Compliant"-method is only available in org.mortbay.http.HttpContext?

Thanks for your help, regards,