tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 7850] New: - Can not access env-entries by using JNDI when Tomcat de-serializes sesssions
Date Mon, 08 Apr 2002 20:09:59 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7850>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7850

Can not access env-entries by using JNDI when Tomcat de-serializes sesssions

           Summary: Can not access env-entries by using JNDI when Tomcat de-
                    serializes sesssions
           Product: Tomcat 4
           Version: 4.0.3 Final
          Platform: PC
               URL: http://http://
        OS/Version: Linux
            Status: NEW
          Severity: Critical
          Priority: Other
         Component: Catalina
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: fbellas@udc.es


SORRY !!! - I resend the bug report. The previous bug report had a "bug". I
wanted to say: "lookup throws an exception", instead ·of "lookup returns null".

* Short description
  -----------------

When sessions are de-serialized (from SESSIONS.ser), *just in that moment*, it
is not possible to access env-entries by using JNDI (lookup throws an exception).

* Full description
  ----------------

My web application (distributable) inserts a serializable object of type X in
the user session. The corresponding class (X) has a static block which
initializes a static attribute by reading an env-entry (using JNDI). Of course,
I know that static attributes are not saved for a serializable class. In a
normal scenario, all works fine. OK ?

For the explanation, assume that there is only one active session. If I stop
Tomcat (shutdown.sh), the object in the session is serialized and stored in
$TOMCAT_HOME/work/localhost/MyWebApplication/SESSIONS.ser. If now I start Tomcat
again (startup.sh), Tomcat de-serializes the object from SESSIONS.ser. Just
before the de-serialization occurs, the class loader loads the class X (still
not loaded at this moment), and the static block is executed. The static block
tries to read an env-entry, and the lookup operation throws an exception (it
should return an String). In other words, when Tomcat starts and re-creates
sessions from SESSIONS.ser, *just in that moment*, env-entries are still not
initialized. If now I invalidate the session and reload the web application
(with the Tomcat manager application), all works fine (the static block is
executed again the first time the class is referenced, and accesses env-entries
without problems). I have checked this scenario inserting System.out.println's
in the static block and having a look at catalina.log. Note that this
explanation has nothing to do with the use of static block. This error would
still occur if I redefine serialization for class X, by redefining readObject,
and try to access env-entries from it. Summing up, the problem is that
env-entries are not initialized when de-serialization of sessions occur.

If you are curious why I use a static block in class X, which initializes a
static attribute, the reason it is that this block initializes a configuration
parameter which is the same for all instances.

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message