Hi Guido

-----Original Message-----
From: Guido Jäkel [mailto:g.jae...@dnb.de] 
Sent: Saturday, July 23, 2016 8:38 AM
To: Tomcat Users List
Subject: Re: OutOfMemoryError: PermGen space - SOLVED

On 22.07.2016 19:15, Berneburg, Cris wrote:

> > The OutOfMemoryError in Tomcat Manager was caused by a
> > memory leak when Log4J did not terminate properly.  This
> > was due to my mistake of neglecting to set up the
> > necessary Log4J shutdown procedures.
> > 
> > Adding Log4jServletContextListener and log4jServletFilter
> > to my app's web.xml solved the problem.  The Find Leaks
> > button on the Tomcat Manager page confirmed.
>
> Dear Chris,
>
> may you add here a short snipped of your additions to the
> web.xml, please? As Mark said, this may also a good and
> convenient reference for others.

Sure.  Please keep in mind this info may become stale as Log4J is maintained.  
At the time of publishing, Log4J was at version 2.6.2.

> From the log4j2 web site:
> 
> https://logging.apache.org/log4j/2.x/manual/webapp.html

[SNIP]

> you'll need to add the log4j-web module to your deployment [...]
> To avoid problems the Log4j shutdown hook will automatically be 
> disabled when the log4j-web jar is included.

[SNIP]

> If you are using Log4j in a Servlet 2.5 web application, or if you
> have disabled auto-initialization with the
> isLog4jAutoInitializationDisabled context parameter, you must
> configure the Log4jServletContextListener and Log4jServletFilter in
> the deployment descriptor or programmatically.

[SNIP]

[BEGIN BLOCK QUOTE]

<listener>
        
<listener-class>org.apache.logging.log4j.web.Log4jServletContextListener</listener-class>
</listener>

<filter>
        <filter-name>log4jServletFilter</filter-name>
        
<filter-class>org.apache.logging.log4j.web.Log4jServletFilter</filter-class>
</filter>
<filter-mapping>
        <filter-name>log4jServletFilter</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
        <dispatcher>ERROR</dispatcher>
        <dispatcher>ASYNC</dispatcher><!-- Servlet 3.0 w/ disabled 
auto-initialization only; not supported in 2.5 -->
</filter-mapping>

[END BLOCK QUOTE]

Since we currently use Tomcat 6, which supports the servlet 2.5 specs (I 
think), we commented out the ASYNC dispatcher filter-mapping option.

--
Cris Berneburg
CACI Lead Software Engineer


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to