tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject DO NOT REPLY [Bug 52443] New: Tomcat#defaultRealm shares Realm instance between web applications, resulting in INFO log message from lifecycle
Date Mon, 09 Jan 2012 16:43:35 GMT

             Bug #: 52443
           Summary: Tomcat#defaultRealm shares Realm instance between web
                    applications, resulting in INFO log message from
           Product: Tomcat 7
           Version: unspecified
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: minor
          Priority: P2
         Component: Catalina
    Classification: Unclassified

Created attachment 28129

Inspired by this thread on dev@:
"problem using default Realm in new unit tests"

The problem is the following:

1. Tomcat.getDefaultRealm() is effectively a factory method for some Realm
instance. It creates this Realm once and caches it as Tomcat#defaultRealm

2. Tomcat.addWebapp() method calls ctx.setRealm(defaultRealm); for every
Context that it creates. Thus the Realm instance is shared between web

3. When Context starts it calls start() method on the realm. When the above
method was used to create several web applications then during the start of the
second and later ones the following message is logged:

09.01.2012 19:19:29 org.apache.catalina.util.LifecycleBase start
INFO: The start() method was called on component [Realm[Simple]] after start()
had already been called. The second call will be ignored.

To reproduce:
1) Apply attached patch to org.apache.catalina.startup.TestTomcat of trunk.
2) Run the test.
3) See the above "The start() method was called" message in the logs.

I think there are several ways to resolve this:
a) Do not call start() on the Realm if it is already started, as indicated by
b) Change Tomcat class to do not share the Realm instance between Contexts.
b.1) assign it to the Engine, or
b.2) create a new instance every time.

The a) way may lead to problems when the Context is stopped. It is not clear
whether the Realm shall be stopped or not. It it is stopped it will affect
another webapp. It may also cause problems with asynchronous start of contexts
implemented in 7.0.23+.

The b) way is consistent with what happens when server.xml is parsed.

Configure bugmail:
------- You are receiving this mail because: -------
You are the assignee for the bug.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message