You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Carsten Krebs <ca...@gameduell.de> on 2007/04/27 21:59:46 UTC
running webapp (war) in a multiproject environment
Hi,
I'm trying to run a maven build war file using one of the container plugins (cargo, tomcat or jetty). While this works fine in single project setup, I don't know how to get it properly work in multi project setup, if I have dependencies from the war module to at least on other child project. The multiproject setup I'm using is similar to the following (pom file are below):
parent (pom) / child1 (jar)
/ child2 (war)
where the child2 module depends on the module child1.
Building and packaging all modules from the top-level project works fine, but starting the webapp (child2.war) is not possible. Running a "mvn tomcat:run" from inside of module "child2" results in the following error:
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'tomcat'.
[INFO] ----------------------------------------------------------------------------
[INFO] Building Unnamed - example:child2:war:1.0-SNAPSHOT
[INFO] task-segment: [tomcat:run]
[INFO] ----------------------------------------------------------------------------
[INFO] Preparing tomcat:run
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.
Missing:
----------
1) example:child1:jar:1.0-SNAPSHOT
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=example -DartifactId=child1 \
-Dversion=1.0-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file
Path to dependency:
1) example:child2:war:1.0-SNAPSHOT
2) example:child1:jar:1.0-SNAPSHOT
----------
1 required artifact is missing.
for artifact:
example:child2:war:1.0-SNAPSHOT
As far I understand maven, this error is comprehensible, because when running maven from inside of the child module, maven doesn't know how to build the child1 dependency. So I would think, that running "mvn tomcat:run" from inside of the top-level module would be more appropriate. But this isn't possible, too, because the top-level module doesn't know anything about the maven-tomcat-plugin. For sure, I can solve this problem, by running a "mvn install" first, go into the child2 module and run a "mvn tomcat:run". This seems to me a little bit too complicated.
So I wonder if there something wrong with my project setup or if there is better way to run the webapp using maven?
Carsten
===
top-level module
----------------
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>example</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>child1</module>
<module>child2</module>
</modules>
<properties>
<example.version>${project.version}</example.version>
</properties>
</project>
child1
------
<?xml version="1.0" encoding="UTF-8"?>
<project>
<parent>
<groupId>example</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>example</groupId>
<artifactId>child1</artifactId>
<packaging>jar</packaging>
</project>
child2
------
<?xml version="1.0" encoding="UTF-8"?>
<project>
<parent>
<groupId>example</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>example</groupId>
<artifactId>child2</artifactId>
<packaging>war</packaging>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<container>
<containerId>tomcat5x</containerId>
<home>/opt/apache-tomcat-5.5.17</home>
</container>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>example</groupId>
<artifactId>child1</artifactId>
<version>${example.version}</version>
</dependency>
</dependencies>
</project>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org