I am encountering an issue when deploying a JRuby (9.4.8.0) WAR file in Tomcat (9.0.58.0). During initialization, the deployment fails with a RackInitializationException and an exit call in the bundler/setup.rb file.
Details:
JRuby Version: 9.4.8.0
Tomcat Version: 9
Bundler Version: 2.3.26
Ruby Version: 3.1.4
Error Context: The bundler/setup.rb file is calling exit during initialization, which halts the process and causes the deployment to fail.
Steps Taken:
Verified the Gemfile and Gemfile.lock for compatibility and completeness.
Checked the JRuby environment variables and setup.
Confirmed that all necessary dependencies are included in the WAR file.
Error Description:
01-Aug-2024 13:27:43.786 INFO [main] org.apache.catalina.core.ApplicationContext.log An exception happened during JRuby-Rack startup
exit
--- System
jruby 9.4.8.0 (3.1.4) 2024-07-02 4d41e55a67 Java HotSpot(TM) 64-Bit Server VM 21.0.3+7-LTS-152 on 21.0.3+7-LTS-152 +jit [x86_64-linux]
Time: 2024-08-01 13:27:43 -0400
Server: Apache Tomcat/9.0.58 (Ubuntu)
jruby.home: uri:classloader://META-INF/jruby.home
--- Context Init Parameters:
jruby.max.modifiable.runtimes= = 1
jruby.max.runtimes = 1
jruby.min.modifiable.runtimes= = 1
jruby.min.runtimes = 1
modifiable.booter= = rails
modifiable.ignored= = ["jndi", "booter"]
modifiable.jndi= =
public.modifiable.root= = /
rails.env = production
rails.modifiable.env= = production
--- Backtrace
SystemExit: exit
exit at org/jruby/RubyKernel.java:921
exit at org/jruby/RubyKernel.java:880
<main> at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/setup.rb:17
require at org/jruby/RubyKernel.java:1184
require at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:85
<main> at /var/lib/tomcat9/webapps/ROOT/WEB-INF/config/boot.class:3
load at org/jruby/RubyKernel.java:1220
<main> at /var/lib/tomcat9/webapps/ROOT/WEB-INF/config/boot.rb:1
require at org/jruby/RubyKernel.java:1184
require at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:85
load_environment at uri:classloader:/jruby/rack/rails/environment3.rb:23
load_environment at uri:classloader:/jruby/rack/rails_booter.rb:83
<main> at <script>:1
--- RubyGems
Gem.dir: uri:classloader:/META-INF/jruby.home/lib/ruby/gems/shared
Gem.path:
uri:classloader:/META-INF/jruby.home/lib/ruby/gems/shared
Activated gems:
jar-dependencies-0.4.1
did_you_mean-1.6.1
stringio-3.0.8-java
bundler-2.3.26
--- Bundler
Bundler.bundle_path: uri:classloader:/META-INF/jruby.home/lib/ruby/gems/shared
Bundler.root: /var/lib/tomcat9/webapps/ROOT/WEB-INF
Gemfile: /var/lib/tomcat9/webapps/ROOT/WEB-INF/Gemfile
Settings:
gemfile = /var/lib/tomcat9/webapps/ROOT/WEB-INF/Gemfile
without = []
--- JRuby-Rack Config
compat_version =
default_logger = org.jruby.rack.logging.StandardOutLogger@3badd5e0
equals = <error: >
err = org.apache.tomcat.util.log.SystemLogHandler@35ed8c1
filter_adds_html = true
filter_verifies_resource = false
ignore_environment = false
initial_memory_buffer_size =
initial_runtimes = 1
jms_connection_factory =
jms_jndi_properties =
logger = org.jruby.rack.logging.ServletContextLogger@66fc5cc7
logger_class_name = servlet_context
logger_name = jruby.rack
maximum_memory_buffer_size =
maximum_runtimes = 1
num_initializer_threads =
out = org.apache.tomcat.util.log.SystemLogHandler@20879a29
rackup =
rackup_path =
rewindable = true
runtime_arguments =
runtime_environment =
runtime_timeout_seconds =
serial_initialization = false
servlet_context = org.apache.catalina.core.ApplicationContextFacade@3ceadc4f
throw_init_exception = false
01-Aug-2024 13:27:43.786 SEVERE [main] org.apache.catalina.core.ApplicationContext.log ERROR: initialization failed
org.jruby.rack.RackInitializationException: exit
from org/jruby/RubyKernel.java:921:in `exit'
from org/jruby/RubyKernel.java:880:in `exit'
from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/setup.rb:17:in `<main>'
from org/jruby/RubyKernel.java:1184:in `require'
from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:85:in `require'
from /var/lib/tomcat9/webapps/ROOT/WEB-INF/config/boot.class:3:in `<main>'
from org/jruby/RubyKernel.java:1220:in `load'
from /var/lib/tomcat9/webapps/ROOT/WEB-INF/config/boot.rb:1:in `<main>'
from org/jruby/RubyKernel.java:1184:in `require'
from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:85:in `require'
from uri:classloader:/jruby/rack/rails/environment3.rb:23:in `load_environment'
from uri:classloader:/jruby/rack/rails_booter.rb:83:in `load_environment'
from <script>:1:in `<main>'
at org.jruby.rack.RackInitializationException.wrap(RackInitializationException.java:29)
at org.jruby.rack.RackApplicationFactoryDecorator.init(RackApplicationFactoryDecorator.java:104)
at org.jruby.rack.RackServletContextListener.contextInitialized(RackServletContextListener.java:50)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4768)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5230)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:698)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:696)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1024)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1911)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:123)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:825)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:475)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1618)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:319)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:423)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:366)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:946)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:835)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:263)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:432)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:927)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:772)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:345)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:480)
Caused by: org.jruby.exceptions.SystemExit: (SystemExit) exit
at org.jruby.RubyKernel.exit(org/jruby/RubyKernel.java:921)
at org.jruby.RubyKernel.exit(org/jruby/RubyKernel.java:880)
at RUBY.<main>(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/setup.rb:17)
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1184)
at RUBY.require(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:85)
at RUBY.<main>(/var/lib/tomcat9/webapps/ROOT/WEB-INF/config/boot.class:3)
at org.jruby.RubyKernel.load(org/jruby/RubyKernel.java:1220)
at RUBY.<main>(/var/lib/tomcat9/webapps/ROOT/WEB-INF/config/boot.rb:1)
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1184)
at RUBY.require(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:85)
at RUBY.load_environment(uri:classloader:/jruby/rack/rails/environment3.rb:23)
at RUBY.load_environment(uri:classloader:/jruby/rack/rails_booter.rb:83)
at RUBY.<main>(<script>:1)
Note:
Able to run the application normally using rails.
Request for Help:
I am seeking assistance to understand why the exit call is occurring and how to resolve this issue. Any guidance or suggestions for troubleshooting this problem would be greatly appreciated.
The actual issue was that Tomcat was unable to identify the GEM_PATH and GEM_HOME; this issue was resolved as soon as I added Gem.paths=ENV in boot.rb before calling require "bundler/setup".
I am encountering an issue when deploying a JRuby (9.4.8.0) WAR file in Tomcat (9.0.58.0). During initialization, the deployment fails with a RackInitializationException and an exit call in the bundler/setup.rb file.
Details:
Steps Taken:
Error Description:
Note: Able to run the application normally using rails.
Request for Help: I am seeking assistance to understand why the exit call is occurring and how to resolve this issue. Any guidance or suggestions for troubleshooting this problem would be greatly appreciated.