LoadError: no such file to load -- jruby-win32ole

Dear friends,

I newest in JRuby/Ruby and I’m very enjoy with it, but the last simple
test is not working when it is executed by java and I need help to find
what is happen exactly, because when I execute the ruby script file
directly by RUBY or by JRUBY commands all is fine, but when I try to be
executed by java shows this error if the require parameter contains
‘jquery-win32ole’

LoadError: no such file to load – jruby-win32ole
require at org/jruby/RubyKernel.java:1054
require at
jar:file:/C:/Users/accampos/.m2/repository/org/jruby/jruby-complete/1.7.4/jruby-complete-1.7.4.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:36
(root) at
C:/DEV/test/jruby-test/src/main/ruby/customer_class_selector.rb:1
require at org/jruby/RubyKernel.java:1054
(root) at
jar:file:/C:/Users/accampos/.m2/repository/org/jruby/jruby-complete/1.7.4/jruby-complete-1.7.4.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:1
require at
jar:file:/C:/Users/accampos/.m2/repository/org/jruby/jruby-complete/1.7.4/jruby-complete-1.7.4.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:36
Exception in thread “main” org.jruby.embed.EvalFailedException:
(LoadError) no such file to load – jruby-win32ole
at
org.jruby.embed.internal.EmbedEvalUnitImpl.run(EmbedEvalUnitImpl.java:133)
at
org.jruby.embed.ScriptingContainer.runUnit(ScriptingContainer.java:1264)
at
org.jruby.embed.ScriptingContainer.runScriptlet(ScriptingContainer.java:1257)
at JRubyTest.getCustomerClass(JRubyTest.java:18)
at JRubyTest.main(JRubyTest.java:71)
Caused by: org.jruby.exceptions.RaiseException: (LoadError) no such file
to load – jruby-win32ole
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1054)
at
RUBY.require(jar:file:/C:/Users/accampos/.m2/repository/org/jruby/jruby-complete/1.7.4/jruby-complete-1.7.4.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:36)
at
RUBY.(root)(C:/DEV/test/jruby-test/src/main/ruby/customer_class_selector.rb:1)
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1054)
at
RUBY.(root)(jar:file:/C:/Users/accampos/.m2/repository/org/jruby/jruby-complete/1.7.4/jruby-complete-1.7.4.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:1)
at
RUBY.require(jar:file:/C:/Users/accampos/.m2/repository/org/jruby/jruby-complete/1.7.4/jruby-complete-1.7.4.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:36)

and shows this error if the require parameter is ‘win32ole’

!!! Missing jruby-win32ole gem: jruby -S gem install jruby-win32ole
LoadError: no such file to load – jruby-win32ole
require at org/jruby/RubyKernel.java:1054
require at
jar:file:/C:/Users/accampos/.m2/repository/org/jruby/jruby-complete/1.7.4/jruby-complete-1.7.4.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:36
(root) at
jar:file:/C:/Users/accampos/.m2/repository/org/jruby/jruby-complete/1.7.4/jruby-complete-1.7.4.jar!/META-INF/jruby.home/lib/ruby/shared/jruby/win32ole/stub.rb:3
require at org/jruby/RubyKernel.java:1054
(root) at
jar:file:/C:/Users/accampos/.m2/repository/org/jruby/jruby-complete/1.7.4/jruby-complete-1.7.4.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:1
require at
jar:file:/C:/Users/accampos/.m2/repository/org/jruby/jruby-complete/1.7.4/jruby-complete-1.7.4.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:36
require at org/jruby/RubyKernel.java:1054
(root) at
C:/DEV/test/jruby-test/src/main/ruby/customer_class_selector.rb:2
(root) at
jar:file:/C:/Users/accampos/.m2/repository/org/jruby/jruby-complete/1.7.4/jruby-complete-1.7.4.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:1
Exception in thread “main” org.jruby.embed.EvalFailedException:
(LoadError) no such file to load – jruby-win32ole
at
org.jruby.embed.internal.EmbedEvalUnitImpl.run(EmbedEvalUnitImpl.java:133)
at
org.jruby.embed.ScriptingContainer.runUnit(ScriptingContainer.java:1264)
at
org.jruby.embed.ScriptingContainer.runScriptlet(ScriptingContainer.java:1257)
at JRubyTest.getCustomerClass(JRubyTest.java:18)
at JRubyTest.main(JRubyTest.java:71)
Caused by: org.jruby.exceptions.RaiseException: (LoadError) no such file
to load – jruby-win32ole
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1054)
at
RUBY.require(jar:file:/C:/Users/accampos/.m2/repository/org/jruby/jruby-complete/1.7.4/jruby-complete-1.7.4.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:36)
at
RUBY.(root)(jar:file:/C:/Users/accampos/.m2/repository/org/jruby/jruby-complete/1.7.4/jruby-complete-1.7.4.jar!/META-INF/jruby.home/lib/ruby/shared/jruby/win32ole/stub.rb:3)
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1054)
at
RUBY.(root)(jar:file:/C:/Users/accampos/.m2/repository/org/jruby/jruby-complete/1.7.4/jruby-complete-1.7.4.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:1)
at
RUBY.require(jar:file:/C:/Users/accampos/.m2/repository/org/jruby/jruby-complete/1.7.4/jruby-complete-1.7.4.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:36)
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1054)
at
RUBY.(root)(C:/DEV/test/jruby-test/src/main/ruby/customer_class_selector.rb:2)
at
RUBY.(root)(jar:file:/C:/Users/accampos/.m2/repository/org/jruby/jruby-complete/1.7.4/jruby-complete-1.7.4.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:1)

The strange for me because I used the jruby-complete-1.7.4 in the java
enironment and how I said, it’s executed fine by commands [ jruby | ruby
]

the java code is simple:

ScriptingContainer container = new
ScriptingContainer(LocalContextScope.THREADSAFE);

    container.setLoadPaths(Arrays.asList("C:/DEV/test/jruby-test/src/main/ruby"));

    container.runScriptlet("require 'customer_class_selector'");

    Object greeter =

container.runScriptlet(“CustomerClassSelector.new”);

    @SuppressWarnings("unchecked")
  List<Object> customerClass = container.callMethod(greeter,

“get_list”, List.class);

But, it fails in java when it parse the require library!

Any idea?
Thanks in advance

jruby-win32ole gem is not included in jruby-complete.jar. You need to
install it as a gem in a location that jruby-complete.jar can see.

-Tom

Thanks a lot Tom, it was I thought and this morning looking for the
win32ole.jar in my computer (it’s inside of gems folder into the
jbuilder installation) and added to my project. But it has several
problems with racob integration (dll in the first case and jar in the
second case) …

Exists any method more clean to add win32ole capabilities into a Java
project thast uses JRuby?

Maybe I’m doing something worng but my first impression is that it’s not
finnished, because to add win32ole feature I required to add the gem
directly as a local repository (I’m using maven) and also, the reference
to the DLL’s in the ruby file jruby-win32ole.rb into the win32ole.jar
have problems to load the racob requisite… may be I’m in the wrong
way and exists another method to add this features to my project.

Could anyone illuminate to me ?

Thanks in advance

Finally , if I remove the win32ole.jar (it is not required because the
*.java classes are in the source directory to be compiled, and the rest
of sources from ruby are in the same lib folder) the error is other…

====================================
C:\DEV\test\jruby-test>java -cp
C:/ide/jruby-1.7.4/lib/jruby.jar;./vendor/gems/jruby-win32ole-0.8.5/lib;./vendor/gems/jruby-win32ole-0.8.5/lib/racob.jar;./src/main/ruby/customer_class_selector.rb;./vendor/
org.jruby.Main ./src/main/ruby/customer_class_selector.rb

LoadError: no such file to load – win32/registry
require at org/jruby/RubyKernel.java:1054
(root) at
C:/DEV/test/jruby-test/vendor/gems/jruby-win32ole-0.8.5/lib/win32ol
e/win32ole_typelib.rb:1
require at org/jruby/RubyKernel.java:1054
(root) at
C:/DEV/test/jruby-test/vendor/gems/jruby-win32ole-0.8.5/lib/jruby-w
in32ole.rb:1
require at org/jruby/RubyKernel.java:1054
(root) at ./src/main/ruby/customer_class_selector.rb:1

…nobody test it before from java integration or what I’m doing wrong?
Thanks in advance for your time and effors to help me
Antonio

Let’s say you have a project structure like this:

project_root
|
|----lib
| |
| |–a_script.rb
|
|----vendor
|
|----jruby_complete.jar

A project_root/ folder. Inside the project_root is a folder lib, and
inside
lib is a single script, a_script.rb. We’ve also created an empty folder
in
project_root called vendor. Finally, directly inside project_root we
have
jruby_complete.jar.

Then you can try :

$ jruby -S gem install -i vendor jruby-win32ole

The -i tells the gem command we are telling it where to install the gem
at,
so it will install it locally, along with everything ruby needs to use
it.

$ ls vendor
cache doc gems specifications

As you see, it created 4 directories inside vendor. This is one reason
why
simply copying the gem from your local rubys gem dir wont work.

Now, to run this via the jruby_complete.jar, we do:

$ java -cp .:jruby-complete.jar:./lib/a_script.rb:./vendor/
org.jruby.Main ./lib/a_script.rb

We make sure everything is on javas classpath (Im not sure, on Windows,
you may need to use a different separator between classpath items. On
Ubuntu it is :), then we call jruby’s Main on our script. Hope this
helps.

Ok, I did the same with the win32-api into the vendor folder (DevKit +
MinGW installed to proceed to install win32-api correctly) …
But I can’t see any folder strcuture or folder+file according with
require ‘win32/registry’

??? any idea

Thanks a lot Tom…

I did your steps and I have now a project with the installed
jruby-win32ole into the vendor folder and I executed directly your
proposition by command line, but …

====================================
C:\DEV\test\jruby-test>java -cp
C:/ide/jruby-1.7.4/lib/jruby.jar;./src/main/ruby/customer_class_selector.rb;./vendor/
org.jruby.Main ./src/main/ruby/customer_cl
ass_selector.rb

LoadError: no such file to load – jruby-win32ole
require at org/jruby/RubyKernel.java:1054
(root) at ./src/main/ruby/customer_class_selector.rb:1

Then I added the jars into the classpath, but …

C:\DEV\test\jruby-test>java -cp
C:/ide/jruby-1.7.4/lib/jruby.jar;./vendor/gems/jruby-win32ole-0.8.5/lib/win32ole/win32ole.jar;./vendor/gems/jruby-win32ole-0.8.5
/lib/racob.jar;./src/main/ruby/customer_class_selector.rb;./vendor/
org.jruby.Main ./src/main/ruby/customer_class_selector.rb

LoadError: no such file to load – racob
require at org/jruby/RubyKernel.java:1054
(root) at
file:/C:/DEV/test/jruby-test/vendor/gems/jruby-win32ole-0.8.5/lib/w
in32ole/win32ole.jar!/jruby-win32ole.rb:8
require at org/jruby/RubyKernel.java:1054
(root) at ./src/main/ruby/customer_class_selector.rb:1

I added it into the project classpath (in Eclipse) and Also, I added the
racob.jar and win32ole.jar contained inside, and also I added the *.java
classes from the source to be compiled in my project.

But the error continues:

LoadError: no such file to load – racob
require at org/jruby/RubyKernel.java:1054
(root) at
file:/C:/DEV/test/jruby-test/vendor/gems/jruby-win32ole-0.8.5/lib/win32ole/win32ole.jar!/jruby-win32ole.rb:8
require at org/jruby/RubyKernel.java:1054
(root) at
C:/DEV/test/jruby-test/src/main/ruby/customer_class_selector.rb:1
require at org/jruby/RubyKernel.java:1054
(root) at
C:/DEV/test/jruby-test/src/main/ruby/customer_class_selector.rb:1
Exception in thread “main” org.jruby.embed.EvalFailedException:
(LoadError) no such file to load – racob
at
org.jruby.embed.internal.EmbedEvalUnitImpl.run(EmbedEvalUnitImpl.java:133)
at
org.jruby.embed.ScriptingContainer.runUnit(ScriptingContainer.java:1264)
at
org.jruby.embed.ScriptingContainer.runScriptlet(ScriptingContainer.java:1257)
at JRubyTest.getCustomerClass(JRubyTest.java:18)
at JRubyTest.main(JRubyTest.java:71)
Caused by: org.jruby.exceptions.RaiseException: (LoadError) no such file
to load – racob
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1054)
at
RUBY.(root)(file:/C:/DEV/test/jruby-test/vendor/gems/jruby-win32ole-0.8.5/lib/win32ole/win32ole.jar!/jruby-win32ole.rb:8)
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1054)
at
RUBY.(root)(C:/DEV/test/jruby-test/src/main/ruby/customer_class_selector.rb:1)
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1054)
at
RUBY.(root)(C:/DEV/test/jruby-test/src/main/ruby/customer_class_selector.rb:1)

Any idea? it’s working in your computer?
Antonio

If you set up a GEM_DIR (or I have even seen people open up
jruby-complete.jar and gem install and make a new one) environment
variable
and jruby -S gem install jruby-win32ole and then make sure your
environment
has that GEM_DIR setting then it should find and load this gem. This is
how the windows installer works. We don’t do anything more than just
installing the gem.

I am not sure why the vendor’ing method is not working for you…or do I
hmm it might have something to do with racob being a JNI extension and
as
such it needs java.library.path set to the racob.dll.

Either path (extra GEM directory or fixing vendored solution) will
require
setting up some environment setting.

-Tom

Ok, I think that I uninstall all my jruby and ruby and start again with
a clean installation (only jruby)… have a nice weekend, more news on
Monday :stuck_out_tongue: thanks for all.

-Antonio

With a clean installation (only jruby without ruby installed) was
fine…although I couldn’t compile the C extensions in Windows from the
source (I prefer always to compile the sources), I installed the binary
package and all was fine in the first execution. You was right,
something was wrong in the environment execution.

Thanks a lot Tom for your help,
Have a nice day