Thrift gem 和 JRuby
我最近在 MRI 中使用 JRuby 和 Thrift gem 后才安装了它。我遇到了一个问题,如果我需要“thrift”,我会收到消息“无法加载 thrift_native 扩展。默认为纯 Ruby 库。”如果我随后尝试要求在 ruby 中生成的代码 thrift,我将收到此错误:“NameError: uninitializedconst Thrift::Struct_Union”
thrift gem 目前无法与 JRuby 一起使用吗?
除了使用 gem 之外,我还能做些什么来将 thrift 与 JRuby 结合使用吗?
编辑:在我的 mac 上进行研究后,我发现 MRI gem 和 JRuby gem 是不同的,尽管 gem 的版本相同(0.2.0.4)。现在这似乎是一个糟糕的主意,但如果您将 .rb 文件从 MRI gem 复制到 JRuby gem 并将 require 'thrift/struct_union'
添加到 thrift.rb,您将不再收到任何错误与 Thrift gem 相关,只是它找不到 thirft_native 并且将使用纯 Ruby 库。这是可以解释的,因为 thrift_native 是为 C 而不是 Java 设计的。
I just recently installed JRuby and the Thrift gem after using it in MRI. I'm running into a problem where if I require 'thrift' I get the message "Unable to load thrift_native extension. Defaulting to pure Ruby libraries." If I then try and require the code thrift generated in ruby I'll get this error: "NameError: uninitialized constant Thrift::Struct_Union"
Is the thrift gem currently not working with JRuby?
Is there something I can do to use thrift with JRuby besides using the gem?
EDIT: After digging around on my mac, I found that the MRI gem and JRuby gem are different even though the gems are the same version (0.2.0.4). Now this seems like a terrible idea, but if you copy the .rb files from the MRI gem into the JRuby gem and add require 'thrift/struct_union'
to thrift.rb you will no longer get any errors related to the Thrift gem except that it can't find thirft_native and will use pure Ruby libraries. This can be explained since thrift_native is made for C not Java.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您已经在使用 JRuby 时,我会使用 Java 本机 thrift 客户端。对我来说,节俭是迁移到 JRuby 的首要原因,因为 Ruby 实现相当缓慢且存在错误。
When you're already using JRuby, I would use a Java native thrift client. For me, thrift was the reason for moving to JRuby in the first place, since the Ruby implementation is rather slow and buggy.