Skip to main content

Loader element of context supported in Glassfish 4.0?

Please note these forums are being decommissioned and use the new and improved forums at
No replies
Joined: 2013-11-07

I am trying to migrate a custom set of webapps from tomcat to glassfish. The webapps all use a custom classloader to allow sharing of class instances between them (Think of heirarchical Spring bean factories). The way that we currently make this work is with a custom webapp classloader that we expose through the the context.xml:

<Context crossContext="true">
    <Manager pathname="" />
    <Loader loaderClass=""

Unfortunately, when I launch the root webapp, I get this exception:

[2013-11-06T09:35:15.019-0800] [glassfish 4.0] [SEVERE] [AS-WEB-CORE-00292] [javax.enterprise.web.core] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1383759315019] [levelValue: 1000] [[
java.lang.ClassNotFoundException: not found by org.glassfish.main.web.core [261]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(
at org.apache.felix.framework.BundleWiringImpl.access$400(
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(
at org.apache.catalina.loader.WebappLoader.createClassLoader(
at org.apache.catalina.loader.WebappLoader.start(
at org.apache.catalina.core.StandardContext.start(
at com.sun.enterprise.web.WebModule.start(
at org.apache.catalina.core.ContainerBase.addChildInternal(
at org.apache.catalina.core.ContainerBase.addChild(
at org.apache.catalina.core.StandardHost.addChild(
at com.sun.enterprise.web.WebContainer.loadWebModule(
at com.sun.enterprise.web.WebContainer.loadWebModule(
at com.sun.enterprise.web.WebApplication.start(

It looks like it almost, kinda works... but it looks like the root error is coming out of Felix and our webapp classloader is not in a bundle. I've tried putting the jar with the webapp classloader in as_install/lib, domains/domain1/lib, domains/domain1/applib and there is no difference in the error generated.

Two questions here: does anyone know if the Loader element is supposed to be supported in a glassfish context.xml? Secondly, might this work if I create a bundle with our classloader and register it?

I realize that the "correct" way to do this would be to re-write this using more standard means to enable sharing of objects between webapps, but we are trying to just get it working first, then refactor it to remove the customizations.