Ruby Forum JRuby > Problem with JRuby, JTestr, and Hadoop

Posted by Bryan Duxbury (Guest)
on 15.05.2008 20:03
(Received via mailing list)
I'm writing an application in Java that uses Hadoop and is tested
with JTestr. Hadoop uses some classpath magic to find config files it
needs. I can verify that my classpath is correct, because if I make a
minimal JUnit test, everything works fine. However, when I try to do
the same thing in JTestr, I get weird exceptions, which I've tracked
down to the fact that the config files aren't being located.

Does JRuby and/or JTestR interact strangely with the classloader such
that it would interfere with finding resources on the classpath?

-Bryan

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Posted by Tyler Jennings (Guest)
on 15.05.2008 20:39
(Received via mailing list)
On 5/15/08, Bryan Duxbury <bryan@rapleaf.com> wrote:
> I'm writing an application in Java that uses Hadoop and is tested with
> JTestr. Hadoop uses some classpath magic to find config files it needs. I
> can verify that my classpath is correct, because if I make a minimal JUnit
> test, everything works fine. However, when I try to do the same thing in
> JTestr, I get weird exceptions, which I've tracked down to the fact that the
> config files aren't being located.
>
>  Does JRuby and/or JTestR interact strangely with the classloader such that
> it would interfere with finding resources on the classpath?
>

I'm guessing a bit here, but I have had classpath problems in JRuby
when Spring tried to use the Thread's context class loader.  You might
try this in your before block and see if it fixes your problem:

java.lang.Thread.current_thread.context_class_loader =
JRuby.runtime.getJRubyClassLoader

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Posted by Bryan Duxbury (Guest)
on 15.05.2008 22:00
(Received via mailing list)
I get "uninitialized cconstant JRuby" if I try that.

-Bryan
Posted by Vladimir Sizikov (Guest)
on 15.05.2008 22:09
(Received via mailing list)
You need:
require 'jruby'

Thanks,
  --Vladimir

On Thu, May 15, 2008 at 10:00 PM, Bryan Duxbury <bryan@rapleaf.com> 
wrote:
> I get "uninitialized cconstant JRuby" if I try that.
> -Bryan
> On May 15, 2008, at 11:38 AM, Tyler Jennings wrote:
>
> java.lang.Thread.current_thread.context_class_loader =
>
> JRuby.runtime.getJRubyClassLoader
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Posted by Tyler Jennings (Guest)
on 15.05.2008 22:10
(Received via mailing list)
require 'java' first.  Sorry, I skipped right over that.

On 5/15/08, Bryan Duxbury <bryan@rapleaf.com> wrote:
> JRuby.runtime.getJRubyClassLoader
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Posted by Bryan Duxbury (Guest)
on 15.05.2008 22:13
(Received via mailing list)
Holy crap! That makes it work. (Well, not my test, just the
infrastructure parts :).

Thanks to everyone who contributed.

-Bryan

On May 15, 2008, at 1:08 PM, Vladimir Sizikov wrote:

>> On May 15, 2008, at 11:38 AM, Tyler Jennings wrote:
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email