Thrift gem and JRuby

半世苍凉 提交于 2019-12-11 01:28:05

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/3712531/thrift-gem-and-jruby

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!