从命令行重启tomcat与从IntelliJ IDEA重启不同

时间:2014-11-13 15:29:23

标签: java tomcat7 war

从命令行和IntelliJ IDEA重新启动tomcat有何不同?

我认为不是。但我发现当从命令行重新启动(/path/to/Tomcat/bin/restart.sh)然后请求Web应用程序时,我在日志中获取java.io.FileNotFoundException(catalina.out)

当我立即从IntelliJ IDEA中的内置终端重启tomcat (相同脚本:/path/to/Tomcat/bin/restart.sh)然后请求Web应用程序时,我得到了预期的结果

我尝试过的事情:

1)最初我认为这与我的WAR文件结构有关,但事实并非如此。

2)我在server.xml中删除了所有引用(开发时指向项目文件夹的上下文容器)。

3)然后我读了日志并且有一些泄漏警告,我通过正确关闭流来摆脱它们。

4)我添加了tomcat-native库。

5)同样的问题在这里解决了...... https://stackoverflow.com/a/17476283/1380304

每次尝试后结果相同。 IDEA的重启工作,cmd线没有。在尝试#3之前,我注意到从命令行和IDEA重新启动后,日志(catalina.out)中存在差异。使用IDEA时,它会运行一些额外的关闭命令。现在,重启后我得到了相同的日志:

calalina.out:

Nov 13, 2014 3:42:24 PM org.apache.catalina.core.StandardServer await
INFO: A valid shutdown command was received via the shutdown port. Stopping the Server instance.
Nov 13, 2014 3:42:24 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-8090"]
Nov 13, 2014 3:42:24 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-8443"]
Nov 13, 2014 3:42:24 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
Nov 13, 2014 3:42:24 PM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Nov 13, 2014 3:42:24 PM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-bio-8090"]
Nov 13, 2014 3:42:24 PM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-bio-8443"]
Nov 13, 2014 3:42:24 PM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["ajp-bio-8009"]
Nov 13, 2014 3:42:24 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-bio-8090"]
Nov 13, 2014 3:42:24 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-bio-8443"]
Nov 13, 2014 3:42:24 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-bio-8009"]
Nov 13, 2014 3:42:25 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8090"]
Nov 13, 2014 3:42:25 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8443"]
Nov 13, 2014 3:42:25 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Nov 13, 2014 3:42:25 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 760 ms
Nov 13, 2014 3:42:25 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Nov 13, 2014 3:42:25 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.55
Nov 13, 2014 3:42:25 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /usr/local/apache-tomcat-7.0.55/webapps/test.war
Nov 13, 2014 3:42:26 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deployment of web application archive /usr/local/apache-tomcat-7.0.55/webapps/test.war has finished in 1,055 ms
Nov 13, 2014 3:42:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/local/apache-tomcat-7.0.55/webapps/docs
Nov 13, 2014 3:42:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /usr/local/apache-tomcat-7.0.55/webapps/docs has finished in 56 ms
Nov 13, 2014 3:42:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/local/apache-tomcat-7.0.55/webapps/examples
Nov 13, 2014 3:42:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /usr/local/apache-tomcat-7.0.55/webapps/examples has finished in 264 ms
Nov 13, 2014 3:42:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/local/apache-tomcat-7.0.55/webapps/host-manager
Nov 13, 2014 3:42:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /usr/local/apache-tomcat-7.0.55/webapps/host-manager has finished in 51 ms
Nov 13, 2014 3:42:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/local/apache-tomcat-7.0.55/webapps/manager
Nov 13, 2014 3:42:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /usr/local/apache-tomcat-7.0.55/webapps/manager has finished in 49 ms
Nov 13, 2014 3:42:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/local/apache-tomcat-7.0.55/webapps/ROOT
Nov 13, 2014 3:42:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /usr/local/apache-tomcat-7.0.55/webapps/ROOT has finished in 50 ms
Nov 13, 2014 3:42:26 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8090"]
Nov 13, 2014 3:42:26 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8443"]
Nov 13, 2014 3:42:26 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Nov 13, 2014 3:42:26 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1593 ms

server.xml(其他配置不受影响):

<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">
<!--  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /> -->
  <Listener className="org.apache.catalina.core.JasperListener" />
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
  <GlobalNamingResources>
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>
  <Service name="Catalina">
    <Connector port="8090" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    <Connector
           port="8443" maxThreads="200"
           scheme="https" secure="true" SSLEnabled="true"
           keystoreFile="${user.home}/.keystore" keystorePass="****"
           clientAuth="false" sslProtocol="SSL" />
    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
    <Engine name="Catalina" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true" >
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
      </Host>
    </Engine>
  </Service>
</Server>

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

一次出现多个问题。

首先如java.io.FileNotFoundException所示,war结构存在问题。

第二个IDEA有自己手动安装的tomcat服务器,这让人感到很困惑。