Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 340006

Summary: Context configuration stops working when webapp is updated
Product: [RT] Virgo Reporter: Glyn Normington <glyn.normington>
Component: runtimeAssignee: Violeta Georgieva <milesg78>
Status: ASSIGNED --- QA Contact:
Severity: normal    
Priority: P3 CC: dmarthaler, fwaibel, milesg78
Version: unspecified   
Target Milestone: 3.8.0.M02   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
WAB
none
context configuration none

Description Glyn Normington CLA 2011-03-15 08:07:32 EDT
Created attachment 191205 [details]
WAB

With the attached WAB in pickup and the attached configuration in:

config/Catalina/localhost

the request dumper valve runs when localhost:8080/samplewab is invoked.

If the WAB is undeployed and redeployed, or simply refreshed, the request dumper valve no longer runs.

The request dumper valve may be seen in action by tailing serviceability/logs/log.log.
Comment 1 Glyn Normington CLA 2011-03-15 08:08:01 EDT
Created attachment 191206 [details]
context configuration
Comment 2 Glyn Normington CLA 2011-03-15 08:09:00 EDT
If Virgo Tomcat server is restarted, the request dumper valve then starts running again when the sample WAB is driven.
Comment 3 Violeta Georgieva CLA 2011-05-11 02:16:25 EDT
The problem is a bit different. Here is what happens:

When the application is undeployed, the following  method is invoked: 

org.eclipse.gemini.web.tomcat.internal.loading.BundleWebappClassLoader.clearReferences()

In this method we try to:
- Unregister JDBC drivers loaded by the web application's classloader
- Clear the IntrospectionUtils cache
- Clear the classloader reference in the VM's bean introspector
- Clear the classloader reference in common-logging

Actually the last one invokes:

org.apache.juli.logging.LogFactory.release(this);

This will invoke java.util.logging.LogManager to reset Loggers and to close all  Loggers' handlers.

In Virgo we use the default java.util.logging.LogManager so when the web application is undeployed all Loggers are reset and their handlers are closed.

When the application is deployed again and we make a request, RequestDumperValve tries to log, but there are no handlers that can process this invocation.

In pure Tomcat there is an extension of java.util.logging.LogManager called org.apache.juli.ClassLoaderLogManager

It is made in a way to reset only

org.apache.juli.ClassLoaderLogManager
        ...
327     private void resetLoggers(ClassLoaderLogInfo clLogInfo) {
328     // This differs from LogManager#resetLogger() in that we close not all
329     // handlers of all loggers, but only those that are present in our
330     // ClassLoaderLogInfo#handlers list. That is because our #addLogger(..)
331     // method can use handlers from the parent class loaders, and closing
332     // handlers that the current class loader does not own would be not
333     // good.
        ...

So I tried the following:
- Copied com.springsource.org.apache.juli.extras.springsource-6.0.29.S2-r1559.jar in <Virgo-Home-Dir>/lib
- Added the following to the <Virgo-Home-Dir>/bin/dmk.bat: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

Now I can see the RequestDumperValve logs always i.e. there is no problems any more. But with this LogManager I can see logs only in the console and not in the log files :(

So there two possible solutions:
- to make our java.util.logging.LogManager extension
- to remove org.apache.juli.logging.LogFactory.release(this) from BundleWebappClassLoader.clearReferences()
Comment 4 Glyn Normington CLA 2011-05-11 03:46:14 EDT
I am nervous about removing the release call from clearReferences as the purpose was to avoid a memory leak and the memory leak would probably return.
Comment 5 Violeta Georgieva CLA 2011-05-11 05:54:09 EDT
(In reply to comment #4)
> I am nervous about removing the release call from clearReferences as the
> purpose was to avoid a memory leak and the memory leak would probably return.

Yes I agree that removing release call from clearReferences method is not a good idea.
So we are going into direction to extend java.util.logging.LogManager?
Comment 6 Glyn Normington CLA 2011-05-11 07:19:36 EDT
Yes, that's seems like the best direction to explore.
Comment 7 Glyn Normington CLA 2011-07-19 07:08:25 EDT
Deferring to next release.
Comment 8 Glyn Normington CLA 2012-09-17 04:51:30 EDT
Since 3.5.0 has shipped, targeting 3.6.0. If this bug is more urgent, please target 3.5.1 and provide a fix.
Comment 9 Glyn Normington CLA 2012-12-19 05:28:02 EST
Missed 3.6.0, so targetting 3.7.0.
Comment 10 Florian Waibel CLA 2017-02-16 03:21:06 EST
Missed 3.7.0, so targetting 3.8.0.