-
Notifications
You must be signed in to change notification settings - Fork 206
Description
JRuby 9.4.x Incompatibility: NoClassDefFoundError: org/jruby/CompatVersion
Summary
WAR files built with Warbler fail to deploy on Apache Tomcat when using JRuby 9.4.x due to a missing org.jruby.CompatVersion class that jruby-rack depends on but was removed in JRuby 9.4.x.
Environment
- JRuby version: 9.4.9.0
- Warbler version: 2.0.5 (gem release) and latest from master branch
- jruby-rack: Bundled by Warbler
- Tomcat version: 9.0.98
- Java version: 21.0.8+9-LTS (Eclipse Adoptium)
Steps to Reproduce
- Create a simple Sinatra application with
config.ru:
require './app'
run Sinatra::Application- Create
Gemfile:
source 'https://rubygems.org'
gem 'sinatra'
gem 'warbler', platforms: :jruby- Create
config/warble.rbwith JRuby 9.3+ workaround:
# Workaround for JRuby 9.3+ new_ostruct_member issue
# See: https://github.com/jruby/warbler/issues/452
class Warbler::Traits::War::WebxmlOpenStruct
def new_ostruct_member(name)
send(:new_ostruct_member!, name)
end
end
Warbler::Config.new do |config|
config.gem_dependencies = true
config.war_name = "hello_world"
config.includes = FileList["app.rb", "config.ru"]
config.bundle_without = []
end- Build WAR file:
jruby -S bundle install
jruby -S bundle exec warble- Deploy to Tomcat and access the application
Expected Behavior
The Sinatra application should start and respond to HTTP requests.
Actual Behavior
The application fails to start with the following error:
java.lang.NoClassDefFoundError: org/jruby/CompatVersion
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(java/lang/Class)
at java.lang.Class.getDeclaredMethods(java/lang/Class)
at org.jruby.javasupport.binding.MethodGatherer$1.computeValue(org/jruby/javasupport/binding/MethodGatherer.java:300)
...
Caused by: java.lang.ClassNotFoundException: org.jruby.CompatVersion
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1349)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1158)
Root Cause
The org.jruby.CompatVersion class was removed in JRuby 9.4.x, but jruby-rack (bundled by Warbler) still references this class.
Attempted Workarounds
1. Using Warbler from GitHub master branch
Updated Gemfile to use latest code:
gem 'warbler', git: 'https://github.com/jruby/warbler', branch: 'master', platforms: :jrubyResult: Same error - the GitHub version still bundles a jruby-rack version that expects CompatVersion.
2. Downgrading to JRuby 9.3.x
JRuby 9.3.13.0 still has the CompatVersion class, but it requires Java 21 (class file version 65.0), which creates other compatibility issues with older Tomcat versions.
3. Removing config.webxml.booter
Removed explicit rack booter configuration to let Warbler auto-detect:
# Removed: config.webxml.booter = :rackResult: No change - the error persists.
Additional Context
- The same application works perfectly when run with Trinidad server
- The WAR file builds successfully without errors
- The WAR deploys to Tomcat without errors
- The failure occurs only at runtime when jruby-rack tries to initialize
Related Issues
- 1.x: Avoid removing files not ended in .rb #452 - JRuby 9.3+
new_ostruct_memberissue (resolved with workaround) - This appears to be a new incompatibility introduced in JRuby 9.4.x
Request
Could jruby-rack be updated to be compatible with JRuby 9.4.x, or could Warbler bundle a patched version that doesn't depend on the removed CompatVersion class?
Temporary Solution
Currently, the only workaround is to continue using JRuby 9.3.x or use alternative servers like Trinidad that don't rely on jruby-rack.