JRuby 加载路径混乱
我将 JRuby 嵌入到 JAR 文件中,并由我部署到 WebSphere 的 EAR 文件使用。当我从工作区调用该类时,它工作正常,但是当我在 WebSphere 中调用它时,我得到的结果如下:
[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 文件中的代码时,加载路径看起来像像这样:
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 捆绑在一起)之后,加载路径如下所示:
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
.
我尝试向加载路径添加更多条目:
制作:
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 中运行时会损坏以及如何修复它吗?
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
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
.
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:
Making it:
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
.
But that didn't make any change.
Do you have any clue why the loadpath gets corrupted when running inside WebSphere and how to fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将以下内容添加到 $LOAD_PATH:
Try adding the following to $LOAD_PATH: