hello,
> wierd - not what I would expect. Can you show me the way you are
> constructing
> the URLClassLoader. Hopefully I will be able to figure it out from that.
>
sure, here we go ...
this code was extracted from an OpenEJB tool called 'SafeToolkit'.
the URLClassloader will simply constructed by using ...
URLClassLoader(codebase, SafeToolkit.class.getClassloader);
^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
url parent classloader
the parent classloader is the phoenix classloader that contains all
the jars from SAR-INF/lib of the OpenEJB block. i gave you the
contents (aka the jar files) of the SAR-INF/lib directory in my last
mail.
-----8<-----------8<-------------8<-------------8<-----------8---------
public static Class loadClass
(
String className,
String codebase
)
throws OpenEJBException
{
ClassLoader cl = getCodebaseClassLoader(codebase);
Object[] urls = ((java.net.URLClassLoader)cl.getParent()).getURLs();
for (int i = 0; i < urls.length; i++)
{
System.out.println("-->" + urls[i].toString());
}
// This should print out the URL classloader
// containing all the various bean jars.
System.err.println("----------------------->"
+ codebase + cl.toString());
// This should print out the phoenix classloader
// containing all jars from SAR-INF/lib.
System.err.println("----------------------->"
+ codebase + cl.getParent().toString());
Class clazz = null;
try
{
clazz = cl.loadClass(className);
}
catch (ClassNotFoundException cnfe)
{
throw new OpenEJBException(
messages.format("cl0007", className, codebase));
}
return clazz;
}
protected static ClassLoader getCodebaseClassLoader
(
String codebase
)
throws OpenEJBException
{
if (codebase == null) codebase = "CLASSPATH";
ClassLoader cl = (ClassLoader) codebases.get(codebase);
if (cl == null)
{
synchronized (codebases)
{
cl = (ClassLoader) codebases.get(codebase);
if (cl == null)
{
try
{
java.net.URL[] urlCodebase =
new java.net.URL[1];
urlCodebase[0] =
new java.net.URL("file",null,codebase);
// make sure everything works if we were not
// loaded by the system class loader
cl = new java.net.URLClassLoader(
urlCodebase, SafeToolkit.class.getClassLoader() );
codebases.put(codebase, cl);
}
catch (java.net.MalformedURLException mue)
{
throw new OpenEJBException(
messages.format ( "cl0001", codebase, mue.getMessage() ) );
}
catch (SecurityException se)
{
throw new OpenEJBException(
messages.format ( "cl0002", codebase, se.getMessage() ) );
}
}
}
}
return cl;
}
----->8----------->8------------->8------------->8----------->8-------
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>