JRuby加载路径搞砸了

时间:2011-03-31 14:28:41

标签: jar websphere jruby load-path

我在一个JAR文件上嵌入了JRuby,它正被我部署到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文件中的代码时,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
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的外观:

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内部运行时加载路径损坏的原因以及如何修复它?

1 个答案:

答案 0 :(得分:3)

尝试将以下内容添加到$ 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