Uploaded image for project: 'Apache Tomcat Maven Plugin'
  1. Apache Tomcat Maven Plugin
  2. MTOMCAT-206

Runtime dependencies within multi module projects are not loaded.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.1
    • Component/s: commons-lib
    • Labels:
      None

      Description

      I am not sure if this counts as a duplicate of MTOMCAT-46, there are some differences...

      Consider a multi module project in maven structured like this:

      • parent
      • api
      • implementation
      • webapp

      The webapp has a compile scope dependency on the API and a runtime scope dependency on the implementation. The implementation classes are loaded with some dependency injection framework.

      If I run tomcat(7):run in the root project it will fail because the tomcat plugin does not add the implementation classes (i.e. the runtime dependency) to the classpath. If I change the dependency scope of the implementation dependency to compile, it works.

      The solution for this was pretty simple. Just change one method call in DefaultClassLoaderEntriesCalculator, viewable in the applied patch. All tests and IT-tests still pass.

        Issue Links

          Activity

          Hide
          theludd Ludwig Magnusson added a comment -

          I cant find a way to upload a patch in a file but here it is:

          Index: src/main/java/org/apache/tomcat/maven/common/run/DefaultClassLoaderEntriesCalculator.java
          ===================================================================
          — src/main/java/org/apache/tomcat/maven/common/run/DefaultClassLoaderEntriesCalculator.java (revision 1446079)
          +++ src/main/java/org/apache/tomcat/maven/common/run/DefaultClassLoaderEntriesCalculator.java (working copy)
          @@ -68,7 +68,7 @@
          {
          @SuppressWarnings ("unchecked") List<String> classPathElements = request.isUseTestClassPath()
          ? request.getMavenProject().getTestClasspathElements()

          • : request.getMavenProject().getCompileClasspathElements();
            + : request.getMavenProject().getRuntimeClasspathElements();
            if ( classPathElements != null )
            {
            for ( String classPathElement : classPathElements )
          Show
          theludd Ludwig Magnusson added a comment - I cant find a way to upload a patch in a file but here it is: Index: src/main/java/org/apache/tomcat/maven/common/run/DefaultClassLoaderEntriesCalculator.java =================================================================== — src/main/java/org/apache/tomcat/maven/common/run/DefaultClassLoaderEntriesCalculator.java (revision 1446079) +++ src/main/java/org/apache/tomcat/maven/common/run/DefaultClassLoaderEntriesCalculator.java (working copy) @@ -68,7 +68,7 @@ { @SuppressWarnings ("unchecked") List<String> classPathElements = request.isUseTestClassPath() ? request.getMavenProject().getTestClasspathElements() : request.getMavenProject().getCompileClasspathElements(); + : request.getMavenProject().getRuntimeClasspathElements(); if ( classPathElements != null ) { for ( String classPathElement : classPathElements )
          Hide
          olamy Olivier Lamy (*$^¨%`£) added a comment -

          good catch !
          I will apply that. Normally you must be able to attach a patch file.

          Show
          olamy Olivier Lamy (*$^¨%`£) added a comment - good catch ! I will apply that. Normally you must be able to attach a patch file.
          Hide
          olamy Olivier Lamy (*$^¨%`£) added a comment -
          Show
          olamy Olivier Lamy (*$^¨%`£) added a comment - applied http://svn.apache.org/r1446188 Thanks !
          Hide
          hudson Hudson added a comment -

          Integrated in TomcatMavenPlugin-mvn3.x #237 (See https://builds.apache.org/job/TomcatMavenPlugin-mvn3.x/237/)
          MTOMCAT-206 Runtime dependencies within multi module projects are not loaded.
          Submitted by Ludwig Magnusson. (Revision 1446188)

          Result = UNSTABLE
          olamy : http://svn.apache.org/viewvc/?view=rev&rev=1446188
          Files :

          • /tomcat/maven-plugin/trunk/common-tomcat-maven-plugin/src/main/java/org/apache/tomcat/maven/common/run/DefaultClassLoaderEntriesCalculator.java
          Show
          hudson Hudson added a comment - Integrated in TomcatMavenPlugin-mvn3.x #237 (See https://builds.apache.org/job/TomcatMavenPlugin-mvn3.x/237/ ) MTOMCAT-206 Runtime dependencies within multi module projects are not loaded. Submitted by Ludwig Magnusson. (Revision 1446188) Result = UNSTABLE olamy : http://svn.apache.org/viewvc/?view=rev&rev=1446188 Files : /tomcat/maven-plugin/trunk/common-tomcat-maven-plugin/src/main/java/org/apache/tomcat/maven/common/run/DefaultClassLoaderEntriesCalculator.java
          Hide
          theludd Ludwig Magnusson added a comment -

          Is this a problem?
          Running mvn clean verify generates a build success for me...

          Show
          theludd Ludwig Magnusson added a comment - Is this a problem? Running mvn clean verify generates a build success for me...
          Hide
          olamy Olivier Lamy (*$^¨%`£) added a comment -

          no worries. It works fine locally too.
          Looks to be some overload on the asf jenkins.

          Show
          olamy Olivier Lamy (*$^¨%`£) added a comment - no worries. It works fine locally too. Looks to be some overload on the asf jenkins.

            People

            • Assignee:
              olamy Olivier Lamy (*$^¨%`£)
              Reporter:
              theludd Ludwig Magnusson
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development