We're updating the issue view to help you get more done. 

The ContainerStopMojo cannot resolve dependencies with scope <test> whereas ContainerRunMojo and ContainerStartMojo can

Description

Based on user complaint: http://old.nabble.com/Cargo-1.1.4-error-when-stopping-a-test-scoped-Jetty-container-to33006113.html

We're using maven 2.2.1 with cargo on REST client & server Java packages, let's call it foo (all the pom goodness will be below). It's got separate foo-client and foo-server projects, and the client's integration test starts up an instance of the foo-server. When using version 1.1.3 of cargo, this works fine, but on 1.1.4 I get the following error when running the cargo:stop goal:
Artifact [com.opower:foo-server:war] is not a dependency of the project.

Can anybody help point me at the cause and a decent solution to this issue? I've found two workarounds for this issue, neither of which feels like an ideal solution:
1. adding a "<version>1.1.3</version>" specifier to cargo's <plugin> block causes the build to work fine
2. removing the cargo:stop goal and letting maven forcefully shut it down also works

I'm a bit of a maven n00b and I hope that I've included enough information to be helpful without writing a novel... if you scroll you'll see the foo-client pom, the maven output (v1.1.4), the maven output using version 1.1.3 with no failure, and finally the foo-server pom.

-Tyler

The project is set up with a parent pom.xml and the following child projects:

1 2 3 4 foo/ foo-parent/ foo-server/ foo-client/

foo-client's pom.xml:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.opower</groupId> <artifactId>foo-parent</artifactId> <version>1.6.0-SNAPSHOT</version> <relativePath>../foo-parent</relativePath> </parent> <artifactId>foo-client</artifactId> <packaging>jar</packaging> <version>1.6.0-SNAPSHOT</version> <name>Foo Service Client</name> <dependencies> <dependency> <groupId>${project.groupId}</groupId> <artifactId>foo-core</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>com.opower</groupId> <artifactId>foo-server</artifactId> <version>${project.version}</version> <type>war</type> <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <configuration> <container> <containerId>jetty6x</containerId> <type>embedded</type> </container> <configuration> <deployables> <deployable> <properties> <context>/</context> </properties> <groupId>com.opower</groupId> <artifactId>foo-server</artifactId> <type>war</type> </deployable> </deployables> </configuration> <wait>false</wait> </configuration> <executions> <execution> <id>start-container</id> <phase>pre-integration-test</phase> <goals> <goal>start</goal> </goals> </execution> <execution> <id>stop-container</id> <phase>post-integration-test</phase> <goals> <goal>stop</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>

