Another classpath problem!

Hello list,

I don’t know why but I still have a class not found since I do:

Dir[“lib/**/*.jar”].each do |jar|
require jar
end
I also try with the full path since in the jruby cookbook it seems
that jruby use the working directory not the current file…

Dir[“lib/**/*.jar”].each do |jar|
require File.expand_path(jar)
puts “jar file =#{File.expand_path(jar)}”
end

I found some thread about using a $CLASSPATH and << jar inside …
without success …

I know it is a newbie question but I if someone can help me…

thanks

arnaud


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Wed, Feb 4, 2009 at 11:56 AM, Arnaud G. [email protected]
wrote:

Dir[“lib/**/*.jar”].each do |jar|
require File.expand_path(jar)
puts “jar file =#{File.expand_path(jar)}”
end

I found some thread about using a $CLASSPATH and << jar inside …
without success …

I know it is a newbie question but I if someone can help me…

Are you certain you have all the jars you need? If a java jar relies
on classes in other dependent jars and those are not present, you’ll
still get a ClassNotFoundException as the JVM tries to resolve all
references when the class(es) is/are loaded.

Just a thought,
/Nick


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

thanks for answer I will double check…
But this is the good way to add jar, there is not other variable to
set or something else…

arnaud

2009/2/4 Nick S. [email protected]:

Are you certain you have all the jars you need? If a java jar relies

arnaud
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

Well, after lot of investigation it seems that the problem is when a
class try to access a jar file…
Finally, I decided to create another jar file for my class and it
works… but I still don’t understand why it is not working since the
jar is correctly require and import and the class are in the ruby
path…

arnaud

2009/2/4 Arnaud G. [email protected]:

Dir[“lib/**/*.jar”].each do |jar|

arnaud


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

The problem may be with how classpaths are organized. If you have
something on the system classpath (like through env var) and then try to
load jar files, the env-var-classpath class won’t see those jars. The
jar files loaded at runtime live at a deeper classloader level. The way
to avoid this is to load everything at runtime through JRuby.

Does that fit your circumstance?

Arnaud G. wrote:

Hello list,
require File.expand_path(jar)
arnaud


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

I thought about this, but I have no sytem classpath in my env… But
using this strategy (setting the classpath env and add jar files and
java classes folder) works before launching jruby…

But I thought that using require ‘myjarfile’ add the jar file to the
java classpath and since my classes were at the same level of my ruby
file was enough… (I also try to add the . level to $LOAD_PATH using
FILE …, because it seems that there is a difference bettween the
working directory and the current ruby file… anyway $LOAD_PATH seems
different to the java classpath)

->But if you talk about classloading I would like to know if you have
a minute the hierachy of jruby classloading strategy ? I am a bit lost
beetwen java classpath env, $LOAD_PATH, using require and so on…

->And if you have another minute ;-), can you please tell me how to
load everything a jruby runtime … I mean adding a folder and not the
jar files since I thought it is just done with require ‘my path to a
jar file’

thanks
arnaud

2009/2/6 Charles Oliver N. [email protected]:

Well, after lot of investigation it seems that the problem is when a

Hello list,
require File.expand_path(jar)
arnaud


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