JRuby 加载路径混乱

发布于 2024-10-29 21:31:05 字数 1652 浏览 10 评论 0原文

我将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

羁〃客ぐ 2024-11-05 21:31:05

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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文