1
votes

I'm trying to deploy a war to an embedded tomcat server via the tomcat maven plugin. The console shows the server starts up fine.

It seems the war is not deployed. I get a HTTP Status 404 from Tomcat when I access http://localhost:9090/foo and http://localhost:9090

I see no war file or exploded war file in target/tomcat/webapps

My configuration is a bit (very) non standard due to factors out of my control:

  • The project uses other means than Maven to build the war file.
  • The project is not setup according to Maven standards.
  • The project has a package type of POM.

POM:

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.foo</groupId>
    <artifactId>foo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>iCON</name>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <ignorePackaging>true</ignorePackaging>
                    <warFile>foo.war</warFile>
                    <port>9090</port>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Output of mvn tomcat7:run

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building foo 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> tomcat7-maven-plugin:2.2:run (default-cli) > process-classes @ foo >>>
[INFO]
[INFO] <<< tomcat7-maven-plugin:2.2:run (default-cli) < process-classes @ foo <<<
[INFO]
[INFO] --- tomcat7-maven-plugin:2.2:run (default-cli) @ foo ---
[INFO] Running war on http://localhost:9090/foo
[INFO] Creating Tomcat server configuration at C:\someDir\aProject\target\tomcat
[INFO] create webapp with contextPath: /foo
Apr 15, 2015 12:50:56 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-9090"]
Apr 15, 2015 12:50:56 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Tomcat
Apr 15, 2015 12:50:56 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
Apr 15, 2015 12:50:58 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-9090"]
1

1 Answers

1
votes

I managed to deploy a war on an embedded tomcat using the same plugin as you some weeks ago.

My configuration is the following

<build>
<finalName>MSHAService</finalName>
<plugins>
  <plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
      <url>http://localhost:8080/manager/text</url>
      <server>localhost</server>
      <path>/MSHA</path>
      <username>user-acc-in-tomcat</username>
      <password>some-password</password>
    </configuration>
  </plugin>
</plugins>

You might miss some of the parameters from the configuration.

Also, you say that you get HTTP Status 404 when you access http://localhost:9090/foo and http://localhost:9090

You are looking on the console logs but looking in access logs might give you more information about this. See more about tomcat logs here: https://tomcat.apache.org/tomcat-8.0-doc/logging.html