I recently ran into this same issue, but I was able to get what I
needed using something like:
jc = Java::JavaClass.for_name(“classname”)
jc.java_class.java_method(“getResource”).invoke(jc)
I was also a bit confused why none of the things you tried below
worked, but I never got around to posting.
Related to this, is there a reason why JRuby doesn’t set the current
Java thread’s contextClassLoader to the JRubyClassLoader? This caused
all kinds of problems for me because I was trying to use the Spring’s
ClassPathXmlApplicationContext, but it seems that internally, Spring
keeps trying to load stuff with the Thread’s contextClassLoader so
resources that I had added to the $CLASSPATH were not being found. I
wound up with something like:
load_from_class = Java::JavaClass.for_name
(“org.springframework.context.support.ClassPathXmlApplicationContext”)
class_loader = load_from_class.java_class.java_method
(“getClassLoader”).invoke(load_from_class)
JThread.currentThread().setContextClassLoader(class_loader)
@@app_context = ClassPathXmlApplicationContext.new(paths.to_java
(:string), ClassPathXmlApplicationContext.java_class)
I’m still not sure if that’s going to come back and bite me eventually.
-lenny
On Oct 8, 2007, at 4:38 PM, Nolan D. wrote:
getResource() method from JRuby. I’ve tried:
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email