Forum: JRuby Loading jars

Posted by Rodrigo Botafogo (Guest)
on 2012-07-26 18:42
(Received via mailing list)
Hello!

I have a jruby application that requires a jar file
(netcdfAll-4.3.jar).  This jar depends on another jar
(joda-time-2.1.jar).  Although Im able to access netcdf classes in
jruby, when a netcdf class tries to access one of the classes in
joda-time, the application fails with:

NativeException: java.lang.NoSuchMethodError:
org.joda.time.format.DateTimeFormatter.withZoneUTC()Lorg/joda/time/format/DateTimeFormatter;

Im even able to access DateTimeFormatter from my jruby code without
problem.  The error only occurs if the netcdf class tries to access
the joda class.

How can I load those classes and make them available to all jars?


Thanks

--
Rodrigo Botafogo
Posted by Manuel Ramos Caro (Guest)
on 2012-07-26 23:27
(Received via mailing list)
Hi Rodrigo copy this jar to java jre that your jruby uses to run it's
the easy solution for me...

on Ubuntu...and Java 6

/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/ext

Regards
Posted by kristian (Guest)
on 2012-07-27 00:07
(Received via mailing list)
in case you use jruby-complete.jar then try to get the joda jar first
into classloader. the problem is the packed joda within jruby which
apparently has a different version the joda-2.1

regards,
Kristian

On Fri, Jul 27, 2012 at 2:55 AM, Manuel Ramos Caro
Posted by Rodrigo Botafogo (Guest)
on 2012-07-27 15:33
(Received via mailing list)
Kristian,

Sorry to ask, but how do I do that? Is there a way to remove the jruby
joda package?


Thanks,


On Thu, Jul 26, 2012 at 11:05 PM, kristian <m.kristian@web.de> wrote:
>> easy solution for me...
>>> Hello!
>>>
>>
>     http://xircles.codehaus.org/manage_email
>
>



--
Rodrigo Botafogo
Posted by kristian (Guest)
on 2012-07-27 16:28
(Received via mailing list)
hi,

well, the best would be to fix the jruby-core jar:
http://jira.codehaus.org/browse/JRUBY-5848

this comes without joda or any other embedded jar (yaml). so with such
a clean classloader you are on the safe side unless you use gems with
"vendored" jars like jruby-openssl, nokogiri-java, etc.

maybe your environment allows it to prepend something to the
boot-classloader which came handy for me to enforce my versions of
Xerces, Xalan and Bouncy-Castle jars on the system (oracle application
server).

if you experience such situation with a webcontainer then you can
reverse the lookup sequence of the web-classloader to first look
inside itself before going to the parent classloader. not sure (never
saw it) if that can be done for ear-file-containers (and not sure if
ruby scripting reached ejb already :))

another way is to call jruby like

$ java -cp joda.jar:jruby-complete.jar org.jruby.Main

that should do the trick as well.

within a maven project just make sure your joda artifact is declared
BEFORE the jruby-complete artifact.

maybe for jruby commandline there is a way to "prepend" jars.

quite possible that the putting the joda in the ext directory works as 
well.

so there are some workarounds but I have a look on the weekend what is
missing for jruby-core jar to work properly - that would be a great
first step to offer a way for a clean classloader setup.

regards,
Kristian

On Fri, Jul 27, 2012 at 7:01 PM, Rodrigo Botafogo
Posted by Rodrigo Botafogo (Guest)
on 2012-07-27 16:50
(Received via mailing list)
Kristian,

Thanks for the reply... but it was way over my current abilities. I
tried the -- $ java -cp joda.jar:jruby-complete.jar org.jruby.Main --
but got a cannot load org.jruby.Main error, although jruby works fine.
 Im working on cygwin, so maybe I can fix the classloader, but then I
really have no idea how to do that!

Do you have any simpler workaround?  I used to be a good java
programmer -- when java was in beta stage (and sadly this is not a
joke!).


Thanks for your help,


Rodrigo

On Fri, Jul 27, 2012 at 3:27 PM, kristian <m.kristian@web.de> wrote:
> boot-classloader which came handy for me to enforce my versions of
>
>
>>
>>> apparently has a different version the joda-2.1
>>>>
>>>>> (netcdfAll-4.3.jar).  This jar depends on another jar
>>>>> the joda class.
>>>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>



--
Rodrigo Botafogo
Posted by kristian (Guest)
on 2012-07-27 17:24
(Received via mailing list)
try

java -Djava.ext.dirs=joda-time -jar jruby-complete-1.6.7.2.jar

where the directory joda-time contains the joda-jar. but I do not know
how to test it myself.

indeed the -cp version did not work - sorry did not try it out before 
writing :(

regards,
Kristian

On Fri, Jul 27, 2012 at 8:18 PM, Rodrigo Botafogo
Posted by Rodrigo Botafogo (Guest)
on 2012-07-27 17:49
(Received via mailing list)
Thanks for your help... got a solution!!!

jruby -J-Xbootclasspath/a:<joda_time_dir>\joda-time-2.1.jar netcdf.rb


Rodrigo



On Fri, Jul 27, 2012 at 4:22 PM, kristian <m.kristian@web.de> wrote:
> Kristian
>>
>> On Fri, Jul 27, 2012 at 3:27 PM, kristian <m.kristian@web.de> wrote:
>>> boot-classloader which came handy for me to enforce my versions of
>>>
>>>
>>>>
>>>>> apparently has a different version the joda-2.1
>>>>>>
>>>>>>> (netcdfAll-4.3.jar).  This jar depends on another jar
>>>>>>> the joda class.
>>>>>>
>>>>
>>>>
>> --
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>



--
Rodrigo Botafogo
Integrando TI ao seu negcio
21-3010-4802/11-3010-1802
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.