Apache Tomcat Maven Plugin
  1. Apache Tomcat Maven Plugin
  2. MTOMCAT-106

tomcat7-maven-plugin extraDependency not working with class not found

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-beta-1
    • Fix Version/s: 2.0-beta-1
    • Component/s: tomcat7
    • Environment:
      Ubuntu 11.04 @32bit with Maven 2.2.1 and Java 1.6.0_26

      Description

      Hello,

      I'm trying to use the 'exec-war-only' goal from version 2.0-SNAPSHOT of tomcat7-maven-plugin, taken from
      http://people.apache.org/repo/m2-snapshot-repository

      Needing derby, I would use the extraDependencies configuration element as showed in the second example at:
      http://tomcat.apache.org/maven-plugin-2.0-SNAPSHOT/executable-war-jar.html

      Here's my configuration:

      <plugin>
      <groupId>org.apache.tomcat.maven</groupId>
      <artifactId>tomcat7-maven-plugin</artifactId>
      <version>2.0-SNAPSHOT</version>
      <executions>
      <execution>
      <id>tomcat-run</id>
      <goals>
      <goal>exec-war-only</goal>
      </goals>
      <phase>package</phase>
      <configuration>
      <path>/$

      {project.artifactId}

      </path>
      <enableNaming>true</enableNaming>
      <extraDependencies>
      <extraDependency>
      <groupId>org.apache.derby</groupId>
      <artifactId>derby</artifactId>
      <version>10.8.2.2</version>
      </extraDependency>
      </extraDependencies>
      </configuration>
      </execution>
      </executions>
      </plugin>

      So I launch "mvn clean package -e" and get:

      org.apache.maven.lifecycle.LifecycleExecutionException: Error configuring: org.apache.tomcat.maven:tomcat7-maven-plugin. Reason: Unable to parse the created DOM for plugin configuration
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:723)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
      at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
      at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
      at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
      at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
      at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
      at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
      Caused by: org.apache.maven.plugin.PluginConfigurationException: Error configuring: org.apache.tomcat.maven:tomcat7-maven-plugin. Reason: Unable to parse the created DOM for plugin configuration
      at org.apache.maven.plugin.DefaultPluginManager.populatePluginFields(DefaultPluginManager.java:1363)
      at org.apache.maven.plugin.DefaultPluginManager.getConfiguredMojo(DefaultPluginManager.java:724)
      at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:468)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
      ... 17 more
      Caused by: org.codehaus.plexus.component.configurator.ComponentConfigurationException: Error loading class 'org.apache.tomcat.maven.plugin.tomcat7.run.ExtraDependency'
      at org.codehaus.plexus.component.configurator.converters.composite.CollectionConverter.fromConfiguration(CollectionConverter.java:170)
      at org.codehaus.plexus.component.configurator.converters.ComponentValueSetter.configure(ComponentValueSetter.java:247)
      at org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.processConfiguration(ObjectWithFieldsConverter.java:137)
      at org.codehaus.plexus.component.configurator.BasicComponentConfigurator.configureComponent(BasicComponentConfigurator.java:56)
      at org.apache.maven.plugin.DefaultPluginManager.populatePluginFields(DefaultPluginManager.java:1357)
      ... 20 more
      Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.maven.plugin.tomcat7.run.ExtraDependency
      at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      at org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmClassLoader.java:195)
      at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:255)
      at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:274)
      at org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLoader.java:214)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
      at org.codehaus.plexus.component.configurator.converters.composite.CollectionConverter.fromConfiguration(CollectionConverter.java:158)
      ... 24 more

      Then I tried to get sources and build myself a plugin newer-than-the-latest-snapshot, but it failed on execution just as the snapshot

      So, I forked the mirror you have on github and hacked a patch that just works for me and follows the syntax found for another similar snippet (<warRunDependencies>)
      This is because I'm a power linux user and mid-level web designer, rather than a Java programmer, so I didn't manage to follow a different way to get it work

      Here is the pull request with the patch:
      https://github.com/apache/tomcat-maven-plugin/pull/1/files

        Activity

        Hide
        William Ghelfi added a comment -

        Thank you, works fine

        Show
        William Ghelfi added a comment - Thank you, works fine
        Hide
        Hudson added a comment -

        Integrated in TomcatMavenPlugin #66 (See https://builds.apache.org/job/TomcatMavenPlugin/66/)
        MTOMCAT-106 tomcat7-maven-plugin extraDependency not working with class not found
        attached patch not used, implements a more simple solution.

        olamy : http://svn.apache.org/viewvc/?view=rev&rev=1203144
        Files :

        • /tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java
        • /tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/ExtraDependency.java
        Show
        Hudson added a comment - Integrated in TomcatMavenPlugin #66 (See https://builds.apache.org/job/TomcatMavenPlugin/66/ ) MTOMCAT-106 tomcat7-maven-plugin extraDependency not working with class not found attached patch not used, implements a more simple solution. olamy : http://svn.apache.org/viewvc/?view=rev&rev=1203144 Files : /tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java /tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/ExtraDependency.java
        Hide
        Olivier Lamy (*$^¨%`£) added a comment -

        patch not used. Implemented with a more easy solution.
        SNAPSHOT deployed to http://repository.apache.org/content/groups/snapshots-group/

        reopen if you still have issue.

        Show
        Olivier Lamy (*$^¨%`£) added a comment - patch not used. Implemented with a more easy solution. SNAPSHOT deployed to http://repository.apache.org/content/groups/snapshots-group/ reopen if you still have issue.
        Hide
        William Ghelfi added a comment -

        Thank you
        At the moment I have to keep the software I'm co-working on, at version 2.2.1 because it's quite complex and many components and features need to be re-thinked before we can upgrade to mvn 3.

        We will approach mvn 3 during 2012 for sure, but for the next release we really look forward for your fix

        Thank you again for your great work and quick response

        Show
        William Ghelfi added a comment - Thank you At the moment I have to keep the software I'm co-working on, at version 2.2.1 because it's quite complex and many components and features need to be re-thinked before we can upgrade to mvn 3. We will approach mvn 3 during 2012 for sure, but for the next release we really look forward for your fix Thank you again for your great work and quick response
        Hide
        Olivier Lamy (*$^¨%`£) added a comment -

        ok. fyi You won't have this issue with 3.x
        BTW I have to fix that

        Show
        Olivier Lamy (*$^¨%`£) added a comment - ok. fyi You won't have this issue with 3.x BTW I have to fix that
        Hide
        William Ghelfi added a comment -

        Yep, 2.2.1

        Show
        William Ghelfi added a comment - Yep, 2.2.1
        Hide
        Olivier Lamy (*$^¨%`£) added a comment -

        you are using mvn 2.x ?

        Show
        Olivier Lamy (*$^¨%`£) added a comment - you are using mvn 2.x ?
        Hide
        William Ghelfi added a comment -

        Me too!
        But due to my (great) lack of skills as a Java programmer, I was unable to obtain the desired set of classes... so I just sticked with what I found for warDependencies and hacked the code with a bit of copy & paste & rename

        Maybe you can properly refactor the patch?

        Show
        William Ghelfi added a comment - Me too! But due to my (great) lack of skills as a Java programmer, I was unable to obtain the desired set of classes... so I just sticked with what I found for warDependencies and hacked the code with a bit of copy & paste & rename Maybe you can properly refactor the patch?
        Hide
        Olivier Lamy (*$^¨%`£) added a comment -

        to prevent too much complicated xml configuration.
        I would prefer : ExtraDependency extend Dependency

        Show
        Olivier Lamy (*$^¨%`£) added a comment - to prevent too much complicated xml configuration. I would prefer : ExtraDependency extend Dependency
        Hide
        William Ghelfi added a comment - - edited

        Just attached a patch

        For a prettified preview, go to:

        https://github.com/apache/tomcat-maven-plugin/pull/1/files

        Show
        William Ghelfi added a comment - - edited Just attached a patch For a prettified preview, go to: https://github.com/apache/tomcat-maven-plugin/pull/1/files
        Hide
        Olivier Lamy (*$^¨%`£) added a comment -

        please attach a patch file and check "Grant license to ASF for inclusion in ASF works (as per the Apache License §5)"

        Thanks!

        Show
        Olivier Lamy (*$^¨%`£) added a comment - please attach a patch file and check "Grant license to ASF for inclusion in ASF works (as per the Apache License §5)" Thanks!

          People

          • Assignee:
            Olivier Lamy (*$^¨%`£)
            Reporter:
            William Ghelfi
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development