我的Spring Boot JRuby应用程序中存在间歇性问题 - 此代码在外部ruby文件上执行脚本引擎eval()
//get jruby engine ScriptEngine jruby = new ScriptEngineManager().getEngineByName("jruby"); //process a ruby file jruby.eval(new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/ruby/myscript.rb")))); //call a method defined in the ruby source jruby.put("score", score); jruby.put("message_id", messageId); jruby.put("sourcedid", sourcedId); jruby.put("key", key); jruby.put("secret", secret); jruby.put("lis_outcome_service_url", lisOutcomeServiceUrl); String res = (String) jruby.eval("postScore($score, $message_id, $sourcedid, $key, $secret, $lis_outcome_service_url)");
它在大多数时间返回成功结果但偶尔我得到文件未找到io错误,特别是当代码被快速连续多次调用时
OpenSSL::SSL::SSLError: problem creating X509 Aux certificate: java.io.IOException
setup at org/jruby/ext/openssl/SSLContext.java:229
initialize at org/jruby/ext/openssl/SSLSocket.java:145
connect at jar:file:/myproject/lib/jruby-complete-1.7.2.jar!/META-INF/jruby.home/lib/ruby/1.9/net/http.rb:776
do_start at jar:file:/myproject/lib/jruby-complete-1.7.2.jar!/META-INF/jruby.home/lib/ruby/1.9/net/http.rb:755
start at jar:file:/myproject/lib/jruby-complete-1.7.2.jar!/META-INF/jruby.home/lib/ruby/1.9/net/http.rb:744
request at jar:file:/myproject/lib/jruby-complete-1.7.2.jar!/META-INF/jruby.home/lib/ruby/1.9/net/http.rb:1292
request at jar:file:/myproject/lib/oauth-gems.jar!/gems/oauth-0.5.0/lib/oauth/consumer.rb:161
request at jar:file:/myproject/lib/oauth-gems.jar!/gems/oauth-0.5.0/lib/oauth/tokens/consumer_token.rb:25
request at jar:file:/myproject/lib/oauth-gems.jar!/gems/oauth-0.5.0/lib/oauth/tokens/access_token.rb:12
post at jar:file:/myproject/lib/oauth-gems.jar!/gems/oauth-0.5.0/lib/oauth/tokens/access_token.rb:47
postScore at <script>:38
(root) at <script>:1
17:45:33.600 [http-nio-8080-exec-9] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is javax.script.ScriptException: org.jruby.embed.EvalFailedException: (OpenSSL::SSL::SSLError) problem creating X509 Aux certificate: java.io.IOException] with root cause
org.jruby.exceptions.RaiseException: (OpenSSL::SSL::SSLError) problem creating X509 Aux certificate: java.io.IOException
at org.jruby.ext.openssl.SSLContext.setup(org/jruby/ext/openssl/SSLContext.java:229) ~[na:na]
at org.jruby.ext.openssl.SSLSocket.initialize(org/jruby/ext/openssl/SSLSocket.java:145) ~[na:na]
at RUBY.connect(jar:file:/myproject/lib/jruby-complete-1.7.2.jar!/META-INF/jruby.home/lib/ruby/1.9/net/http.rb:776) ~[na:na]
at RUBY.do_start(jar:file:/myproject/lib/jruby-complete-1.7.2.jar!/META-INF/jruby.home/lib/ruby/1.9/net/http.rb:755) ~[na:na]
at RUBY.start(jar:file:/myproject/lib/jruby-complete-1.7.2.jar!/META-INF/jruby.home/lib/ruby/1.9/net/http.rb:744) ~[na:na]
at RUBY.request(jar:file:/myproject/lib/jruby-complete-1.7.2.jar!/META-INF/jruby.home/lib/ruby/1.9/net/http.rb:1292) ~[na:na]
at RUBY.request(jar:file:/myproject/lib/oauth-gems.jar!/gems/oauth-0.5.0/lib/oauth/consumer.rb:161) ~[na:na]
at RUBY.request(jar:file:/myproject/lib/oauth-gems.jar!/gems/oauth-0.5.0/lib/oauth/tokens/consumer_token.rb:25) ~[na:na]
at RUBY.request(jar:file:/myproject/lib/oauth-gems.jar!/gems/oauth-0.5.0/lib/oauth/tokens/access_token.rb:12) ~[na:na]
at RUBY.post(jar:file:/myproject/lib/oauth-gems.jar!/gems/oauth-0.5.0/lib/oauth/tokens/access_token.rb:47) ~[na:na]
at RUBY.postScore(<script>:38) ~[na:na]
at RUBY.(root)(<script>:1) ~[na:na]
想知道是否有人发过类似这样的事情?感谢您提出任何优化建议。
编辑:@kares。编辑: 感谢您的回复 - 我尝试升级jruby但我仍然遇到同样的错误。你有什么建议吗?现在我认为ruby文件存在竞争条件......Errno::EBADF: Bad file descriptor - Bad file descriptor
fcntl at org/jruby/RubyIO.java:2295y
fcntl at org/jruby/ext/openssl/SSL.java:248
initialize at org/jruby/ext/openssl/SSL.java:286
initialize at org/jruby/ext/openssl/SSLSocket.java:172
connect at /lms-integration/lib/jruby-complete-1.7.24.jar!/META-INF/jruby.home/lib/ruby/1.9/net/http.rb:777
do_start at /lms-integration/lib/jruby-complete-1.7.24.jar!/META-INF/jruby.home/lib/ruby/1.9/net/http.rb:756
start at /lms-integration/lib/jruby-complete-1.7.24.jar!/META-INF/jruby.home/lib/ruby/1.9/net/http.rb:745
request at /lms-integration/lib/jruby-complete-1.7.24.jar!/META-INF/jruby.home/lib/ruby/1.9/net/http.rb:1293
request at /lms-integration/lib/oauth-gems.jar!/gems/oauth-0.5.0/lib/oauth/consumer.rb:161
request at /lms-integration/lib/oauth-gems.jar!/gems/oauth-0.5.0/lib/oauth/tokens/consumer_token.rb:25
request at /lms-integration/lib/oauth-gems.jar!/gems/oauth-0.5.0/lib/oauth/tokens/access_token.rb:12
post at /lms-integration/lib/oauth-gems.jar!/gems/oauth-0.5.0/lib/oauth/tokens/access_token.rb:47
postScore at <script>:38
(root) at <script>:1
19:13:06.489 [http-nio-8080-exec-7] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is javax.script.ScriptException: org.jruby.embed.EvalFailedException: (Errno::EBADF) Bad file descriptor] with root cause
org.jruby.exceptions.RaiseException: (Errno::EBADF) Bad file descriptor
at org.jruby.RubyIO.fcntl(org/jruby/RubyIO.java:2295) ~[jruby-complete-1.7.24.jar:na]
at org.jruby.ext.openssl.SSL$SocketForwarder.fcntl(org/jruby/ext/openssl/SSL.java:248) ~[na:na]
at org.jruby.ext.openssl.SSL$Nonblock.initialize(org/jruby/ext/openssl/SSL.java:286) ~[na:na]
at org.jruby.ext.openssl.SSLSocket.initialize(org/jruby/ext/openssl/SSLSocket.java:172) ~[na:na]
at RUBY.connect(/lms-integration/lib/jruby-complete-1.7.24.jar!/META-INF/jruby.home/lib/ruby/1.9/net/http.rb:777) ~[na:na]
at RUBY.do_start(/lms-integration/lib/jruby-complete-1.7.24.jar!/META-INF/jruby.home/lib/ruby/1.9/net/http.rb:756) ~[na:na]
at RUBY.start(/lms-integration/lib/jruby-complete-1.7.24.jar!/META-INF/jruby.home/lib/ruby/1.9/net/http.rb:745) ~[na:na]
at RUBY.request(/lms-integration/lib/jruby-complete-1.7.24.jar!/META-INF/jruby.home/lib/ruby/1.9/net/http.rb:1293) ~[na:na]
at RUBY.request(/lms-integration/lib/oauth-gems.jar!/gems/oauth-0.5.0/lib/oauth/consumer.rb:161) ~[na:na]
at RUBY.request(/lms-integration/lib/oauth-gems.jar!/gems/oauth-0.5.0/lib/oauth/tokens/consumer_token.rb:25) ~[na:na]
at RUBY.request(/lms-integration/lib/oauth-gems.jar!/gems/oauth-0.5.0/lib/oauth/tokens/access_token.rb:12) ~[na:na]
at RUBY.post(/lms-integration/lib/oauth-gems.jar!/gems/oauth-0.5.0/lib/oauth/tokens/access_token.rb:47) ~[na:na]
at RUBY.postScore(<script>:38) ~[na:na]
at RUBY.(root)(<script>:1) ~[na:na]
答案 0 :(得分:0)
正如在JRuby的IRC上所建议的那样,这是一个相当古老的JRuby 1.7.x版本(最新版本是在创建此答案时的1.7.24)。一个相当新的JRuby-OpenSSL版本不应该有这个问题。
P.S。如果您打算在IRC上询问与此处相同的内容,请附上链接。