Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.1
    • Component/s: tomcat6, tomcat7
    • Labels:
      None

      Description

      in DefaultClassLoaderEntriesCalculator#calculateClassPathEntries, direct dependencies are not added, the log message says "skip adding artifact " + artifact.getArtifactId() + " as it's in reactors".

      In my case, it's a jar that is configured as a direct dependency. When the Webapp starts, the Jar is missing from the Classpath and the startup fails.

        Activity

        Hide
        Olivier Lamy (*$^¨%`£) added a comment -

        That's not a problem as classpath elements (the output directory of your dependency from reactors is added to the class path).
        Which maven version are you using ? (I have to say that work only with maven 3).

        Show
        Olivier Lamy (*$^¨%`£) added a comment - That's not a problem as classpath elements (the output directory of your dependency from reactors is added to the class path). Which maven version are you using ? (I have to say that work only with maven 3).
        Hide
        Arne Franken added a comment - - edited

        I'm using:
        Apache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100)

        Show
        Arne Franken added a comment - - edited I'm using: Apache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100)
        Hide
        Olivier Lamy (*$^¨%`£) added a comment -

        So should work fine.
        Do you have any sample project to reproduce your isssue ?

        Show
        Olivier Lamy (*$^¨%`£) added a comment - So should work fine. Do you have any sample project to reproduce your isssue ?
        Hide
        Arne Franken added a comment -

        I just found what the problem is:

        I created a new project using your archetype. Example directory structure:
        dep-issue-api/
        dep-issue-api-impl/
        dep-issue-webapp/
        dep-issue-webapp-exec/
        dep-issue-webapp-it/

        I usually build and start all modules from the projects root directory, in this case:
        mvn -am -pl dep-issue-webapp clean install && mvn -pl dep-issue-webapp tomcat7:run

        if I start the tomcat plugin this way, all direct dependencies of the dep-issue-webapp module will not be added to the classpath by Maven, the startup of the webapp will fail.

        ---------

        If I instead do this:
        mvn -am -pl dep-issue-webapp clean install
        cd dep-issue-webapp
        mvn tomcat7:run

        Maven will add all direct dependencies to the classpath and the webapp will start correctly.

        Show
        Arne Franken added a comment - I just found what the problem is: I created a new project using your archetype. Example directory structure: dep-issue-api/ dep-issue-api-impl/ dep-issue-webapp/ dep-issue-webapp-exec/ dep-issue-webapp-it/ I usually build and start all modules from the projects root directory, in this case: mvn -am -pl dep-issue-webapp clean install && mvn -pl dep-issue-webapp tomcat7:run if I start the tomcat plugin this way, all direct dependencies of the dep-issue-webapp module will not be added to the classpath by Maven, the startup of the webapp will fail. --------- If I instead do this: mvn -am -pl dep-issue-webapp clean install cd dep-issue-webapp mvn tomcat7:run Maven will add all direct dependencies to the classpath and the webapp will start correctly.
        Hide
        Olivier Lamy (*$^¨%`£) added a comment -

        use:
        mvn -pl :dep-issue-webapp -am tomcat7:run

        Show
        Olivier Lamy (*$^¨%`£) added a comment - use: mvn -pl :dep-issue-webapp -am tomcat7:run
        Hide
        Arne Franken added a comment -

        mvn -pl :dep-issue-webapp -am tomcat7:run
        that actually works, but it means that I would ALWAYS have to build the webapp and ALL dependencies before I can start it.

        That may not be a problem in a small test project like the one the archetype creates, but this is a big problem in a project where I have lot of dependencies with (tens of) thousands of lines of code that have to be compiled over and over again if I just want to restart my webapp.

        Show
        Arne Franken added a comment - mvn -pl :dep-issue-webapp -am tomcat7:run that actually works, but it means that I would ALWAYS have to build the webapp and ALL dependencies before I can start it. That may not be a problem in a small test project like the one the archetype creates, but this is a big problem in a project where I have lot of dependencies with (tens of) thousands of lines of code that have to be compiled over and over again if I just want to restart my webapp.
        Hide
        Olivier Lamy (*$^¨%`£) added a comment -

        I miss you here !
        Don't clean your projects and you won't rebuild/recompile everything.
        use only mvn -pl :dep-issue-webapp tomcat7:run (without -am) if you don't want to rebuild/recompile everything.

        Show
        Olivier Lamy (*$^¨%`£) added a comment - I miss you here ! Don't clean your projects and you won't rebuild/recompile everything. use only mvn -pl :dep-issue-webapp tomcat7:run (without -am) if you don't want to rebuild/recompile everything.
        Hide
        Arne Franken added a comment -

        > Don't clean your projects
        oops, of course you're right about that.

        > use only mvn -pl :dep-issue-webapp tomcat7:run (without -am) if you don't want to rebuild/recompile everything.
        if I don't use "-am", Tomcat will not have all necessary libraries in the classpath

        if I use "-am" , Tomcat will have all necessary libraries in the classpath, but this won't work if any of my dependencies are also WAR artefacts which also have a Tomcat configuration since Maven will run the Tomcat plugin for the first module with plugin configuration in the dependency chain.
        Also, dependencies will only be added to the classpath if they are compile time dependencies, whereas a WAR artefact only needs runtime dependencies if it doesn't contain code that needs compiling.

        For me the only working workaround at the moment is to run "mvn tomcat7:run" directly in the directory of the webapp module.

        Show
        Arne Franken added a comment - > Don't clean your projects oops, of course you're right about that. > use only mvn -pl :dep-issue-webapp tomcat7:run (without -am) if you don't want to rebuild/recompile everything. if I don't use "-am", Tomcat will not have all necessary libraries in the classpath if I use "-am" , Tomcat will have all necessary libraries in the classpath, but this won't work if any of my dependencies are also WAR artefacts which also have a Tomcat configuration since Maven will run the Tomcat plugin for the first module with plugin configuration in the dependency chain. Also, dependencies will only be added to the classpath if they are compile time dependencies, whereas a WAR artefact only needs runtime dependencies if it doesn't contain code that needs compiling. For me the only working workaround at the moment is to run "mvn tomcat7:run" directly in the directory of the webapp module.
        Hide
        Loïc Guerrin added a comment -

        Hello,

        I have the same issue with tomcat7-maven-plugin:2.0. But it's during an integration test with junit. I have the structure below:

        /
        – project-domain
        – project-webapp

        The module project-domain isn't added to the classpath and the startup of the tomcat fails.
        In the maven debug log I see too 'skip adding artifact project-domain as it's in reactors'.

        In DefaultClassLoaderEntriesCalculator#calculateClassPathEntries at line 116, the method isInProjectReferences rejects the project-domain as it's in projectReferences of project-webapp.

        So is it possible to add a cheap workaround like a configuration parameter 'forceIncludeProjectReferences' in order to add those project references to module classpath?

        Thanks.

        Show
        Loïc Guerrin added a comment - Hello, I have the same issue with tomcat7-maven-plugin:2.0. But it's during an integration test with junit. I have the structure below: / – project-domain – project-webapp The module project-domain isn't added to the classpath and the startup of the tomcat fails. In the maven debug log I see too 'skip adding artifact project-domain as it's in reactors'. In DefaultClassLoaderEntriesCalculator#calculateClassPathEntries at line 116, the method isInProjectReferences rejects the project-domain as it's in projectReferences of project-webapp. So is it possible to add a cheap workaround like a configuration parameter 'forceIncludeProjectReferences' in order to add those project references to module classpath? Thanks.
        Show
        Olivier Lamy (*$^¨%`£) added a comment - fixed http://svn.apache.org/r1408507
        Hide
        Arne Franken added a comment -

        I just built 2.1-SNAPSHOT locally and can confirm that the issue is fixed. Thanks!

        Show
        Arne Franken added a comment - I just built 2.1-SNAPSHOT locally and can confirm that the issue is fixed. Thanks!

          People

          • Assignee:
            Olivier Lamy (*$^¨%`£)
            Reporter:
            Arne Franken
          • Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development