The Tomcat7 Maven Plugin provides goals to manipulate WAR projects within the Tomcat servlet container version 7.x.
Like many of its functionalities, Maven provides Tomcat-specific goals through the use of independently developed plugins. There are currently two Tomcat plugins available for Maven.
The Maven WAR plugin is responsible for collecting and compiling all the dependencies, classes, and resources of the web application into a web application archive. There are some defined goals in the Maven WAR plugin: war: This is the default goal that is invoked during the packaging phase of the project.
It work for me as the following.
My setting.xml
<server>
<id>local_tomcat</id>
<username>ray</username>
<password>password</password>
</server>
My plugin configuration
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<server>local_tomcat</server>
<url>http://localhost:8080/manager/text</url>
</configuration>
</plugin>
My tomcat-users.xml
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user password="password" roles="manager-gui, manager-script" username="ray"/>
i use the official Tomcat7 Maven Plugin from Apache as follows:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<path>/${project.artifactId}</path>
<port>8080</port>
</configuration>
</plugin>
and to run it: mvn tomcat7:run
There is t7mp - a Tomcat 7 Maven Plugin - on Google code.
Cargo (and its Cargo Maven2 Plugin) also has support for Tomcat 7 (this was CARGO-790).
Apache Tomcat Maven Plugin 2.0-beta-1 supports Tomcat 7.
Using maven cargo your can coufigure your project that way :
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0.6</version>
<configuration>
<container>
<containerId>tomcat7x</containerId>
<type>installed</type>
<home>${catalina.home}</home>
</container>
<configuration>
<type>existing</type>
<home>${catalina.home}</home>
</configuration>
<deployer>
<type>installed</type>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<type>war</type>
</deployable>
</deployables>
</deployer>
</configuration>
</plugin>
don't forget to configure your catalina.home
property
The you can deploy it using:
mvn cargo:deploy
There is the Tomcat Maven Plugin 7 plugin developed by the Apache Tomcat team.
Currently you have to checkout the sources and install it to your local repository. After that you can use it in the plugin section of your pom:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0-SNAPSHOT</version>
<executions>
<execution>
<id>start-tomcat</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<path>/</path>
<serverXml>src/main/tomcatconf/server.xml</serverXml>
</configuration>
</execution>
</executions>
</plugin>
After I had this error for three days in a row, here's my solution:
The user you are using to connect needs at least the role manager-script. In your /conf/tomcat-users.xml
<role rolename="manager-script"/>
<user username="test" password="test" roles="manager-script"/>
In your pom.xml, include the following plugin
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<url>http://server.url:8080/manager/text</url>
<path>/YourApp</path>
<username>test</username>
<password>test</password>
</configuration>
</plugin>
Contrary to what I found in the internet you DON'T need to edit your maven setting.xml. The tomcat7-maven-plugin can be configured directly in the configuration-tag
A word to the url-tag: I tested the suffix
of which only /manager/text worked
My versions:
I'm using tomcat7-maven-plugin for my embedded tomcat instance. Here is how I have configured it. Since my app requires jaas authentication I can also provide that in the setting itself.
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<!-- http port -->
<port>8080</port>
<path>/gcs-explorers</path>
<contextFile>${basedir}/src/main/webapp/META-INF/context.xml</contextFile>
<addWarDependenciesInClassloader>true</addWarDependenciesInClassloader>
<systemProperties>
<java.security.auth.login.config>${basedir}/conf/jaas.config</java.security.auth.login.config>
</systemProperties>
<url>http://127.0.0.1:8080/manager/html</url>
<username>admin</username>
<password>admin</password>
<addContextWarDependencies>true</addContextWarDependencies>
<addWarDependenciesInClassloader>true</addWarDependenciesInClassloader>
<configurationDir>${basedir}</configurationDir>
</configuration>
<dependencies>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>2.2.0</version>
<type>jar</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.company.package.jaas</groupId>
<artifactId>gcs-jaas</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>jar</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.company.gcs</groupId>
<artifactId>package-file-share</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>war</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With