NutzCN Logo
问答 正常启动nutz项目,出现死循环重启,导致内存溢出
发布于 313天前 作者 yssgithub 205 次浏览 复制 上一个帖子 下一个帖子
标签: tomcat log4j

提供这段从up到down间的日志,帮忙看看是什么原因造成的吧:
2016-12-12 22:32:27.783 INFO [localhost-startStop-1] Nutz.Mvc[nutz] is up in 908ms
十二月 12, 2016 10:32:27 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-8085"]
十二月 12, 2016 10:32:27 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-bio-8059"]
十二月 12, 2016 10:32:27 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 3391 ms
十二月 12, 2016 10:32:37 下午 org.apache.catalina.loader.WebappClassLoaderBase modified
信息: Additional JARs have been added : 'log4j-1.2.17.jar'
十二月 12, 2016 10:32:37 下午 org.apache.catalina.core.StandardContext reload
信息: Reloading Context with name [/nutzbook] has started
2016-12-12 22:32:37.804 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] Nutz.Mvc[nutz] is deposing ...
2016-12-12 22:32:37.805 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.nutz.ioc.impl.NutIoc@1900591011 is closing. startup date [16-12-12 22:32:26.990]
2016-12-12 22:32:37.806 DEBUG [ContainerBackgroundProcessor[StandardEngine[Catalina]]] Depose object 'dao' ...
2016-12-12 22:32:37.806 DEBUG [ContainerBackgroundProcessor[StandardEngine[Catalina]]] Depose object 'dataSource' ...
十二月 12, 2016 10:32:37 下午 com.alibaba.druid.pool.DruidDataSource info
信息: {dataSource-1} closed
2016-12-12 22:32:37.820 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.nutz.ioc.impl.NutIoc@1900591011 is deposed. startup date [16-12-12 22:32:26.990]
2016-12-12 22:32:37.821 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] Nutz.Mvc[nutz] is down in 16ms

16 回复

把tomcat的auto reload 关掉试试

reloadable="false"

我试了,貌似还是一样的问题

把context.xml发一下

<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
--><!-- The contents of this file will be loaded for each web application --><Context>

    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>

    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    <!--
    <Manager pathname="" />
    -->

    <!-- Uncomment this to enable Comet connection tacking (provides events
         on session expiration as well as webapp lifecycle) -->
    <!--
    <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
    -->

</Context>

server.xml也发一下

<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
--><!-- Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" at this level.
     Documentation at /docs/config/server.html
 --><Server port="8055" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener"/>
  <!-- Security listener. Documentation at /docs/config/listeners.html
  <Listener className="org.apache.catalina.security.SecurityListener" />
  -->
  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/>
  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
  <Listener className="org.apache.catalina.core.JasperListener"/>
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>

  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>
  </GlobalNamingResources>

  <!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container",
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  <Service name="Catalina">

    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
        maxThreads="150" minSpareThreads="4"/>
    -->


    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080
    -->
    <Connector connectionTimeout="20000" port="8085" protocol="HTTP/1.1" redirectPort="8443"/>
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    -->
    <!-- Define a SSL HTTP/1.1 Connector on port 8443
         This connector uses the BIO implementation that requires the JSSE
         style configuration. When using the APR/native implementation, the
         OpenSSL style configuration is required as described in the APR/native
         documentation -->
    <!--
    <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
               maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8059" protocol="AJP/1.3" redirectPort="8443"/>


    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
    -->
    <Engine defaultHost="localhost" name="Catalina">

      <!--For clustering, please take a look at documentation at:
          /docs/cluster-howto.html  (simple how to)
          /docs/config/cluster.html (reference documentation) -->
      <!--
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
      -->

      <!-- Use the LockOutRealm to prevent attempts to guess user passwords
           via a brute-force attack -->
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <!-- This Realm uses the UserDatabase configured in the global JNDI
             resources under the key "UserDatabase".  Any edits
             that are performed against this UserDatabase are immediately
             available for use by the Realm.  -->
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
      </Realm>

      <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t &quot;%r&quot; %s %b" prefix="localhost_access_log." suffix=".txt"/>

      <Context docBase="ShiroWeb6" path="/ShiroWeb6" reloadable="true" source="org.eclipse.jst.jee.server:ShiroWeb6"/></Host>
    </Engine>
  </Service>
</Server>

我的项目名是nutzbook,不是xml里面的ShiroWeb6

这不没改吗???

<Context docBase="ShiroWeb6" path="/ShiroWeb6" reloadable="true" source="org.eclipse.jst.jee.server:ShiroWeb6"/></Host>

eclipse里面启动tomcat的????

刚才这个也改过了,没效果

是啊,eclipse里面启动tomcat的

eclisep --> server view --> 双击tomcat, Modules auto reload by default 去掉.

貌似还是一样啊,时间比较晚了,您先去休息吧,我自己再看看吧

经过我自己昨晚跟今天早上详细对比了下,发现启动正常到第二次启动的转折点,日志信息:
十二月 12, 2016 10:32:37 下午 org.apache.catalina.loader.WebappClassLoaderBase modified
信息: Additional JARs have been added : 'log4j-1.2.17.jar'
所以我感觉应该是这个jar包的问题,到Web App Libraries下发现,log4j居然不能展开,没办法还是先到中央仓库去重新下一个新的,新旧替换后启动,发现问题解决了,而Web App Libraries下log4j也可以展开了。
再回头对比新旧log4j两个jar包,发现原来导致问题的jar包比新jar包小很多。

添加回复
请先登陆
回到顶部