I just want to run a web project that has been configured in a maven project with the pom.xml. It uses the maven tomcat7-maven-plugin to deploy the web app artifact and all
I have added the following into server.xml and my application is working fine with tomcat7:run-war command:
<Host appBase="webapps" autoDeploy="true" deployXML="false"
name="localhost" unpackWARs="true">
<Context docBase="../../webApplicationName"
path="/webApplicationName" reloadable="true" />
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
Here is how I configure plug-in in pom.xml
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/</path>
<serverXml>src/main/tomcatconf/server.xml</serverXml>
<warDirectory>target/appName</warDirectory>
<webapps>
<webapp>
<groupId>com.abc</groupId>
<artifactId>appName</artifactId>
<version>7.0.1</version>
<type>war</type>
</webapp>
</webapps>
</configuration>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.5.5</version>
</dependency>
</plugin>
I have dropped server.xml
+ other config files into src/main/tomcatconf
directory (default value of plugin) and also have context.xml
into META-INF
dir and into src/main/tomcatconf
. The plugin seems to be picking up context.xml
from one of the directories.
Hope this works for you.
I think you can try this configuration
<project>
...
<build>
<finalName>servidor-identidades-webapp</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<server>myserver</server>
<url>http://127.0.0.1:8080/manager</url>
<path>/servidor-identidades-webapp</path>
<warSourceDirectory>C:/Users/fulanis/workspace2/web/target/servidor-identidades-webapp.jar</warSourceDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
Ref: https://wiki.base22.com/display/btg/How+to+create+a+Maven+web+app+and+deploy+to+Tomcat+-+fast
Hope this helps.
The tomcat7-maven-plugin documentation says for <serverXml>
:
server.xml to use Note if you use this you must configure in this file your webapp paths.
I think this means that you have to insert a <Context>
element with the path of your war inside the <Host>
element, like so:
<Host appBase="webapps" autoDeploy="true" deployXML="false" name="localhost" unpackWARs="true">
<Context docBase="../../webapp" path="/webapp" reloadable="true" />
</Host>
Where "webapp" is my generated war name. Apparently, appBase
is relative to target/tomcat
(and "webapps" seems to be the default value). docBase
is relative to appBase
so for simplicity I used the relative path to the build directory.
This is working for me, and without that <Context>
element I get a white page.
If you are using filtering you can probably replace docBase
by a property. However take care to exclude the server.xml (and tomcat-users.xml) from your war file!