« Return to Thread: Class loading problem when embering DWR

Class loading problem when embering DWR

by Han Liu :: Rate this Message:

Reply to Author | View in Thread

hi all,

I create a module to add DWR to my framework Yilan

(yilan.googlecode.com )

Yilan is something like this

Yilan Kernel classLoader

   --- > Module DWR
   --- > Module XFire
   --- > Module Jetty
   --- > Module Tomcat

So DWR must have a dependecy on Jetty
Each module has it's  local ClassLoader and is dynamically loaded during runtime

When add DwrServlet to the mapping of Jetty and jetty call
DwrServlet.initialize(),

error accurs when finding the system classes in

 Class impl = LocalUtil.classForName((String) value);

The thread context classloader is not equal to Dwr lib's classloader

So I change  the following  in LocalUtil

public static Class classForName(String className) throws ClassNotFoundException
{
  return Thread.currentThread().getContextClassLoader().loadClass(className);
}

to

public static Class classForName(String className) throws ClassNotFoundException
{
  try {
  return Thread.currentThread().getContextClassLoader().loadClass(className);
  } catch (ClassNotFoundException e) {
        return LocalUtil.class.getClassLoader().loadClass(className);
  }
}

and it works fine.   But is it enough?


Thanks for your help

Best Regards

Han Liu

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...

 « Return to Thread: Class loading problem when embering DWR