Hello all,
Sorry if this is a (too) long message.
First a little background on my problem…
I have some java code that I’d like to wrap with jruby (eventually so I
can
use it in a jruby on rails app, but that’s not relevant at the moment).
Essentially, I am trying to do the following
I ‘require java’
I iterate across all the jar files I should need in the lib directory of
my
project with ‘Dir[“lib/*.jar”].each { |jar| require jar }’
I ‘java_import my.package.and.className’
however, when I try to use my class, it calls out to a delegate class to
take care of some initialization/singleton stuff (I didn’t write it, so
don’t blame me). The problem is I wind up with this error
NativeException: java.lang.RuntimeException: Unexpected
ClassNotFoundException looking up class ‘org/jruby/Main’
I can only guess that the init code is doing something seriously funky,
which is why JRuby can’t find it’s own running class (assuming I’m
reading
the error correctly). Any ideas for dealing with this are greatly
appreciated.
Now the immediate problem…
So far, I’ve tried setting the log4j level to debug, so I could get a
better idea of where in the java code, the errors are actually coming
from.
That has proven to be more difficult than I imagined.
I used this code to set the log level, and print it back out, so I know
it
at least thinks the setting took
org.apache.log4j.LogManager.getLogger(“my.package.className.class”).setLevel(org.apache.log4j.Level.toLevel(“DEBUG”))
puts "Log level is "+
org.apache.log4j.LogManager.getLogger(“my.package.className.class”).getEffectiveLevel.toString
Indeed, that does print out ‘DEBUG’, however, I’m still only seeing log
messages from my java code at INFO level.
I also threw a log4j.properties file in the directory and load it as
file = File.new(“log4j.properties”);
PropertyConfigurator.configure(file.toURL());
logger = Logger.getLogger(“java_integ_test.rb”);
logger.debug(“Test of debug msg”);
and it does seem to print out the debug message. I use that config file
to
set the root logger to DEBUG level
log4j.rootLogger=DEBUG, stdout
log4j.logger.com=DEBUG
However, I’m still not getting any debug messages from my java code
(only
the ruby script itself)
So, my two questions are.
- how the @#$% can I get the logger to run in debug for my java code
- Any idea on what the first error actually means?
I strongly suspect that if I can get 1 answered, then 2 will follow
easily.
I doubt that it matters, but I’m running jruby-1.6.7 [
darwin-x86_64-java ]
on OSX. The behavior is the same for both Mountain Lion with Java 1.7,
and
Lion with Java 1.6.
Thanks for reading this far,
Mat