Note that there are some explanatory texts on larger screens.

plurals
  1. PODouble pound (##) in path name doesn't work with JRuby 'require'?
    text
    copied!<p>So, I'm attempting to deploy my JRuby on Rails app to Tomcat 7. Everything works fine.</p> <p>Until I tried using Tomcat's Parallel Deployment feature, which requires that the context/war name be of the form <code>name##VERSION.war</code>.</p> <p>JRuby chokes on this the first time I try to require a file with a <code>##</code> in the path, with the following stacktrace:</p> <pre><code>org.jruby.rack.RackInitializationException: no !/ in spec from file:/opt/apache-tomcat-7.0.23/webapps/my-application##0001/WEB-INF/lib/jruby-rack-1.1.2.jar!/vendor/rack.rb:7:in `(root)' from org/jruby/RubyKernel.java:1038:in `require' from file:/opt/apache-tomcat-7.0.23/webapps/my-application##0001/WEB-INF/lib/jruby-rack-1.1.2.jar!/vendor/rack.rb:28:in `boot!' from file:/opt/apache-tomcat-7.0.23/webapps/my-application##0001/WEB-INF/lib/jruby-rack-1.1.2.jar!/jruby/rack/boot/rack.rb:10:in `Rack' from file:/opt/apache-tomcat-7.0.23/webapps/my-application##0001/WEB-INF/lib/jruby-rack-1.1.2.jar!/jruby/rack/boot/rack.rb:8:in `(root)' from org/jruby/RubyKernel.java:1063:in `load' from file:/opt/apache-tomcat-7.0.23/webapps/my-application##0001/WEB-INF/lib/jruby-rack-1.1.2.jar!/jruby/rack/boot/rack.rb:1:in `(root)' at org.jruby.rack.DefaultRackApplicationFactory$4.init(DefaultRackApplicationFactory.java:206) at org.jruby.rack.DefaultRackApplicationFactory.newErrorApplication(DefaultRackApplicationFactory.java:102) at org.jruby.rack.DefaultRackApplicationFactory.getErrorApplication(DefaultRackApplicationFactory.java:66) at org.jruby.rack.SharedRackApplicationFactory$1.call(SharedRackApplicationFactory.java:33) at org.jruby.rack.AbstractRackDispatcher.process(AbstractRackDispatcher.java:30) at org.jruby.rack.AbstractFilter.doFilter(AbstractFilter.java:31) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:298) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) </code></pre> <p>As the stack trace indicates, it seems to be blowing up on the require. Can JRuby just not handle paths of this form? Is there any way I can get around this issue, or is it a fundamental conflict between JRuby and Tomcat's naming convention?</p> <p><strong>UPDATE</strong></p> <p>I attached a debugger to Tomcat, and the problem goes all the way down to the way java.net.URL parses URL strings:</p> <pre><code>new URL("jar:file:/opt/apache-tomcat-7.0.23/webapps/my-app##001/WEB-INF/lib/jruby-rack-1.1.2.jar!/vendor/rack-1.3.6/rack.rb") </code></pre> <p>This blows up with a MalformedURLException. But:</p> <pre><code>new URL("jar:file:/opt/apache-tomcat-7.0.23/webapps/my-app/WEB-INF/lib/jruby-rack-1.1.2.jar!/vendor/rack-1.3.6/rack.rb") </code></pre> <p>This is identical except for the <code>##001</code> in the application name, and it works fine.</p> <p>These are invoked on line 1145 of org.jruby.runtime.load.LoadService in JRuby, by the way.</p> <p>So what are the ramifications of this? Well, for one thing, it looks like Tomcat may have made a poorly considered choice in the characters it uses to indicate names, if it gives trouble to URL parsing. I'm not sure if JRuby can work around this easily.</p> <p>Thoughts, anyone?</p> <p><strong>FURTHER UPDATE</strong></p> <p>You can make it work if you URL escape the hashes. ## becomes %23%23. This will need to be patched in JRuby itself, however, I think.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload