【问题标题】:mvn tomcat7:run-war or tomcat:run-war give a 404 and no logsmvn tomcat7:run-war 或 tomcat:run-war 给出 404 并且没有日志
【发布时间】:2013-11-08 15:41:31
【问题描述】:

我有一个问题让我抓狂:

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

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

    [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....

【问题讨论】:

  • 不,它不能解决我的问题,当我把我的战争部署在一个独立的 tomcat 中时它是好的,我使用 playframework2.1.4 并且只有命令 mvn tomcat:run-war 给我一个 404 页面并且没有日志或 mvn tomcat7:run-war 这让我在这上面花了 2 天的时间......

标签: java maven tomcat


【解决方案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>

【讨论】:

  • 谢谢我完成了这个任务我们可以结束讨论吗????感谢 ,但使用 play 框架最好使用 logback 而不是 log4J,因为默认情况下库在包中...
  • 我将 logback 放在额外的依赖项中,它对我有用
【解决方案2】:

使用&lt;path&gt;/&lt;/path&gt;标签,这样你的配置就变成了:

       <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>

【讨论】:

  • 谢谢,但我已经尝试过了,但没有可能,所以用 tomcat 6 是不可能的,用 tomcat 7 可以,谢谢,我不知道它可以....
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-08-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-31
相关资源
最近更新 更多