JRuby加载路径搞砸了 [英] JRuby loadpath messed up
问题描述
我在一个JAR文件上嵌入了JRuby,它正被我部署到WebSphere的EAR文件使用。当我从我的工作区调用该类时,它工作正常,但是当我在WebSphere中调用它时,这就是我得到的:
I am embedding JRuby on a JAR file and it's being used by a EAR file that I am deploying to WebSphere. When I call the class from my workspace, it works fine, however when I call it inside WebSphere, here's what I get:
[3/31/11 11:21:15:984 BRT] 00000042 SystemErr R classpath:/lib/xmlcompare.rb:4:in `require': no such file to load -- rubygems (LoadError)
from classpath:/lib/xmlcompare.rb:4
from classpath:/lib/xmlcompare.rb:1:in `require'
from <script>:1
经过一些研究,我注意到当我从命令行运行JAR文件中的代码时,loadpath看起来像这样:
After some research, I noticed that when I run the code in the JAR file from the command line, the loadpath looks like this:
lib
lib/gems/builder-3.0.0/lib
lib/gems/rainbow-1.1.1/lib
lib/gems/syntax-1.0.0/lib
lib/gems/xml-simple-1.0.14/lib
file:/C:/RSA/workspace/sdops-XmlCompare/pkg/XmlCompare.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8
file:/C:/RSA/workspace/sdops-XmlCompare/pkg/XmlCompare.jar!/META-INF/jruby.home/lib/ruby/site_ruby/shared
file:/C:/RSA/workspace/sdops-XmlCompare/pkg/XmlCompare.jar!/META-INF/jruby.home/lib/ruby/1.8
.
然而,在将JAR部署到WebSphere(与EAR捆绑在一起)之后,这里是loadpath的外观:
However, after the JAR is deployed to WebSphere (bundled with an EAR), here's how the loadpath looks:
lib
lib/gems/builder-3.0.0/lib
lib/gems/rainbow-1.1.1/lib
lib/gems/syntax-1.0.0/lib
lib/gems/xml-simple-1.0.14/lib
C:/WINDOWS/TEMP//lib/ruby/site_ruby/1.8
C:/WINDOWS/TEMP//lib/ruby/site_ruby/shared
C:/WINDOWS/TEMP//lib/ruby/1.8
.
我尝试在加载路径中添加更多条目:
I have tried adding a few more entries to the loadpath:
制作:
lib
lib/gems/builder-3.0.0/lib
lib/gems/rainbow-1.1.1/lib
lib/gems/syntax-1.0.0/lib
lib/gems/xml-simple-1.0.14/lib
META-INF/lib/ruby/site_ruby/1.8
META-INF/lib/ruby/site_ruby/shared
META-INF/lib/ruby/1.8
C:/WINDOWS/TEMP//lib/ruby/site_ruby/1.8
C:/WINDOWS/TEMP//lib/ruby/site_ruby/shared
C:/WINDOWS/TEMP//lib/ruby/1.8
.
但这没有任何改变。
你有什么线索在WebSphere内部运行时加载路径被破坏以及如何修复它?
Do you have any clue why the loadpath gets corrupted when running inside WebSphere and how to fix it?
推荐答案
尝试将以下内容添加到$ LOAD_PATH:
Try adding the following to $LOAD_PATH:
META-INF/jruby.home/lib/ruby/site_ruby/1.8
META-INF/jruby.home/lib/ruby/site_ruby/shared
META-INF/jruby.home/lib/ruby/1.8
这篇关于JRuby加载路径搞砸了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!