cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Klimetschek <alexander.klimetsc...@mindquarry.com>
Subject Re: Problem with JAXP and shielding (was Re: Shielded class loading between blocks)
Date Wed, 22 Nov 2006 15:04:02 GMT
Carsten Ziegeler schrieb:
> I guess you have a xerces version in your web-inf/lib /or
> web-inf/shielded/lib. So you have two versions in your classpath.
> Try removing your version (put it either in the endorsed lib if you need
> your own version), the same applies for xalan.

The problem also exists without my ShieldingBlockServlet, I just tested 
serving jsps from a sitemap that is part of a normal cocoon webapp with 
shielding done by the deployer plugin and the same exception pops up 
upon requesting the jsp.

The actual bug is that the cocoon-jsp block does not work with any kind 
of shielding, since it uses the jasper jsp engine provided by the webapp 
and that one expects its own JAXP implementation. The jasper jsp engine 
can be loaded, but during compiling of a jsp it tries to load some JAXP 
class, which fails, because that loading is done by the shielding 
classloader, which has another version of Xerces and xalan. (IIRC, the 
latter point is the reason for shielding anyway, since many 
transformation stuff done with cocoon sitemaps does not work with older 
XSLT implementations provided by the webapp container - some really 
annoying problem we already stepped into).

A solution to that kind of problem is not easy. The first idea would be 
to explicitly check for the classloader in the cocoon JSP component 
before executing the Jasper enginge, but how do you find out if you got 
a shielding classloader or not? You cannot cast, not for the 
ShieldingClassLoader which will be part of the maven-war-plugin you 
don't want to have a dependency to, and also not for the 
WebappClassLoader, because that one is webapp container specific (and 
there is no API for that in the servlet specs).

So a dirty Hack would be to do a check like

ClassLoader cl = this.getClass().getClassLoader();
// step over all shielding class loaders to find the webapp classloader
while (cl.getClass().getName().indexOf("Shielded")) {
     cl = cl.getParent();
}

// set cl as context classloader
// start jsp engine


Looks kinda ugly....

Alex

-- 
Alexander Klimetschek
http://www.mindquarry.com


Mime
View raw message