Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat7 + Maven plugin: Tomcat will not start with my war

Tags:

java

maven

tomcat

I'm using java 8 and tomcat 7 and maven 3.3.9 with the maven tomcat plugin:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <port>8085</port>
            </configuration>
        </plugin>
    </plugins>
</build>

For a while everything worked just fine and tomcat7:run-war worked.

And now I'm getting this error for no apparent reason:

[INFO] --- tomcat7-maven-plugin:2.2:run-war (default-cli) @ tomcat-example ---
[INFO] Running war on http://localhost:8085/tomcat-example
[INFO] Using existing Tomcat server configuration at /Users/shikloshi/java_workspace/webapp-examples/tomcat-example/target/tomcat
[INFO] create webapp with contextPath: /tomcat-example
Jul 04, 2016 2:30:45 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8085"]
Jul 04, 2016 2:30:45 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Tomcat
Jul 04, 2016 2:30:45 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.693s
[INFO] Finished at: Mon Jul 04 14:30:45 IDT 2016
[INFO] Final Memory: 17M/307M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:run-war (default-cli) on project tomcat-example: Could not start Tomcat: Failed to start component [StandardServer[-1]]: Failed to start component [StandardService[Tomcat]]: Failed to start component [StandardEngine[Tomcat]]: Failed to start component [Realm[MemoryRealm]]: Memory database file /Users/shikloshi/java_workspace/webapp-examples/tomcat-example/target/tomcat/conf/tomcat-users.xml cannot be read -> [Help 1]

This is the error:

Tomcat: Failed to start component [StandardServer[-1]]: Failed to start component [StandardService[Tomcat]]: Failed to start component [StandardEngine[Tomcat]]: Failed to start component [Realm[MemoryRealm]]: Memory database file /Users/shikloshi/java_workspace/webapp-examples/tomcat-example/target/tomcat/conf/tomcat-users.xml cannot be read -> [Help 1]

Who is responsible for writing the tomcat configuration inside my target dir and why is it not written?

like image 388
Shikloshi Avatar asked Jul 04 '16 11:07

Shikloshi


People also ask

What is tomcat7 Maven plugin?

The Tomcat7 Maven Plugin provides goals to manipulate WAR projects within the Tomcat servlet container version 7.x.

Is Apache Tomcat Open source?

The Apache Tomcat® software is an open source implementation of the Jakarta Servlet, Jakarta Server Pages, Jakarta Expression Language, Jakarta WebSocket, Jakarta Annotations and Jakarta Authentication specifications. These specifications are part of the Jakarta EE platform.


2 Answers

Execute mvn clean in order to clean target dir.

Then try again, the tomcat-maven-plugin would re-create the tomcat folder (including the file tomcat-users.xml).

like image 79
Alfergon Avatar answered Sep 18 '22 14:09

Alfergon


Just delete the target folder from your application and run your app again. It works for me.

like image 37
Ravindra Avatar answered Sep 22 '22 14:09

Ravindra