mvn tomcat7:run-war或tomcat:run-war给出404而没有日志

时间:2013-11-08 15:41:32

标签: java maven tomcat

我有一个让我疯狂的问题:

我有一个maven项目,(带有play2war插件的maven项目中的 play2 应用程序)

当我启动mvn tomcat7:run-wartomcat:run-war(我更改servlet容器)时,这是错误的:

    [INFO] Running war on http://localhost:8090/arhswfe
    [INFO] Creating Tomcat server configuration atC:\dev\projects\publicwebsite\sources\arhsweb\frontend\target\tomcat
    [INFO] create webapp with contextPath: /arhswfe
    Nov 08, 2013 4:30:55 PM org.apache.coyote.AbstractProtocol init
    INFO: Initializing ProtocolHandler ["http-bio-8090"]
    Nov 08, 2013 4:30:55 PM org.apache.catalina.core.StandardService startInternal
    INFO: Starting service Tomcat
    Nov 08, 2013 4:30:55 PM org.apache.catalina.core.StandardEngine startInternal
    INFO: Starting Servlet Engine: Apache Tomcat/7.0.37
    Nov 08, 2013 4:30:55 PM org.apache.tomcat.util.digester.Digester endElement
    WARNING:   No rules found matching 'Context/Logger'.
   Nov 08, 2013 4:30:56 PM org.apache.coyote.AbstractProtocol start
   INFO: Starting ProtocolHandler ["http-bio-8090"]

一切似乎都没问题,但当我在url上测试时,它会给我一个404no logs, 在一个独立的服务器上,没关系。

你有什么想法吗?我已经配置了所有可能的:

    <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.1</version>
        <configuration>
            <tomcatLoggingFile>D:/log.txt</tomcatLoggingFile>
            <warDirectory>${project.build.directory}</warDirectory>
            <update>true</update>
            <contextReloadable>true</contextReloadable>
            <port>8090</port>
            <warFile>arhswfe.war</warFile>
            <ignorePackaging>true</ignorePackaging>
            <contextFile>../configuration/context.xml</contextFile>
        </configuration>
     </plugin>

日志始终为空但没有错误,`404....

2 个答案:

答案 0 :(得分:1)

对于日志添加插件配置这部分

               <extraDependencies>
                    <dependency>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-api</artifactId>
                        <version>1.7.2</version>
                    </dependency>
                    <dependency>
                        <groupId>org.slf4j</groupId>
                        <artifactId>jul-to-slf4j</artifactId>
                        <version>1.7.2</version>
                    </dependency>
                    <dependency>
                        <groupId>log4j</groupId>
                        <artifactId>log4j</artifactId>
                        <version>1.2.17</version>
                    </dependency>
                </extraDependencies>

答案 1 :(得分:0)

使用<path>/</path>标记,以便您的配置变为:

       <configuration>
            <tomcatLoggingFile>D:/log.txt</tomcatLoggingFile>
            <warDirectory>${project.build.directory}</warDirectory>
            <update>true</update>
            <contextReloadable>true</contextReloadable>
            <port>8090</port>
            **<path>/</path>**
            <warFile>arhswfe.war</warFile>
            <ignorePackaging>true</ignorePackaging>
            <contextFile>../configuration/context.xml</contextFile>
        </configuration>