Console output from running a build:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building Foo Service Client [INFO] task-segment: [clean, install] [INFO] ------------------------------------------------------------------------ [INFO] [clean:clean {execution: default-clean}] [INFO] Deleting directory /opt/git/shared/foo/foo-client/target [INFO] [svn-revision-number:revision {execution: default}] [INFO] inspecting /opt/git/shared/foo/foo-client [INFO] [resources:resources {execution: default-resources}] [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource [INFO] skip non existing resourceDirectory /opt/git/shared/foo/foo-client/version [INFO] skip non existing resourceDirectory /opt/git/shared/foo/foo-client/db/patches [INFO] skip non existing resourceDirectory /opt/git/shared/foo/foo-client/db/postpatches [INFO] skip non existing resourceDirectory /opt/git/shared/foo/foo-client/db/ami_schema [INFO] [compiler:compile {execution: default-compile}] [INFO] Compiling 7 source files to /opt/git/shared/foo/foo-client/target/classes [INFO] [checkstyle:checkstyle {execution: checkstyle}] [INFO] Starting audit... Audit done. [INFO] [scala:compile {execution: default}] [INFO] Checking for multiple versions of scala [INFO] includes = [**/*.scala,] [INFO] excludes = [] [WARNING] No source files found. [INFO] [resources:testResources {execution: default-testResources}] [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 19 resources [INFO] Copying 1 resource [INFO] [compiler:testCompile {execution: default-testCompile}] [INFO] Compiling 2 source files to /opt/git/shared/foo/foo-client/target/test-classes [INFO] [scala:testCompile {execution: default}] [INFO] Checking for multiple versions of scala [INFO] includes = [**/*.scala,] [INFO] excludes = [] [WARNING] No source files found. [INFO] [surefire:test {execution: default-test}] [INFO] Surefire report directory: /opt/git/shared/foo/foo-client/target/surefire-reports <unit tests omitted> [INFO] [jar:jar {execution: default-jar}] [INFO] Building jar: /opt/git/shared/foo/foo-client/target/foo-client-1.6.0-SNAPSHOT.jar [INFO] Preparing source:jar [WARNING] Removing: jar from forked lifecycle, to prevent recursive invocation. [INFO] [svn-revision-number:revision {execution: default}] [INFO] inspecting /opt/git/shared/foo/foo-client [WARNING] the "artifact.svn.info.repository" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix. [WARNING] the "artifact.svn.info.path" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix. [WARNING] the "artifact.svn.info.revision" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix. [WARNING] the "artifact.svn.info.mixedRevisions" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix. [WARNING] the "artifact.svn.info.committedRevision" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix. [WARNING] the "artifact.svn.info.committedDate" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix. [WARNING] the "artifact.svn.info.status" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix. [WARNING] the "artifact.svn.info.specialStatus" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix. [INFO] [source:jar {execution: attach-sources}] [INFO] Building jar: /opt/git/shared/foo/foo-client/target/foo-client-1.6.0-SNAPSHOT-sources.jar [INFO] [cargo:start {execution: start-container}] [INFO] [beddedLocalContainer] Jetty 6.x Embedded starting... <server startup and test output lines omitted> Tests run: 9, Failures: 0, Errors: 0, Skipped: 0 [INFO] [cargo:stop {execution: stop-container}] [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] Artifact [com.foo-server:war] is not a dependency of the project. [INFO] ------------------------------------------------------------------------ [INFO] For more information, run Maven with the -e switch [INFO] ------------------------------------------------------------------------ [INFO] Total time: 19 seconds [INFO] Finished at: Mon Dec 19 17:02:13 EST 2011 [INFO] Final Memory: 76M/145M [INFO] ------------------------------------------------------------------------ 2011-12-19 17:02:13.583:INFO::Shutdown hook executing 2011-12-19 17:02:13.583:INFO::Stopped SelectChannelConnector@0.0.0.0:8080 2011-12-19 17:02:13.590:INFO:/:Closing Spring root WebApplicationContext 2011-12-19 17:02:13,590 INFO [Shutdown] [] [r.spring.WebApplicationContext] Closing Root WebApplicationContext: startup date [Mon Dec 19 17:02:09 EST 2011]; root of context hierarchy 2011-12-19 17:02:13,590 DEBUG [Shutdown] [] [r.spring.WebApplicationContext] Publishing event in Root WebApplicationContext: org.springframework.context.event.ContextClosedEvent[source=Root WebApplicationContext: startup date [Mon Dec 19 17:02:09 EST 2011]; root of context hierarchy] 2011-12-19 17:02:13.608:INFO:/:Shutting down log4j log4j: [/private/var/folders/5g/_jfmsv892jl_3dcx3rvsy9xc0000gp/T/foo.server.1.6.0.SNAPSHOT.war____.gqkpbp/webapp/WEB-INF/classes/config/log4j.properties] does not exist. 2011-12-19 17:02:13.742:INFO::Shutdown hook complete

By specifying the 1.1.3 version of the cargo plugin, the same build cycle succeeds as shown here:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 $ mvn clean install [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building Foo Service Client [INFO] task-segment: [clean, install] [INFO] ------------------------------------------------------------------------ Unauthorized access prohibited. See http://opower.com/Warning.txt : Downloading: scp://mvn.opower.com/opt/releases/org/codehaus/cargo/cargo-maven2-plugin/1.1.3/cargo-maven2-plugin-1.1.3.pom [INFO] Unable to find resource 'org.codehaus.cargo:cargo-maven2-plugin:pom:1.1.3' in repository opower_releases (scp://mvn.opower.com/opt/releases) Downloading: http://scala-tools.org/repo-releases/org/codehaus/cargo/cargo-maven2-plugin/1.1.3/cargo-maven2-plugin-1.1.3.pom [INFO] Unable to find resource 'org.codehaus.cargo:cargo-maven2-plugin:pom:1.1.3' in repository scala-tools.org (http://scala-tools.org/repo-releases) Downloading: http://repo1.maven.org/maven2/org/codehaus/cargo/cargo-maven2-plugin/1.1.3/cargo-maven2-plugin-1.1.3.pom Unauthorized access prohibited. See http://opower.com/Warning.txt : Downloading: scp://mvn.opower.com/opt/releases/org/codehaus/cargo/cargo-maven2-plugin/1.1.3/cargo-maven2-plugin-1.1.3.jar [INFO] Unable to find resource 'org.codehaus.cargo:cargo-maven2-plugin:maven-plugin:1.1.3' in repository opower_releases (scp://mvn.opower.com/opt/releases) Downloading: http://scala-tools.org/repo-releases/org/codehaus/cargo/cargo-maven2-plugin/1.1.3/cargo-maven2-plugin-1.1.3.jar [INFO] Unable to find resource 'org.codehaus.cargo:cargo-maven2-plugin:maven-plugin:1.1.3' in repository scala-tools.org (http://scala-tools.org/repo-releases) Downloading: http://repo1.maven.org/maven2/org/codehaus/cargo/cargo-maven2-plugin/1.1.3/cargo-maven2-plugin-1.1.3.jar [INFO] [clean:clean {execution: default-clean}] [INFO] Deleting directory /opt/git/shared/foo/foo-client/target [INFO] [svn-revision-number:revision {execution: default}] [INFO] inspecting /opt/git/shared/foo/foo-client [INFO] [resources:resources {execution: default-resources}] [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource [INFO] skip non existing resourceDirectory /opt/git/shared/foo/foo-client/version [INFO] skip non existing resourceDirectory /opt/git/shared/foo/foo-client/db/patches [INFO] skip non existing resourceDirectory /opt/git/shared/foo/foo-client/db/postpatches [INFO] skip non existing resourceDirectory /opt/git/shared/foo/foo-client/db/ami_schema [INFO] [compiler:compile {execution: default-compile}] [INFO] Compiling 7 source files to /opt/git/shared/foo/foo-client/target/classes [INFO] [checkstyle:checkstyle {execution: checkstyle}] [INFO] Starting audit... Audit done. [INFO] [scala:compile {execution: default}] [INFO] Checking for multiple versions of scala [INFO] includes = [**/*.scala,] [INFO] excludes = [] [WARNING] No source files found. [INFO] [resources:testResources {execution: default-testResources}] [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 19 resources [INFO] Copying 1 resource [INFO] [compiler:testCompile {execution: default-testCompile}] [INFO] Compiling 2 source files to /opt/git/shared/foo/foo-client/target/test-classes [INFO] [scala:testCompile {execution: default}] [INFO] Checking for multiple versions of scala [INFO] includes = [**/*.scala,] [INFO] excludes = [] [WARNING] No source files found. [INFO] [surefire:test {execution: default-test}] [INFO] Surefire report directory: /opt/git/shared/foo/foo-client/target/surefire-reports <tests omitted> [INFO] [jar:jar {execution: default-jar}] [INFO] Building jar: /opt/git/shared/foo/foo-client/target/foo-client-1.6.0-SNAPSHOT.jar [INFO] Preparing source:jar [WARNING] Removing: jar from forked lifecycle, to prevent recursive invocation. [INFO] [svn-revision-number:revision {execution: default}] [INFO] inspecting /opt/git/shared/foo/foo-client [WARNING] the "artifact.svn.info.repository" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix. [WARNING] the "artifact.svn.info.path" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix. [WARNING] the "artifact.svn.info.revision" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix. [WARNING] the "artifact.svn.info.mixedRevisions" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix. [WARNING] the "artifact.svn.info.committedRevision" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix. [WARNING] the "artifact.svn.info.committedDate" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix. [WARNING] the "artifact.svn.info.status" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix. [WARNING] the "artifact.svn.info.specialStatus" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix. [INFO] [source:jar {execution: attach-sources}] [INFO] Building jar: /opt/git/shared/foo/foo-client/target/foo-client-1.6.0-SNAPSHOT-sources.jar [INFO] [cargo:start {execution: start-container}] [INFO] [beddedLocalContainer] Jetty 6.x Embedded starting... <server startup and integration tests omitted> [INFO] [cargo:stop {execution: stop-container}] [INFO] [beddedLocalContainer] Jetty 6.x Embedded is stopping... 2011-12-19 17:16:24.035:INFO::Stopped SelectChannelConnector@0.0.0.0:8080 2011-12-19 17:16:24.652:INFO:/:Closing Spring root WebApplicationContext 2011-12-19 17:16:24,652 INFO [Thread-22] [] [r.spring.WebApplicationContext] Closing Root WebApplicationContext: startup date [Mon Dec 19 17:16:20 EST 2011]; root of context hierarchy 2011-12-19 17:16:24,653 DEBUG [Thread-22] [] [r.spring.WebApplicationContext] Publishing event in Root WebApplicationContext: org.springframework.context.event.ContextClosedEvent[source=Root WebApplicationContext: startup date [Mon Dec 19 17:16:20 EST 2011]; root of context hierarchy] 2011-12-19 17:16:24.671:INFO:/:Shutting down log4j log4j: [/private/var/folders/5g/_jfmsv892jl_3dcx3rvsy9xc0000gp/T/Jetty_0_0_0_0_8080_foo.server.1.6.0.SNAPSHOT.war____.gqkpbp/webapp/WEB-INF/classes/config/log4j.properties] does not exist. [INFO] [beddedLocalContainer] Jetty 6.x Embedded is stopped [INFO] [install:install {execution: default-install}] [INFO] Installing /opt/git/shared/foo/foo-client/target/foo-client-1.6.0-SNAPSHOT.jar to /opt/.m2repository/com/opower/foo-client/1.6.0-SNAPSHOT/foo-client-1.6.0-SNAPSHOT.jar [INFO] Installing /opt/git/shared/foo/foo-client/target/foo-client-1.6.0-SNAPSHOT-sources.jar to /opt/.m2repository/com/opower/foo-client/1.6.0-SNAPSHOT/foo-client-1.6.0-SNAPSHOT-sources.jar [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 29 seconds [INFO] Finished at: Mon Dec 19 17:16:31 EST 2011 [INFO] Final Memory: 73M/142M [INFO] ------------------------------------------------------------------------ 2011-12-19 17:16:32.057:INFO::Shutdown hook executing 2011-12-19 17:16:32.057:INFO::Shutdown hook complete

And as a final postscript, the foo-server POM:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.opower</groupId> <artifactId>foo-parent</artifactId> <version>1.6.0-SNAPSHOT</version> <relativePath>../foo-parent</relativePath> </parent> <artifactId>foo-server</artifactId> <packaging>war</packaging> <name>Foo Server</name> <version>1.6.0-SNAPSHOT</version> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>${project.groupId}</groupId> <artifactId>foo-core</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-jaxrs</artifactId> </dependency> <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-spring</artifactId> </dependency> <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-jaxrs</artifactId> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> <version>6.1.22</version> </plugin> </plugins> </build> </project>

Status

Assignee

Savas Ali Tokmen

Reporter

Savas Ali Tokmen

Components

Fix versions

Affects versions

1.1.4

Priority

Major