Skip to content

Conversation

qisantanu
Copy link
Contributor

  1. Consistency with war.erb template behavior
  2. Isolation - only uses gems packaged in the WAR
  3. No system gem conflicts - prevents loading host system gems
  4. Self-contained deployment - WAR file is completely portable

- Add Gem.paths configuration in bundler.erb template
- Resolves 'bundle install' errors when running WAR files
- Ensures RubyGems finds bundled gems correctly in servlet containers
@qisantanu
Copy link
Contributor Author

@kares , can you please review and merge this PR? It will be helpful for our further development. We are in a transition period to update our app.

@chadlwilson
Copy link

chadlwilson commented Sep 19, 2025

While I'm not a warbler expert and dont have maintainer permissions on this project, I'm also keen to help here if I can since there are similar challenges to jruby-rack with build infra, versions, bundler modernisation etc.

@qisantanu Could you perhaps summarise the spefic issue you're trying to resolve for the non-expert (the root cause seems to not be well understood) especially how it relates to #564? Seems this is basically an attempt to fix #539 however you appear to have considered some other aspects.

Especially as there is an existing comment at https://github.com/jruby/warbler/pull/564/files#r2212851704 indicating this might not be the right place to address the issue, we should try and resolve these.

@qisantanu
Copy link
Contributor Author

Hi @chadlwilson , I am also not an expert in the warble gem. but we are using it for our enterprised app to deploy under weblogic for a long time.
After upgrading the application to Rails 7 and packaging it into a WAR file, deployment fails with the following error:

“The necessary gems are missing. Please run bundle install.”

This results in an HTTP 500 error during execution.

Root Cause (Suspected)

The Gem.paths.path is not being set, which prevents the application from correctly using the packaged gems.

Similarly, Gem.paths.home is not configured, causing the application to search for gems on the server instead of within the packaged archive.

We tried this version of warbler in our Rails7 app's Gemfile. And now we can run the generated war file under the weblogic without the error.

@chadlwilson
Copy link

Which JRuby and jruby-rack versions are you using? And which change/upgrade triggered the problem starting for you?

The challenge seems to be that no-one in #539 other than OP (which is now outdated) seems to have reported with fuller environment context, meaning any hasty fix risks breaking things for other people's environments.

I don't imagine anyone is likely to feel comfortable merging without understanding the root cause (and what changed upstream to create the issue) more clearly.

@qisantanu
Copy link
Contributor Author

We are using at present: JRuby 9.3.15.0
image
This is working with war in WebLogic.

We are upgrading to: JRuby 9.4.5.0
image

The error was:
image

So, it was saying that bundle install is not been executed yet. Though, we have checked that all the gem files were part of the war file. After switching to this version of Warbler, it works.

@chadlwilson
Copy link

It’s a mildly separate issue, but you should really be using the latest ruby 9.4 patch version - that one is very old, and thus unsupported.

side-question - why do you include screenshots from text and cut off the error traces rather than including all config? To replicate your issue/env you would like people to type out your gemfiles by hand?

@headius
Copy link
Member

headius commented Sep 24, 2025

I'm back and looking this over. Thanks for the patch @qisantanu!

@headius
Copy link
Member

headius commented Sep 24, 2025

@qisantanu Could you provide a simple way to reproduce the issue you're seeing, like a small repository that fails the same way? I'm also having trouble understanding if this is the right way or the right place to fix this issue.

@qisantanu
Copy link
Contributor Author

@qisantanu Could you provide a simple way to reproduce the issue you're seeing, like a small repository that fails the same way? I'm also having trouble understanding if this is the right way or the right place to fix this issue.

Hi @headius,

Thanks for looking into this! I’ve pushed a minimal JRuby Rails 7.1 app that reproduces the issue to a public repository: https://github.com/qisantanu/myapp_for_weblogic
.

The repo includes:

Rails 7.1, JRuby 9.4.5.0

No database (simplified for reproduction)

Added a README as well.

The error I am getting after installing the war file in weblogic:

Internal Server Error (500)
  Request Method:	GET
  Request URL:	http://apps.intranet.xyz.com:7009/myapp_for_weblogic
  

