I am having problems running a JRuby scripting container accessed by
multiple threads. Here’s my declaration:
protected static ScriptingContainer container = new
ScriptingContainer(LocalContextScope.THREADSAFE);
When I run my application which has multiple threads utilizing this
container, I often get java.lang.NoClassDefFoundError or other similar
exceptions soon after starting up. Not always, but often. And not always
the same class. Here are four different stack traces that I have seen:
==> stack-1.txt <==
org.jruby.embed.InvokeFailedException: (NameError) uninitialized
constant
Krypt::Provider::JDK
at
org.jruby.embed.internal.EmbedRubyObjectAdapterImpl.call(EmbedRubyObjectAdapterImpl.java:317)
~[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at
org.jruby.embed.internal.EmbedRubyObjectAdapterImpl.callMethod(EmbedRubyObjectAdapterImpl.java:169)
~[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at
org.jruby.embed.ScriptingContainer.callMethod(ScriptingContainer.java:1508)
~[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at com.needco.scrapers.JRubyScraper.init(JRubyScraper.java:43)
~[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at com.needco.scrapers.Scraper.scrape(Scraper.java:90)
[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at
com.needco.scrapers.ScraperProcessor.run(ScraperProcessor.java:108)
[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[?:1.7.0_71]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
[?:1.7.0_71]
at java.lang.Thread.run(Thread.java:745) [?:1.7.0_71]
Caused by: org.jruby.exceptions.RaiseException: (NameError)
uninitialized
constant Krypt::Provider::JDK
at
org.jruby.RubyModule.const_missing(org/jruby/RubyModule.java:2726)
~[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at
RUBY.(root)(/home/scraper/scrapers/nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/META-INF/jruby.home/lib/ruby/shared/krypt/core.rb:41)
~[?:?]
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1071)
~[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at
Kernel.require(/home/scraper/scrapers/nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:73)
~[?:?]
==> stack-2.txt <==
org.jruby.embed.InvokeFailedException: (LoadError) load error: kryptcore
java.lang.NoClassDefFoundError: org/jruby/ext/krypt/KryptCoreService
at
org.jruby.embed.internal.EmbedRubyObjectAdapterImpl.call(EmbedRubyObjectAdapterImpl.java:317)
~[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at
org.jruby.embed.internal.EmbedRubyObjectAdapterImpl.callMethod(EmbedRubyObjectAdapterImpl.java:169)
~[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at
org.jruby.embed.ScriptingContainer.callMethod(ScriptingContainer.java:1508)
~[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at com.needco.scrapers.JRubyScraper.init(JRubyScraper.java:43)
~[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at com.needco.scrapers.Scraper.scrape(Scraper.java:90)
[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at
com.needco.scrapers.ScraperProcessor.run(ScraperProcessor.java:108)
[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[?:1.7.0_71]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
[?:1.7.0_71]
at java.lang.Thread.run(Thread.java:745) [?:1.7.0_71]
Caused by: org.jruby.exceptions.RaiseException: (LoadError) load error:
kryptcore – java.lang.NoClassDefFoundError:
org/jruby/ext/krypt/KryptCoreService
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1071)
~[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at
Kernel.require(/home/scraper/scrapers/nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:55)
~[?:?]
at
Kernel.require(/home/scraper/scrapers/nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:53)
~[?:?]
at
RUBY.(root)(/home/scraper/scrapers/nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/META-INF/jruby.home/lib/ruby/shared/krypt/core.rb:37)
~[?:?]
==> stack-3.txt <==
org.jruby.embed.InvokeFailedException: (LoadError) load error: kryptcore
java.lang.NoClassDefFoundError: org/jruby/ext/krypt/helper/RubyHelper
at
org.jruby.embed.internal.EmbedRubyObjectAdapterImpl.call(EmbedRubyObjectAdapterImpl.java:317)
~[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at
org.jruby.embed.internal.EmbedRubyObjectAdapterImpl.callMethod(EmbedRubyObjectAdapterImpl.java:169)
~[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at
org.jruby.embed.ScriptingContainer.callMethod(ScriptingContainer.java:1508)
~[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at com.needco.scrapers.JRubyScraper.init(JRubyScraper.java:43)
~[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at com.needco.scrapers.Scraper.scrape(Scraper.java:90)
[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at
com.needco.scrapers.ScraperProcessor.run(ScraperProcessor.java:108)
[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[?:1.7.0_71]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
[?:1.7.0_71]
at java.lang.Thread.run(Thread.java:745) [?:1.7.0_71]
Caused by: org.jruby.exceptions.RaiseException: (LoadError) load error:
kryptcore – java.lang.NoClassDefFoundError:
org/jruby/ext/krypt/helper/RubyHelper
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1071)
~[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at
Kernel.require(/home/scraper/scrapers/nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:126)
~[?:?]
at
Kernel.require(/home/scraper/scrapers/nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:124)
~[?:?]
at
RUBY.(root)(/home/scraper/scrapers/nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/META-INF/jruby.home/lib/ruby/shared/krypt/core.rb:37)
~[?:?]
==> stack-4.txt <==
org.jruby.embed.InvokeFailedException: (LoadError) load error:
jopenssl/load – java.lang.NoClassDefFoundError:
org/bouncycastle/asn1/DERBoolean
at
org.jruby.embed.internal.EmbedRubyObjectAdapterImpl.call(EmbedRubyObjectAdapterImpl.java:317)
~[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at
org.jruby.embed.internal.EmbedRubyObjectAdapterImpl.callMethod(EmbedRubyObjectAdapterImpl.java:169)
~[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at
org.jruby.embed.ScriptingContainer.callMethod(ScriptingContainer.java:1508)
~[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at com.needco.scrapers.JRubyScraper.init(JRubyScraper.java:43)
~[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at com.needco.scrapers.Scraper.scrape(Scraper.java:90)
[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at
com.needco.scrapers.ScraperProcessor.run(ScraperProcessor.java:108)
[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[?:1.7.0_71]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
[?:1.7.0_71]
at java.lang.Thread.run(Thread.java:745) [?:1.7.0_71]
Caused by: org.jruby.exceptions.RaiseException: (LoadError) load error:
jopenssl/load – java.lang.NoClassDefFoundError:
org/bouncycastle/asn1/DERBoolean
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1071)
~[nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
at
Kernel.require(/home/scraper/scrapers/nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:126)
~[?:?]
at
Kernel.require(/home/scraper/scrapers/nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:124)
~[?:?]
at
RUBY.(root)(/home/scraper/scrapers/nc-scrapers-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/META-INF/jruby.home/lib/ruby/shared/openssl.rb:1)
~[?:?]
I have tried setting global.require.lock=true and
.compile.invokedynamic=false as they had been suggested to others that
seemed to have similar issues, but that has not helped.
I am using jruby-complete 1.7.18 and Java 1.7.0_71.
Can anyone help?
Thanks!