JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-6339

JRuby can't load from JAR files on a path with a '#' symbol (breaks Tomcat 7 Parallel Deployment)

    Details

    • Number of attachments :
      0

      Description

      Tomcat 7 parallel deployment indicates versioned WARs by placing a ##VERSION suffix on the WAR file, e.g, my-app##001.war. (http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Parallel_deployment)

      When deploying a JRuby on Rails packaged with Warbler, this results in a RackInitializationException, the root cause of which is a MalformedURLException thrown from line 1146 of org.jruby.runtime.load.LoadService.java. The malformed url looks like "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".

      That this is a malformed URL can be verified by simply passing the string to the constructor of java.net.URL: it will throw a MalformedURLException. Everything after the sharp symbol is being interpreted as a fragment rather than part of the file path.

      One possible solution is to escape the sharp signs in a file path using standard URL escaping. '##' becomes '%23%23'. Experimentation confirms that Java is capable of parsing and reading from the example URL given above when it is escaped in this way.

        Activity

        Hiro Asari made changes -
        Field Original Value New Value
        Priority Major [ 3 ] Critical [ 2 ]
        Hide
        Charles Oliver Nutter added a comment -

        This may be easy to investigate and fix if we can reproduce it or you can provide more info. I was not sure how to set up Tomcat 7 to do this parallel deployment (I have not administered Tomcat in a long time). Can you help there? Alternatively, if you can provide full logs that show the error, it would give us a hint where to look.

        And of course if you think you can just go ahead and fix it yourself in jruby-rack, that would be great too

        Show
        Charles Oliver Nutter added a comment - This may be easy to investigate and fix if we can reproduce it or you can provide more info. I was not sure how to set up Tomcat 7 to do this parallel deployment (I have not administered Tomcat in a long time). Can you help there? Alternatively, if you can provide full logs that show the error, it would give us a hint where to look. And of course if you think you can just go ahead and fix it yourself in jruby-rack, that would be great too
        Hide
        Charles Oliver Nutter added a comment -

        FWIW, it doesn't look like this affects non-versioned deployments, since Tomcat does not use this naming scheme then.

        Show
        Charles Oliver Nutter added a comment - FWIW, it doesn't look like this affects non-versioned deployments, since Tomcat does not use this naming scheme then.
        Hide
        Nick Muerdter added a comment -

        I also just ran into this with JRuby 1.7.0 and Tomcat 7 while attempting to use the parallel deployment feature. The exact error I got was slightly different and points to jruby-core instead of jruby-rack, but otherwise it seems like the same issue.

        To reproduce, all you should need is a default Tomcat 7 installation, and then drop in a war named like "my_app##01.war" (the "##version.war" suffix is the only important part to trigger parallel deployments). The parallel deployment feature should be enabled by default in Tomcat 7.

        I've tried to come up with a simpler test case, but haven't had much luck. I'll still poke around, but in the meantime here's the full backtrace I received in Tomcat if that helps.

        SEVERE: ERROR: unable to create shared application instance
        org.jruby.rack.RackInitializationException: no !/ in spec
                from org/jruby/RubyKernel.java:1019:in `require'
                from file:/var/lib/tomcat7/webapps/my_app##01/WEB-INF/lib/jruby-core-1.7.0.jar!/jruby/kernel19/rubygems.rb:4:in `(root)'
                from org/jruby/RubyKernel.java:1045:in `load'
                from file:/var/lib/tomcat7/webapps/my_app##01/WEB-INF/lib/jruby-core-1.7.0.jar!/jruby/kernel19.rb:1:in `(root)'
        
                at org.jruby.rack.DefaultRackApplicationFactory.createApplication(DefaultRackApplicationFactory.java:242)
                at org.jruby.rack.DefaultRackApplicationFactory.newApplication(DefaultRackApplicationFactory.java:49)
                at org.jruby.rack.DefaultRackApplicationFactory.getApplication(DefaultRackApplicationFactory.java:57)
                at org.jruby.rack.SharedRackApplicationFactory.init(SharedRackApplicationFactory.java:33)
                at org.jruby.rack.RackServletContextListener.contextInitialized(RackServletContextListener.java:48)
                at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
                at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
                at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
                at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
                at java.util.concurrent.FutureTask.run(FutureTask.java:166)
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
                at java.lang.Thread.run(Thread.java:722)
        Caused by: org.jruby.exceptions.RaiseException: (IOError) no !/ in spec
                at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1019)
                at RUBY.(root)(file:/var/lib/tomcat7/webapps/my_app##01/WEB-INF/lib/jruby-core-1.7.0.jar!/jruby/kernel19/rubygems.rb:4)
                at org.jruby.RubyKernel.load(org/jruby/RubyKernel.java:1045)
                at RUBY.(root)(file:/var/lib/tomcat7/webapps/my_app##01/WEB-INF/lib/jruby-core-1.7.0.jar!/jruby/kernel19.rb:1)
        
        Show
        Nick Muerdter added a comment - I also just ran into this with JRuby 1.7.0 and Tomcat 7 while attempting to use the parallel deployment feature. The exact error I got was slightly different and points to jruby-core instead of jruby-rack, but otherwise it seems like the same issue. To reproduce, all you should need is a default Tomcat 7 installation, and then drop in a war named like "my_app##01.war" (the "##version.war" suffix is the only important part to trigger parallel deployments). The parallel deployment feature should be enabled by default in Tomcat 7. I've tried to come up with a simpler test case, but haven't had much luck. I'll still poke around, but in the meantime here's the full backtrace I received in Tomcat if that helps. SEVERE: ERROR: unable to create shared application instance org.jruby.rack.RackInitializationException: no !/ in spec from org/jruby/RubyKernel.java:1019:in `require' from file:/ var /lib/tomcat7/webapps/my_app##01/WEB-INF/lib/jruby-core-1.7.0.jar!/jruby/kernel19/rubygems.rb:4:in `(root)' from org/jruby/RubyKernel.java:1045:in `load' from file:/ var /lib/tomcat7/webapps/my_app##01/WEB-INF/lib/jruby-core-1.7.0.jar!/jruby/kernel19.rb:1:in `(root)' at org.jruby.rack.DefaultRackApplicationFactory.createApplication(DefaultRackApplicationFactory.java:242) at org.jruby.rack.DefaultRackApplicationFactory.newApplication(DefaultRackApplicationFactory.java:49) at org.jruby.rack.DefaultRackApplicationFactory.getApplication(DefaultRackApplicationFactory.java:57) at org.jruby.rack.SharedRackApplicationFactory.init(SharedRackApplicationFactory.java:33) at org.jruby.rack.RackServletContextListener.contextInitialized(RackServletContextListener.java:48) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang. Thread .run( Thread .java:722) Caused by: org.jruby.exceptions.RaiseException: (IOError) no !/ in spec at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1019) at RUBY.(root)(file:/ var /lib/tomcat7/webapps/my_app##01/WEB-INF/lib/jruby-core-1.7.0.jar!/jruby/kernel19/rubygems.rb:4) at org.jruby.RubyKernel.load(org/jruby/RubyKernel.java:1045) at RUBY.(root)(file:/ var /lib/tomcat7/webapps/my_app##01/WEB-INF/lib/jruby-core-1.7.0.jar!/jruby/kernel19.rb:1)
        Hide
        Nick Muerdter added a comment -

        I think I got to the bottom of it and submitted pull requests (more details there):

        https://github.com/jruby/jruby/pull/388
        https://github.com/jruby/warbler/pull/125

        Show
        Nick Muerdter added a comment - I think I got to the bottom of it and submitted pull requests (more details there): https://github.com/jruby/jruby/pull/388 https://github.com/jruby/warbler/pull/125
        Hide
        Hiro Asari added a comment -

        I merged the pull request for JRuby.

        Show
        Hiro Asari added a comment - I merged the pull request for JRuby.
        Hiro Asari made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Hiro Asari [ asari ]
        Fix Version/s JRuby 1.7.1 [ 18842 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Hiro Asari
            Reporter:
            Luke VanderHart
          • Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: