Using jruby within java

Hi,

I’ve been following this:
http://kenai.com/projects/jruby/pages/DirectJRubyEmbedding#Ruby_code_in_your_classpath,_Mixed_with_java

I had the RubyLaucher code working in a project last year (jruby 1.3)
but I
can’t get any of those examples to work with jruby-complete 1.4. My code
compiles fine, but when executed I get:

:1: library `enumerator’ could not be loaded:
java.lang.ClassNotFoundException: org.jruby.libraries.EnumeratorLibrary
(LoadError)
…internal jruby stack elided…
from (unknown).(unknown)(:1)

Any ideas on what that might be from?

Thanks,
Matt

Hi,
Am 21.01.2010 um 05:15 schrieb Matt M.:
ve been following this:
http://kenai.com/projects/jruby/pages/DirectJRubyEmbedding#Ruby_code_in_your_classpath,_Mixed_with_java

I had the RubyLaucher code working in a project last year (jruby 1.3) but I can’t get any of those examples to work with jruby-complete 1.4. My code compiles fine, but when executed I get:

:1: library `enumerator’ could not be loaded: java.lang.ClassNotFoundException: org.jruby.libraries.EnumeratorLibrary (LoadError)

What jvm version are you using?


Reg. Adresse: Red Hat GmbH, Otto-Hahn-Strasse 20, 85609 Dornach bei München
Handelsregister: Amtsgericht München HRB 153243
Geschaeftsführer: Brendan Lane, Charlie Peters, Michael Cunningham, Charles
Cachera


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

This is what I’m using (OS X)

java version “1.6.0_17”
Java™ SE Runtime Environment (build 1.6.0_17-b04-248-10M3025)
Java HotSpot™ 64-Bit Server VM (build 14.3-b01-101, mixed mode)

Thanks,
Matt

Just wanted to clarify… that last error was from using jruby-complete.

I switched out jruby-complete with plain jruby and got this:

:1: no such file to load – builtin/core_ext/symbol (LoadError)
…internal jruby stack elided…
from (unknown).(unknown)(:1)

Matt

Hi Matt,

On Fri, Jan 22, 2010 at 10:05 AM, Matt M. [email protected]
wrote:

I switched out jruby-complete with plain jruby and got this:

:1: no such file to load – builtin/core_ext/symbol (LoadError)
…internal jruby stack elided…
from (unknown).(unknown)(:1)

I think this error will be resolved if you set jruby.home system
property or JRUBY_HOME environment variable.
But, I’m not sure where the first error came from. As far as I tried
it using embedding API (see
http://kenai.com/projects/jruby/pages/RedBridgeWay), it worked.
Probably, internal API has been changed since 1.3 and causes the
error.

-Yoko


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Hi Yoko,

I do have my JRUBY_HOME environment variable set. I’ll try the system
property too.

Maybe I’ll give an earlier version of JRuby a try…

Thanks,
Matt

I tried setting the system property and also tried JRuby 1.3.1 but had
the
same problem:

:1: library `enumerator’ could not be loaded:
java.lang.ClassNotFoundException: org.jruby.libraries.EnumeratorLibrary
(LoadError)
…internal jruby stack elided…
from (unknown).(unknown)(:1)

I’ll try a simpler test next…

OK So I made a simple example and of course, it worked.

What I was trying to do originally was create a custom Apache Solr
request
handler. I’d put the compiled jar file in my Solr-home/lib directory and
get
that error. But when I put the compiled jar into Jetty’s lib directory,
it
worked. So it must be something to do with the way Solr creates it’s
class
path. Just happy it’s working now!

Thanks for your help,

Matt

Hi,

Am 25.01.2010 um 03:34 schrieb Matt M.:

OK So I made a simple example and of course, it worked.

What I was trying to do originally was create a custom Apache Solr request handler. I’d put the compiled jar file in my Solr-home/lib directory and get that error. But when I put the compiled jar into Jetty’s lib directory, it worked. So it must be something to do with the way Solr creates it’s class path. Just happy it’s working now!

I am running in a similar issue with a similar solution like Matt.

Can someone explain the classloader needs so that a classloader which is
not the root classloader for a
whole application like jetty, but only for a single web-app can still
successfully get JRuby started and the
jsr 223 mechanism be used (to me it looks like this issue is not jsr 223
specific, but seems to apply to all
ways of running jruby from within a java app with multiple classloaders.

Thanks
Heiko


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Hi,

On Mon, Jan 25, 2010 at 10:30 AM, Heiko W.Rupp [email protected] wrote:

Can someone explain the classloader needs so that a classloader which is not the root classloader for a
whole application like jetty, but only for a single web-app can still successfully get JRuby started and the
jsr 223 mechanism be used (to me it looks like this issue is not jsr 223 specific, but seems to apply to all
ways of running jruby from within a java app with multiple classloaders.

Embedding API of JRuby 1.5.0 will have setLoader method, but JSR 223
won’t since JSR 223 doesn’t have a method to set classloader. Only one
possible change is to make it to use the classloader that is used to
load ScriptEngineFactory always. Currently,
Thread.currentThread().getContextClassLoader() is always used to get
the classloader for JSR223. Do you think the loader of
ScriptEngineFactory is better to choose? If so, I’ll make the change.

-Yoko


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Yoko,

Am 25.01.2010 um 17:55 schrieb Yoko H.:

Embedding API of JRuby 1.5.0 will have setLoader method, but JSR 223
won’t since JSR 223 doesn’t have a method to set classloader. Only one
possible change is to make it to use the classloader that is used to
load ScriptEngineFactory always. Currently,
Thread.currentThread().getContextClassLoader() is always used to get
the classloader for JSR223. Do you think the loader of
ScriptEngineFactory is better to choose? If so, I’ll make the change.

I don’t really have the knowledge to make a good quess here…
Would it be possible to set the classloader via some property?
But I think using the ScriptEngingFactory loader could solve
my issue.
I understand that your other APIs have some advantages over the
JSR 223 one, but I am seeing using JSR 223 as a very practical thing,
as it allows to add new script languages to a program with only little
additional coding overhead. Especially in the case of systemmanagement
tools in java (like http://rhq-project.org/) end users know many of the
languages
we Java-peeps can’t even think of (perl, python, zsh).

Thanks
Heiko


Reg. Adresse: Red Hat GmbH, Otto-Hahn-Strasse 20, 85609 Dornach bei München
Handelsregister: Amtsgericht München HRB 153243
Geschaeftsführer: Brendan Lane, Charlie Peters, Michael Cunningham, Charles
Cachera


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email