简体   繁体   English

Tomcat7 + Maven插件:Tomcat不会以我的战争开始

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

I'm using java 8 and tomcat 7 and maven 3.3.9 with the maven tomcat plugin: 我正在使用java 8tomcat 7maven 3.3.9与maven tomcat插件:

<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. 有一段时间一切正常, tomcat7:run-war工作。

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? 谁负责在我的目标目录中编写tomcat配置,为什么不写?

Execute mvn clean in order to clean target dir. 执行mvn clean以清理目标目录。

Then try again, the tomcat-maven-plugin would re-create the tomcat folder (including the file tomcat-users.xml ). 然后再试一次,tomcat-maven-plugin将重新创建tomcat文件夹(包括文件tomcat-users.xml )。

Just delete the target folder from your application and run your app again. 只需从应用程序中删除目标文件夹,然后再次运行您的应用。 It works for me. 这个对我有用。

You can try creating a file for tomcat users in: 您可以尝试在以下位置为tomcat用户创建文件:

/Users/shikloshi/java_workspace/webapp-examples/tomcat-example/target/tomcat/conf/

And then adding this into it: 然后将其添加到其中:

<?xml version="1.0" encoding="UTF-8"?>
<tomcat-users>
 <role rolename="tomcat"/>
 <role rolename="admin"/>
 <role rolename="manager"/>
 <user  username="admin" password="admin" roles="tomcat,admin,manager"/>
</tomcat-users>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM