JRuby eval() OpenSSL::SSL::SSLError: creating X509 Aux certificate: java.io.IOException
<p>I'm having intermittent problems in my Spring Boot JRuby app -this code does a scripting engine eval() on an external ruby file</p>

<blockquote>
<pre><code>    //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)");
</code></pre>
</blockquote>

<p>It returns success result majority of the time but occasionally i get file not found io error, especially when the code is called multiple times in quick succession</p>

<pre><code>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 &lt;script&gt;:38
      (root) at &lt;script&gt;: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(&lt;script&gt;:38) ~[na:na]
    at RUBY.(root)(&lt;script&gt;:1) ~[na:na]
</code></pre>

<p>Wondering if anyone has dealt w something like this?  Thanks for any suggestions for optimization.</p>

<p>EDIT:  @kares
Thank you for responding- I've tried upgrading jruby but I still get the same error.  Do you have any suggestions?  Right now I think there is a race condition for the ruby file...</p>

<pre><code>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 &lt;script&gt;:38
      (root) at &lt;script&gt;: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(&lt;script&gt;:38) ~[na:na]
    at RUBY.(root)(&lt;script&gt;:1) ~[na:na]
</code></pre>