[jboss-jira] [JBoss JIRA] Resolved: (JGRP-531) Resource loading issue
Bela Ban (JIRA)
jira-events at lists.jboss.org
Wed Jun 13 17:16:49 EDT 2007
[ http://jira.jboss.com/jira/browse/JGRP-531?page=all ]
Bela Ban resolved JGRP-531.
---------------------------
Resolution: Done
> Resource loading issue
> ----------------------
>
> Key: JGRP-531
> URL: http://jira.jboss.com/jira/browse/JGRP-531
> Project: JGroups
> Issue Type: Bug
> Reporter: Bela Ban
> Assigned To: Bela Ban
> Priority: Minor
> Fix For: 2.4.1 SP4, 2.5
>
>
> 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) {
> // hanson: returns only if resource is found
> // return loader.getResourceAsStream(name);
> InputStream is = loader.getResourceAsStream(name);
>
> if (is != null)
> return is;
> }
> }
> catch(Throwable t) {
> }
>
> if(clazz != null) {
> try {
> loader=clazz.getClassLoader();
> if(loader != null) {
> // hanson: returns only if resource is found
> // return loader.getResourceAsStream(name);
> InputStream is = loader.getResourceAsStream(name);
>
> if (is != null)
> return is;
> }
> }
> catch(Throwable t) {
> }
> }
> try {
> loader= ClassLoader.getSystemClassLoader();
> if(loader != null) {
> return loader.getResourceAsStream(name);
> }
> }
> catch(Throwable t) {
> }
>
> return null;
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list