I've been trying to get the new 1.2 JMX stuff working in Tomcat 5.5.7. I've run into some problems when invoking mbeans that load resources from the classpath. If I load the resource with:
things work OK. However if I just use:
Resource resource = new ClassPathResource("foo.xml", this.getClass().getClassLoader());
the resource cannot be found. However if I invoke the latter statement from within the webapp (ie: not thru JMX) it does work.
Resource resource = new ClassPathResource("foo.xml"));
I believe this happens because the Thread's context ClassLoader is used by default in the ClassPathResource class, but when you invoke the method through Tomcat's JMX, this Thread context ClassLoader is not the same as the ClassLoader that was used to load the webapp - hence the resource cannot be found.
What I'm trying to do is actually a little more complex than the example I gave above, and its failing because some internal spring classes don't specify the class loader explicitly when loading resources. It seems that I can't (easily) override/change this behaviour either.
Any ideas on how I can fix this problem?