import' from (irb):6 from /usr/local/bin/irb:12:in
Closed lramach closed 11 years ago
Thanks for replying Louis! Yes, I did look at both of those threads!
Both 'java -version' and 'javac -version' turn up 1.6.0_31.
I checked the class files for jars joda-time, xom, stanford-corenlp and they were all compiled using 1.5, and bridge with 1.6. And I read that the jvm version running should be the same or greater than the version of the jars. So this seems to be fine.
My JAVA_HOME has been set as: JAVA_HOME' => "/usr/lib/jvm/java-1.6.0-sun-1.6.0.31/jre/ The problem is not likely to be with this, since I managed to install rjb with this path.
Could rjb still be picking up some other version of jdk? I can't understand how that is possible. I am not sure how to check this even.
When you installed Rjb, did you use the exact same procedure you're now using before running the gem?
Rjb suggests in their install doc that on Linux, you need to "set LD_LIBRARY_PATH to point to j2se shared objects explicitly." For an sh bash, they say to do the following:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JAVA_HOME/jre/lib/i386:$JAVA_HOME/jre/lib/i386/client
However, that's a bit weird because it runs successfully both on my Linux box (Ubuntu 11) and on the Travis CI servers (Ubuntu 12) with just setting JAVA HOME. I don't think that's the problem unless you specifically needed to set LD_LIBRARY_PATH to install Rjb successfully.
Does the error happen when you run the gem outside of rails?
If it works outside of Rails, you might have an issue with Rjb making assumptions based on the Rails environment. For Rails, the Rjb doc states that on RoR, which it looks like you're using, you need to set:
ENV['JAVA_HOME'] = "/usr/java/jdk1.5.0_09"
ENV['LD_LIBRARY_PATH'] = "#{ENV['LD_LIBRARY_PATH']}:#{ENV['JAVA_HOME]}/jre/lib/i386:"
Otherwise, are you able to create an Rjb instance from scratch outside of stanford-core-nlp alltogether?
require 'rjb'
Point = Rjb::import('java.awt.Point')
p = Point.new(0, 0)
p.y = 80
puts "x=#{p.x}, y=#{p.y}" # => "0,80"
I had to fix JAVA_HOME in the .bashrc file!! That fixed it! Thanks for your help!
False alarm! I thought it did, but the issue hasn't been fixed yet! :(
I am getting a runtime error when I run Rjb::import RuntimeError: can't create Java VM from (irb):5:in `import' from (irb):5
Looks like JAVA_HOME has not been set correctly. I have set this in /root/.bashrc as export JAVA_HOME="/usr/lib/jvm/java-1.6.0-sun-1.6.0.31"
Where else would I have to set the environment variable?
What does "echo $JAVA_HOME" do in your console? And what does "puts ENV['JAVA_HOME']" output in the Ruby script?
You may need to do something like:
ENV['JAVA_HOME'] = "/usr/lib/jvm/java-1.6.0-sun-1.6.0.31" if ENV['JAVA_HOME'].nil?
If ENV['JAVA_HOME'] is empty (i.e. your path variable is not getting propagated).
Any news? I got a similar error recently while trying to deploy an app on a MT server, the Java VM could not be created because there was insufficient RAM on the server (512 mb). I fixed it by doing:
export JAVA_OPTS="-Xmx128m -Xms128m -XX:MaxPermSize=128m"
I am sorry for not reporting back. I have been busy with exams and grading. I will report back on this bug in a bit.
I am also getting RJB error as suggested and 'echo $JAVA_HOME' seems to return the right path /home/avinash/jdk1.6.0_38.
On irb am able to get output for irb(main):001:0> puts ENV['JAVA_HOME'] /home/avinash/jdk1.6.0_38 => nil
Kindly help me as am behind schedule for a delivery
irb(main):001:0> require 'stanford-core-nlp'
=> true
irb(main):002:0> StanfordCoreNLP.log_file = 'log.txt'
=> "log.txt"
irb(main):003:0> text = 'Angela Merkel met Nicolas Sarkozy on January 25th in '
=> "Angela Merkel met Nicolas Sarkozy on January 25th in "
irb(main):004:0> pipeline = StanfordCoreNLP.load(:tokenize, :ssplit, :pos, :lemma, :parse, :ner, :dcoref)
RuntimeError: can't create Java VM
from /usr/local/lib/ruby/gems/1.9.1/gems/bind-it-0.2.0/lib/bind-it/jar_loader.rb:19:in load' from /usr/local/lib/ruby/gems/1.9.1/gems/bind-it-0.2.0/lib/bind-it/jar_loader.rb:19:in
init'
from /usr/local/lib/ruby/gems/1.9.1/gems/bind-it-0.2.0/lib/bind-it/jar_loader.rb:36:in load' from /usr/local/lib/ruby/gems/1.9.1/gems/bind-it-0.2.0/lib/bind-it/binding.rb:56:in
load_jar'
from /usr/local/lib/ruby/gems/1.9.1/gems/bind-it-0.2.0/lib/bind-it/binding.rb:64:in block in load_default_jars' from /usr/local/lib/ruby/gems/1.9.1/gems/bind-it-0.2.0/lib/bind-it/binding.rb:61:in
each'
from /usr/local/lib/ruby/gems/1.9.1/gems/bind-it-0.2.0/lib/bind-it/binding.rb:61:in load_default_jars' from /usr/local/lib/ruby/gems/1.9.1/gems/bind-it-0.2.0/lib/bind-it/binding.rb:48:in
bind'
from /usr/local/lib/ruby/gems/1.9.1/gems/stanford-core-nlp-0.3.5/lib/stanford-core-nlp.rb:118:in load' from (irb):4 from /usr/local/bin/irb:12:in
import' from (irb):6 from /usr/local/bin/irb:12:in
Seems related to #13
I am not getting the rjb error anymore. Looks like JAVA_HOME has been set correctly now!
I had set JAVA_HOME in my deploy.rb file as set :default_environment, 'JAVA_HOME' => "/usr/lib/jvm/java-1.6.0-sun-1.6.0.31", which didn't seem to work.
I later set JAVA_HOME in the environment.rb file as ENV['JAVA_HOME'] = "/usr/lib/jvm/java-1.6.0-sun-1.6.0.31", and I think it worked, since I see the application running without throwing the UnsupportedClassVersionError.
Although now I am getting a different kind of error - a Rails Application Error - probably for a different forum to get help from!
Great! I am going to close this. Make sure you update to the latest version and files (released yesterday) for the latest bug fixes and patches (as well as JRuby support :-]).
Thanks for all the help Louis!
I am using the stanford-core-nlp gem for an educational application. I am running the application on RedHat Linux version 4. I installed java 6 since the gem depends on rjb, which has a java dependency. But when I run the app on the system I get the following error:
UnsupportedClassVersionError in Automated metareviewsController#list
Bad version number in .class file RAILS_ROOT: /local/rails/expertiza/releases/20121130014254
Application Trace | Framework Trace | Full Trace /local/rails/expertiza/shared/bundle/ruby/1.8/gems/bind-it-0.2.0/lib/bind-it/binding.rb:92:in
import' /local/rails/expertiza/shared/bundle/ruby/1.8/gems/bind-it-0.2.0/lib/bind-it/binding.rb:92:in
load_klass' /local/rails/expertiza/shared/bundle/ruby/1.8/gems/bind-it-0.2.0/lib/bind-it/binding.rb:82:inload_default_classes' /local/rails/expertiza/shared/bundle/ruby/1.8/gems/bind-it-0.2.0/lib/bind-it/binding.rb:80:in
each' /local/rails/expertiza/shared/bundle/ruby/1.8/gems/bind-it-0.2.0/lib/bind-it/binding.rb:80:inload_default_classes' /local/rails/expertiza/shared/bundle/ruby/1.8/gems/bind-it-0.2.0/lib/bind-it/binding.rb:49:in
bind' /local/rails/expertiza/shared/bundle/ruby/1.8/gems/stanford-core-nlp-0.3.0/lib/stanford-core-nlp.rb:103:inload' /local/rails/expertiza/releases/20121130014254/app/models/automated_metareview.rb:78:in
calculate_metareview_metrics' /local/rails/expertiza/releases/20121130014254/app/controllers/automated_metareviews_controller.rb:15:in `list'binding.rb contains a call to Rjb::import on line 92, where the error is being thrown.
The issue seems to have something to do with using different java versions. But I have set JAVA_HOME to java 1.6 and the jars/classes that the gem uses were compiled with java 1.5 or 1.6, so this should be fine shouldn't it? I can't seem to figure out what the problem is.
Any help would be greatly appreciated! Thanks!