Jetty
  1. Jetty
  2. JETTY-205

jetty:run uses different ClassLoader model than both jetty:run-war and jetty:run-exploded

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Testcase included:
      yes
    • Number of attachments :
      1

      Description

      I have run into a situation where running "mvn jetty:run" results in a NullPointerException when in reality, there should be none. When I run "mvn jetty:run-war" or "mvn jetty:run-exploded", the NPE does not manifest and the application runs properly. (If it is any consolation, "mvn test" runs the same as "mvn jetty:run" so this may be a little deeper than just the Jetty plugin.) Anyway, I have attached a project to help you reproduce this issue and respond accordingly. Here are some instructions:

      Preparation
      ----------------
      The README included with the attachment tells you how to install RIFE into your local Maven repository

      Reproduction
      ------------------
      If you are interested, run "mvn test" to reproduce the fact that Maven's test plugin suffers from this issue as well. If not, continue on by running "mvn jetty:run -o -Dmaven.test.skip=true". This should result in an NPE as part of the server startup. Then run "mvn jetty:run-exploded -o -Dmaven.test.skip=true" and this time, there should be no NPE. The same should happen if you use jetty:run-war as opposed to running jetty:run-exploded.

      I would be extremely happy if this turns out to be a non-issue but a misunderstanding on my part. If not, I hope my attachment and documentation helps fix any issues found as a result of this Jira.

      Take care,

      Jeremy

        Activity

        Hide
        Jeremy Whitlock added a comment -

        Disregard the "mvn test" issues. Apparently I learned more about RIFE that made running unit tests work. This does appear to be more related to the Maven Jetty plugin than the Maven framework.

        Take care,

        Jeremy

        Show
        Jeremy Whitlock added a comment - Disregard the "mvn test" issues. Apparently I learned more about RIFE that made running unit tests work. This does appear to be more related to the Maven Jetty plugin than the Maven framework. Take care, Jeremy
        Hide
        Jan Bartel added a comment -

        Jeremy,

        Rife seems to require that the rife jar is in the same classloader as the config xml files. In fact the rife doco at http://www.rifers.org/examples even explicitly says that you cannot copy a rife jar into a web server's shared /lib dir, and that each and every webapp has to have an individual copy of the jar.

        In jetty stand-alone as for jetty:run-war and jetty:run-exploded, this will be the case, as the classloader for the webapp will contain everything from the built webapps's WEB-INF/lib and WEB-INF/classes directory.

        However, in the case of jetty:run, we are using the classloader that maven gives us which already contains all of the dependencies (ie the rife jar), and then the webapp classloader just contains the webapps' classes and any resources (which BTW are usually put in src/main/resources and defined as <resources> in the pom.xml). So, the rife jars are on the classpath of the classloader that is executing the plugin, and the config files are on the classpath of the webapp's classloader.

        I can't see any easy way of making jetty:run work with rife's current classloading requirements. Can you?

        Show
        Jan Bartel added a comment - Jeremy, Rife seems to require that the rife jar is in the same classloader as the config xml files. In fact the rife doco at http://www.rifers.org/examples even explicitly says that you cannot copy a rife jar into a web server's shared /lib dir, and that each and every webapp has to have an individual copy of the jar. In jetty stand-alone as for jetty:run-war and jetty:run-exploded, this will be the case, as the classloader for the webapp will contain everything from the built webapps's WEB-INF/lib and WEB-INF/classes directory. However, in the case of jetty:run, we are using the classloader that maven gives us which already contains all of the dependencies (ie the rife jar), and then the webapp classloader just contains the webapps' classes and any resources (which BTW are usually put in src/main/resources and defined as <resources> in the pom.xml). So, the rife jars are on the classpath of the classloader that is executing the plugin, and the config files are on the classpath of the webapp's classloader. I can't see any easy way of making jetty:run work with rife's current classloading requirements. Can you?
        Hide
        Jan Bartel added a comment -

        Closing. If more info is forthcoming, reopen the issue.

        Show
        Jan Bartel added a comment - Closing. If more info is forthcoming, reopen the issue.

          People

          • Assignee:
            Jan Bartel
            Reporter:
            Jeremy Whitlock
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: