Actually I put it more as a reminder for users who rely on an external Tomcat 
instance, not the embedded one most users prefer.
I kinda explained that at 
https://issues.apache.org/jira/browse/OFBIZ-5395?focusedCommentId=13824518

Since I investigated this last year, I decided to put what I discovered in code 
even if it's not useful/used OOTB.
Notably the default parameters and explanation about them. It's a kind of 
documentation in code if you want.
Maybe, to make things more clear, I should have commented out all lines.

I put a word in this page 
https://cwiki.apache.org/confluence/display/OFBTECH/Run+OFBiz+under+outside+Application+Servers
Maybe I could do better and extract this block of OOTB code to this page and 
explain things better there.
It seems it was what I wanted to do and did not finish completely. On the other hand it's maybe easier for external Tomcat users to have it there, not sure.
I could for instance put a link to the Jira comment above in the code to 
explain things better
and add this

@@ -203,6 +202,7 @@
         }
         try {
             server.setGlobalNamingContext(new InitialContext());
+ //server.addLifecycleListener(jreMemoryLeakPreventionListener); // Useless 
with OOTB Tomcat embedded, but useful when using an external Tomcat instance
         } catch (NamingException e) {
             throw new ContainerException(e);
         }

What do you think?

Jacques

Le 22/09/2014 14:38, Jacopo Cappellato a écrit :
Jacques,

I am wondering how your commit could have fixed the issue in the demo server: 
the code you have added create an instance of JreMemoryLeakPreventionListener 
but doesn't attach it to the server, so it is not used.

Jacopo

On Nov 17, 2013, at 10:01 PM, Jacques Le Roux <[email protected]> 
wrote:

Sorry again, BTW you are invited to try/use/break the demo trunk as most as 
possible ;)

On Sunday, November 17, 2013 9:59 PM Jacques Le Roux 
<[email protected]> wrote:
Sorry, the right initial address for Plumbr is http://plumbr.eu/

On Sunday, November 17, 2013 9:33 PM Jacques Le Roux 
<[email protected]> wrote:
BTW, I have installed Plumbr https://portal.plumbr.eu/ into the trunk demo 
(don't ask how :D )
It's running for more than a week, any leaks (no surprises)

Jacques

On Sunday, November 17, 2013 7:53 PM [email protected] <[email protected]> 
wrote:
Author: jleroux
Date: Sun Nov 17 18:53:17 2013
New Revision: 1542795

URL: http://svn.apache.org/r1542795
Log:
Adds the JreMemoryLeakPreventionListener, see 
https://issues.apache.org/jira/browse/OFBIZ-5395 for details

Modified:
   
ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java

Modified: 
ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java?rev=1542795&r1=1542794&r2=1542795&view=diff
============================================================================== 
---
ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java
 (original) +++
ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java
 Sun Nov 17 18:53:17 2013 @@ -44,6 +44,7
@@ import org.apache.catalina.Host;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.Manager;
import org.apache.catalina.connector.Connector;
+import org.apache.catalina.core.JreMemoryLeakPreventionListener;
import org.apache.catalina.core.StandardContext;
import org.apache.catalina.core.StandardEngine;
import org.apache.catalina.core.StandardHost;
@@ -140,7 +141,7 @@ import org.xml.sax.SAXException;
*/

/**
- * CatalinaContainer -  Tomcat 5
+ * CatalinaContainer -  Tomcat
*
*/
public class CatalinaContainer implements Container {
@@ -206,6 +207,17 @@ public class CatalinaContainer implement
            tomcat.enableNaming();
        }

+        //
https://tomcat.apache.org/tomcat-7.0-doc/config/listeners.html#JRE_Memory_Leak_Prevention_Listener_-_org.apache.catalina.core.JreMemoryLeakPreventionListener
+        // <<The JRE Memory Leak Prevention Listener provides work-arounds for 
known places where the Java Runtime environment
uses +        // the context class loader to load a singleton as this will 
cause a memory leak if a web application class loader
happens +        // to be the context class loader at the time.>> +        //
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java?view=annotate
 +
JreMemoryLeakPreventionListener jreMemoryLeakPreventionListener = new 
JreMemoryLeakPreventionListener(); +        // Mostly use
default config, but some specific cases here +        
jreMemoryLeakPreventionListener.setAppContextProtection(true); // True is
the default for Java 1.6, use false for Java from 1.7.0_02 onwards (see sources 
above) +
jreMemoryLeakPreventionListener.setGcDaemonProtection(false); // False because 
of
https://mail-archives.apache.org/mod_mbox/tomcat-users/201008.mbox/%[email protected]%3E
        +        jreMemoryLeakPreventionListener.setUrlCacheProtection(false); 
// False to keep the URLConnection cache, moot
        point + // configure JNDI in the StandardServer StandardServer server = 
(StandardServer) tomcat.getServer();
        try {
@@ -480,7 +492,7 @@ public class CatalinaContainer implement
        String protocol = ContainerConfig.getPropertyValue(connectorProp, "protocol", 
"HTTP/1.1");
        String address = ContainerConfig.getPropertyValue(connectorProp, "address", 
"0.0.0.0");
        int port = ContainerConfig.getPropertyValue(connectorProp, "port", 0) + 
ClassLoaderContainer.portOffset;
-
+
        boolean secure = ContainerConfig.getPropertyValue(connectorProp, 
"secure", false);
        if (protocol.toLowerCase().startsWith("ajp")) {
            protocol = "ajp";
@@ -540,7 +552,7 @@ public class CatalinaContainer implement

            try {
                for (ContainerConfig.Container.Property prop: 
connectorProp.properties.values()) {
-                    if ("port".equals(prop.name)) {
+                    if ("port".equals(prop.name)) {
                        connector.setProperty(prop.name, "" + port);
                    } else {
                        connector.setProperty(prop.name, prop.value);



Reply via email to