I am trying to deploy a simple rails app on glassfish v3 using jdk6 u18,
jruby 1.4.0 and it gives
/tools/jruby-1.4.0/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:271:in
require_frameworks': library
socket’ could not be loaded:
java.lang.LinkageError: loader (instance of java/net/URLClassLoader):
attempted duplicate class definition for name:
“org/jruby/ext/socket/RubySocket” (RuntimeError)
from
/tools/jruby-1.4.0/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:134:in
process' from /tools/jruby-1.4.0/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:113:in
run’
from /myhome/vivekmz/dev/depot/config/environment.rb:13
from /myhome/vivekmz/dev/depot/config/environment.rb:31:in `require’
My understanding of “LinkageError:attempted duplicate class definition
for
name:” tells that it might be the race condition in URLClassLoader that
might be causing this. For example, multiple threads are asking a
ClassLoader.findClass() to load a class and if findClass() is not
synchronized there is chance that one thread is already loaded the class
and
second thread’s call to ClassLoader.findClass() load the same class
resulting in to this error. I am not sure what fixes went in to jdk6 u18
thats causing it.
Another detail is that glassfish gem or webrick works just fine with it.
Its
only in the glassfish v3 server environment which has osgi runtime this
error happens. On glassfish side we will continue to investigate. Can
JRuby
experts shed some light on this kind of error and how JRuby loads rails?
Here is the reference to the discussion on glassfish forum:
Developer Community - Oracle Forums.
-vivek.