https://github.com/qinvent/warbler.git is not yet checked out. Run `bundle install` first. from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/source/git.rb:214:in `load_spec_files' from
 uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/source/path.rb:107:in `local_specs' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/source/git.rb:178:in `specs' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/lazy_specification.rb:82:in `materialize_for_installation' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/spec_set.rb:194:in
  `block in specs_for_dependency' from org/jruby/RubyArray.java:2813:in `map' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/spec_set.rb:194:in `specs_for_dependency' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/spec_set.rb:33:in `block in for' from org/jruby/RubyKernel.java:1603:in `loop' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib
  /bundler/spec_set.rb:22:in `for' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/spec_set.rb:79:in `materialize' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/definition.rb:490:in `materialize' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/definition.rb:187:in `specs' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler
  /definition.rb:244:in `specs_for' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/runtime.rb:18:in `setup' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler.rb:161:in `setup' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/setup.rb:20:in `block in <main>' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/ui/shell.rb:136:in `with_level'
   from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/ui/shell.rb:88:in `silence' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/setup.rb:20:in `<main>' from org/jruby/RubyKernel.java:1071:in `require' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:85:in `require' from /opt/weblogic/user_projects/domains/base_domain
   /servers/TDCID/tmp/_WL_user/myapp_for_weblogic/4frmyw/war/WEB-INF/config/boot.class:3:in `<main>' from org/jruby/RubyKernel.java:1107:in `load' from /opt/weblogic/user_projects/domains/base_domain/servers/TDCID/tmp/_WL_user/myapp_for_weblogic/4frmyw/war/WEB-INF/config/boot.rb:1:in `<main>' from org/jruby/RubyKernel.java:1071: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/environment.rb:23:in `load_environment' from uri:classloader:/jruby/rack/rails_booter.rb:73:in `load_environment' from <script>:1:in `<main>'
   


You're seeing this error because you use JRuby::Rack::ErrorApp::ShowStatus.


@mbiang
Copy link

mbiang commented Sep 30, 2025

FYI - we are also seeing this issue after upgrading our app to Rails 7 on jruby 9.4.14.0

@chadlwilson
Copy link

chadlwilson commented Sep 30, 2025

Unfortunately this approach does not seem a good idea to me, as it ignores existing config values that interact with these same values, and seems to fail to get at the root cause?

It seems there is a lot of historical mess here to unpack , as noted in #564 along with a number of other bundler quirks in issues over time :(

@headius
Copy link
Member

headius commented Oct 1, 2025

@qisantanu I'm trying to get your example app deployed today. WebLogic is complicated to get and install these days!

I tried deploying on Tomcat but got an error at app deploy that seems to prevent me going further:

01-Oct-2025 13:16:16.969 SEVERE [main] org.apache.catalina.core.ApplicationContext.log initialization failed
        org.jruby.rack.RackInitializationException: Missing `secret_key_base` for 'production' environment, set this string with `bin/rails credentials:edit`
        from /Users/headius/.gem/jruby/3.1.4/gems/railties-7.1.5.2/lib/rails/application.rb:661:in `validate_secret_key_base'
        from /Users/headius/.gem/jruby/3.1.4/gems/railties-7.1.5.2/lib/rails/application.rb:483:in `secret_key_base'
        from /Users/headius/.gem/jruby/3.1.4/gems/railties-7.1.5.2/lib/rails/application.rb:161:in `key_generator'
        from /Users/headius/.gem/jruby/3.1.4/gems/turbo-rails-2.0.17/lib/turbo/engine.rb:116:in `block in Engine'

@mbiang Thank you for jumping in... clearly this is a problem we need to fix and get released.

@chadlwilson
Copy link

I spent some time trying to figure things out across jruby-rack, warbler etc and got lost in all of the various hacks/config options and the fact that there is an open PR for Bundler 2 support, yet everyone is obviously using Bundler 2 already.

Probably a bit beyond me right now, sadly.

@qisantanu
Copy link
Contributor Author

Hi @headius ,

I make some commits to fix the issue. You need to run bundle install once. I updated the README as well with the steps (https://github.com/qisantanu/myapp_for_weblogic?tab=readme-ov-file#setup-instructions).
Yes, the Weblogic installation is complicated.
I have tried today with the war file in Apache Tomcat. And now the error is

Internal Server Error (500)
Request Method:	GET
Request URL:	http://localhost:8080/myapp_for_weblogic/
https://github.com/jruby/warbler.git is not yet checked out. Run `bundle install` first. from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/source/git.rb:214:in `load_spec_files' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/source/path.rb:107:in `local_specs' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/source/git.rb:178:in `specs' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/source/rubygems_aggregate.rb:35:in `block in build_index' from org/jruby/RubyArray.java:1989:in `each' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/source/rubygems_aggregate.rb:33:in `block in build_index' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/index.rb:9:in `build' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/source/rubygems_aggregate.rb:30:in `build_index' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/source/rubygems_aggregate.rb:12:in `initialize' from org/jruby/RubyClass.java:917:in `new' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/definition.rb:803:in `source_requirements' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/definition.rb:477:in `resolver' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/definition.rb:279:in `resolve' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/definition.rb:490:in `materialize' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/definition.rb:187:in `specs' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/definition.rb:244:in `specs_for' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/runtime.rb:18:in `setup' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler.rb:161:in `setup' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/setup.rb:20:in `block in <main>' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/ui/shell.rb:136:in `with_level' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/ui/shell.rb:88:in `silence' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/setup.rb:20:in `<main>' from org/jruby/RubyKernel.java:1071: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/myapp_for_weblogic/WEB-INF/config/boot.class:3:in `<main>' from org/jruby/RubyKernel.java:1107:in `load' from /var/lib/tomcat9/webapps/myapp_for_weblogic/WEB-INF/config/boot.rb:1:in `<main>' from org/jruby/RubyKernel.java:1071: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/environment.rb:23:in `load_environment' from uri:classloader:/jruby/rack/rails_booter.rb:73:in `load_environment' from <script>:1:in `<main>'

You're seeing this error because you use JRuby::Rack::ErrorApp::ShowStatus.

And then I tried with the fixes from my warbler branch. And I can render the homepage.

@chadlwilson
Copy link

Yes, it’s the same error. It’s not specific to WebLogic, but does manifest specifically when sourcing warbler from git rather than a published gem.

I think the reason we see a lot of reports is that there hasn’t been a published warbler for some time so lots of people are trying to install off master (to use unpublished fixes there) and thus hitting this additional issue on top of the one they were trying to use master to fix :)

This patch is based on #539 (comment) which guesses it being related to a much earlier issue at #430

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants