Recently I encountered a resource loading problem from within a tomcat webapp when trying to construct a JChannel when so triggered from a JMX MBean via the jconsole:
channel = new JChannel("tcp.xml");
Basically if the JChannel is constructed from a webapp, it can locate the "tcp.xml" from the classpath as a resource and works just fine. However if the JChannel is constructed from an MBean call stack via the jconsole, it failed to locate the resource due to the fact that the context classloading of the executing thread is different. So I hacked Util.java and it now worked in both cases. See below for details.
My question is should the hack I made be incorporated into the official version ?
(I hacked this on jgroups 2.2.9.4 , but I tried the latest 2.5.0CR1 which also seems to exhibit the same problem/behavior.)
Hanson Char
org.jgroups.util.Util.java
=================
public static InputStream getResourceAsStream(String name, Class clazz) {
ClassLoader loader;
try {
loader=Thread.currentThread().getContextClassLoader();
if(loader != null)
}
catch(Throwable t) {
}
if(clazz != null) {
try {
loader=clazz.getClassLoader();
if(loader != null)
}
catch(Throwable t) {
}
}
try {
loader= ClassLoader.getSystemClassLoader();
if(loader != null)
}
catch(Throwable t) {
}
return null;
}