cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Wallez <sylvain.wal...@anyware-tech.com>
Subject Re: Potential Classloader bug
Date Mon, 06 Aug 2001 14:40:58 GMT


Berin Loritsch wrote:
> 
> Cocoon has a potential classloader issue.  The Excalibur that comes with
> Cocoon has support for the <driver/> entry in the JdbcDataSource--and uses
> the Context ClassLoader to load the driver's class.  The only problem is
> that even though the class is properly loaded, it is not loaded in the
> same classloader that created the JdbcDataSource.
> 
> Now, the question becomes: Should JdbcDataSource use the context classloader,
> or should Cocoon fix the classloader issue?  If JdbcDataSource does it, that
> means the class will be loaded by the same classloader that created JdbcDataSource.
> This may or may not be a bad thing.  If JdbcDataSource is loaded by the
> Boot ClassLoader, then the driver will be loaded for the Boot ClassLoader.
> 
> The thing is that the JdbcDataSource works fine when the ClassLoader in the
> Context ClassLoader (Thread.currentThread().getContextClassLoader()) is the
> same one or a parent of the classloader that loaded the JdbcDataSource.
> There is some wierdness with the DriverManager.getConnection() so it may be
> that the Driver class should be loaded with the the same classloader as
> JdbcDataSource.
> 

Not a specialist about classloader problems, but here are my thoughts.
Tell me if I'm wrong.

The force-load servlet parameter in Cocoon calls ClassUtils.loadClass(),
which uses the ClassLoader used to load itself, i.e. the
ServletContext's ClassLoader. This ClassLoader is also the parent of the
RepositoryClassLoader which is set with Thread.setContextClassLoader.

So what we have here is a ClassLoader which is the root of the
application ClassLoader hierarchy (whatever "application" means, here a
servlet context) and a final ClassLoader which the application should
use to benefit of dynamic compilation.

Shouldn't there be a mean in Avalon to store this "application root
ClassLoader" and use it in selected places, like JDBC driver loading ?
This will allow the JdbcDataSource <driver> to be loaded in the same
ClassLoader as with the "force-load" parameter.

Hope I was clear in explaining my thoughts :)
-- 
Sylvain Wallez
Anyware Technologies - http://www.anyware-tech.com


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message