Hi,
Because Log is not Serializable, you can't put it in the session.  So
making it transient is fine.  I also saw your reasoning for making it
dynamic rather than static.

Tomcat will save and restore your sessions across server restarts by
default.  That includes session attributes that are Serializable.  If
the Form was in the session, it will be deserialized: this is not the
same process as reconstruction.  So if you choose to stick with this
transient modifier, you will need to check for the log being null before
every time you use it.

Yoav Shapira
Millennium Research Informatics


>-----Original Message-----
>From: Richard Mixon (qwest) [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, July 13, 2004 6:26 PM
>To: Tomcat Users List
>Subject: RE: NPE in ActionForm where it is not be possible
>
>QM <mailto:[EMAIL PROTECTED]> wrote:
>> On Sat, Jul 10, 2004 at 12:31:21PM -0700, Richard Mixon (qwest)
wrote:
>>> The "log" variable is initialized when the Action form is
>>>   instantiated, like so: public class ChartWizardForm extends
>>>       ActionForm implements java.io.Serializable { private transient
>>> Log log =
>>> LogFactory.getLog(ChartWizardForm.class);
>>>       ...
>>>
>>> Obviously I'm missing something pretty basic. Is Tomcat re-using a
>>> form instance across restarts? I've got pretty much default settings
>>> in Tomcat:
>>
>> I notice, you define/initialize the instance variable "log" at its
>> declaration point.
>>
>> Humor me: what happens if you initialize "log" in the ctor?
>>
>> -QM
>
>I've had to look at higher priorities for a couple of days :)
>
>Thanks for the idea. I changed as follows:
>    ...
>    // private transient Log log =
>LogFactory.getLog(ChartWizardForm.class);
>    private transient Log log; // Logging instance for this class
>    ...
>
>    public ChartWizardForm() {
>        showInactive = false;
>        altClassMeasOrder = false;
>        ...
>        outputFmt="";
>        scaleFactor="";
>        log = LogFactory.getLog(ChartWizardForm.class); // <-- ADDED
>INITIALIZATION HERE
>    }
>    ...
>
>But, still get the NPE :(
>
>I'm defininig the instance variable as transient because Tomcat
>complains about saving sessions that contain a private instance
variable
>(non-transient) of type Log. I was trying to get my sessions to persist
>across restarts. Does that suggest anything?
>
>Thank you again - Richard
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]




This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to