For example, AxisConfigBuilder uses it to resolve TransportReceiver and TransportSender. Please note the class can be suppiled by the application or by Axis2 (default).
This approach works well in the following two cases:
1) The class is provided by the application and it's visible to the TCCL.
2) The class is provided by Axis2 and the axis2 is loaded by either the application classloader or any ancestor of the application classloader.
We have a different use case. (similar as tomcat)
1) We load axis2 together with our library from an isolated classloader (CL1)
2) The application is running with its own classloader (TCCL=CL2)
3) CL2 cannot see classes in CL1
As a result, we got a ClassCastException for the Transport receiver and sender even they are from the Axis2. Would it make sense to support this case using the following:
Class cls = null;
try{
cls = Class.forName(clasName, true, Thread.currentThread().getContextClassLoader()); // Try the application class loader
} catch (ClassNotFoundException e) {
cls = Class.forName(className); // Try the axis2 classloader
}
Thanks,
Raymond
Description
In most of the Axis2 code, thread context classloader (TCCL) is used to resolve class by name as follows.
Class.forName(clasName, true, Thread.currentThread().getContextClassLoader());
For example, AxisConfigBuilder uses it to resolve TransportReceiver and TransportSender. Please note the class can be suppiled by the application or by Axis2 (default).
This approach works well in the following two cases:
1) The class is provided by the application and it's visible to the TCCL.
2) The class is provided by Axis2 and the axis2 is loaded by either the application classloader or any ancestor of the application classloader.
We have a different use case. (similar as tomcat)
1) We load axis2 together with our library from an isolated classloader (CL1)
2) The application is running with its own classloader (TCCL=CL2)
3) CL2 cannot see classes in CL1
As a result, we got a ClassCastException for the Transport receiver and sender even they are from the Axis2. Would it make sense to support this case using the following:
Class cls = null;
try{
cls = Class.forName(clasName, true, Thread.currentThread().getContextClassLoader()); // Try the application class loader
} catch (ClassNotFoundException e) {
cls = Class.forName(className); // Try the axis2 classloader
}
Thanks,
Raymond