JRuby wrong element type class java.lang.String(array contains char) related to JAVA_HOME
- by Daryl
I am on Ubuntu x64 bit running:
java version "1.6.0_18"
OpenJDK Runtime Environment (IcedTea6 1.8) (6b18-1.8-0ubuntu1)
OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)
and
jruby 1.4.0 (ruby 1.8.7 patchlevel 174) (2010-02-11 6586) (OpenJDK 64-Bit Server VM 1.6.0_18) [amd64-java]
I have this code running on my Windows 7 computer at home. I recently copied over my whole folder over to Ubuntu, installed java, jruby, and associated gems but I get this error when I run my main file:
jruby run.rb test
=================Processing FREDERICKSBURG_1.1=======================
ERROR IN TESTING wrong element type class java.lang.String(array contains char)
/home/daryl/Desktop/work/Code/geografikos/lib/sentence_splitter/splitter.rb:21:in `to_java'
/home/daryl/Desktop/work/Code/geografikos/lib/sentence_splitter/splitter.rb:21:in `split'
/home/daryl/Desktop/work/Code/geografikos/lib/models/page.rb:103:in `sentences'
/home/daryl/Desktop/work/Code/geografikos/lib/extractor/lingpipe_svm.rb:34:in `extract'
/home/daryl/Desktop/work/Code/geografikos/lib/extractor/geo_controller.rb:9:in `process'
/home/daryl/Desktop/work/Code/geografikos/lib/extractor/geo_controller.rb:8:in `each'
/home/daryl/Desktop/work/Code/geografikos/lib/extractor/geo_controller.rb:8:in `process'
/home/daryl/Desktop/work/Code/geografikos/lib/extractor/geo_controller.rb:6:in `each'
/home/daryl/Desktop/work/Code/geografikos/lib/extractor/geo_controller.rb:6:in `process'
/home/daryl/Desktop/work/Code/geografikos/lib/statistics.rb:111:in `generate_all'
/home/daryl/Desktop/work/Code/geografikos/lib/statistics.rb:105:in `each'
/home/daryl/Desktop/work/Code/geografikos/lib/statistics.rb:105:in `generate_all'
run.rb:56
The focus of the error is:
ERROR IN TESTING wrong element type class java.lang.String(array contains char)
Everything works fine on my windows machine. I figured I was getting this error because I did not have JAVA_HOME set however I added this to bashrc as:
export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk
and have confirmed:
echo $JAVA_HOME
/usr/lib/jvm/java-1.6.0-openjdk
I can produce a similar error by removing my JAVA_HOME variable on windows:
=================Processing FREDERICKSBURG_1.3=======================
ERROR IN TESTING cannot convert instance of class org.jruby.RubyString to char
C:/work/Code/geografikos/lib/sentence_splitter/splitter.rb:21:in `to_java'
C:/work/Code/geografikos/lib/sentence_splitter/splitter.rb:21:in `split'
C:/work/Code/geografikos/lib/models/page.rb:103:in `sentences'
C:/work/Code/geografikos/lib/extractor/lingpipe_svm.rb:34:in `extract'
C:/work/Code/geografikos/lib/extractor/geo_controller.rb:9:in `process'
C:/work/Code/geografikos/lib/extractor/geo_controller.rb:8:in `each'
C:/work/Code/geografikos/lib/extractor/geo_controller.rb:8:in `process'
C:/work/Code/geografikos/lib/extractor/geo_controller.rb:6:in `each'
C:/work/Code/geografikos/lib/extractor/geo_controller.rb:6:in `process'
C:/work/Code/geografikos/lib/statistics.rb:111:in `generate_all'
C:/work/Code/geografikos/lib/statistics.rb:105:in `each'
C:/work/Code/geografikos/lib/statistics.rb:105:in `generate_all'
run.rb:56
It is obviously not exactly the same but I have a feeling this has to do with the java path. You can probably derive from the error that I am just trying to convert a ruby variable to java using to_java. This works fine on my windows machine and I have confirmed the gems are the same but I don't think this has to do with gems.
I lied. I changed my JAVA_HOME back on my windows machine and this error still occurs. So now the code doesn't run on either machine. I recently installed git on my windows machine and added the code to a repository. But I haven't really done anything with it. All it said was it will convert all LF to CRLF...That shouldn't change anything though should it? Any ideas on why I am now getting these errors? I haven't changed anything on my windows machine in months except for installing git.