tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Tulley" <JTUL...@novell.com>
Subject Tag library calls to reset & attr setters (was Re: NullPointer on getParameter)
Date Tue, 07 Oct 2003 22:24:12 GMT
This keeps coming up.  According to the spec, doStartTag, doEndTag, etc
can be called multiple times between calls to reset().  This happens on
Tomcat if you are doing tag pooling.  Some containers instead comply to
what people sometimes think is going on in that they call reset(),
doStartTag, doEndTag, repeat, each time.

An interesting thing that I learned from a friend the other day with
lots of experience (and pain) in the area of tag libraries is that, with
some containers (and in the spec???) the attribute setters are called
only one time per tag, if the tag attributes have not changed.  So, some
bugs come up from people changing the value of the variable that is used
internally to represent that attribute, thinking that the setter will be
called again on the next (pooled?) use of the tag.
You need to use a completely different variable if you are computing a
derived value from the attribute, and not touch the one the setter
method sets.

I had not known this and thought this would be a good time to pass it
on, in case it benefits somebody else.

- Jeff Tulley 

>>> zodiac@holoweb.net 10/7/03 1:01:50 PM >>>
So to wrap this one up, the problem turned out to be a tag that wasn't

resetting its state correctly -- or rather, was only doing so in its 
reset() method. All was fine with tag pooling turned off but with it on

the tag could wind up with inconsistent internal state. Cleaning up in

doEndTag() solved the problem. [I've added a note to that affect on bug

21611 as well.]

L.

Laurie Harper wrote:
> Sure, I'll update Bug# 21611 as I get more details.
> 
> L.
> 
> Bill Barker wrote:
> 
>> I just got a ton of these while doing a stress-test to try and get 
>> another
>> bug to crawl out from under it's rock ;-).  I believe that there is
a bug
>> here somewhere, but I'm currently chasing bug #1.  If your server
logs 
>> are
>> more interesting than mine (which don't say much more than NPE at
...),
>> could you at least post them as an attachment to a bugzilla report?
>>
>> "Laurie Harper" <zodiac@holoweb.net> wrote in message
>> news:bjo59g$nke$1@sea.gmane.org...
>>
>>> Agreed :-) But understanding the life cycle of CoyoteRequestFacade
may
>>> make it easier to do so. There's nothing particularly funky going
on in
>>> the code that's exhibiting the problem so I don't know yet what I
can
>>> pare away. I'm trying to get a local build of Tomcat set up so I
can add
>>> some tracing and narrow things down.
>>>
>>> L.
>>>
>>> Shapira, Yoav wrote:
>>>
>>>
>>>> Howdy,
>>>> The best thing is to come up with a way for us to reproduce it. 
The
>>>> simplest, most direct way to get the exception.
>>>>
>>>> Yoav Shapira
>>>> Millennium ChemInformatics
>>>>
>>>>
>>>>
>>>>
>>>>> -----Original Message-----
>>>>> From: Laurie Harper [mailto:zodiac@holoweb.net] 
>>>>> Sent: Tuesday, September 09, 2003 6:17 PM
>>>>> To: tomcat-user@jakarta.apache.org 
>>>>> Subject: NullPointer on getParameter
>>>>>
>>>>> Hi, I'm trying to figure out a problem we've encountered since
>>>>
>>>>
>>>> upgrading
>>>>
>>>>
>>>>> to Tomcat 4.1. I've seen this both on 4.1.24 and 4.1.27. I
haven't yet
>>>>> reduced it to a specific recipe for reproduction outside the 
>>>>> context of
>>>>> my application but I do see this quite frequently so I thought
I'd see
>>>>> if anyone else has come across it...
>>>>>
>>>>> The problem is that a call to getParameter is getting a
>>>>> NullPointerException in the delegation method on
CoyoteRequestFacade:
>>>>>
>>>>> Caused by:
>>>>> java.lang.NullPointerException
>>>>>       at org.apache.coyote.tomcat4.CoyoteRequestFacade.
>>>>> getParameter(CoyoteRequestFacade.java:178)
>>>>>       at javax.servlet.ServletRequestWrapper.
>>>>> getParameter(ServletRequestWrapper.java:203)
>>>>>
>>>>> I checked the code and line 178 just a call to the wrapped
>>>>
>>>>
>>>> CoyoteRequest
>>>>
>>>>
>>>>> object, meaning that reference is null. Now, there's only two
ways it
>>>>> could be null: a null reference was passed into
CoyoteRequestFacade's
>>>>> constructor, or CoyoteRequestFacade.clear() was called.
>>>>>
>>>>> As I understand it, a CoyoteRequestFacade should be associated
with a
>>>>> request when it starts and not released until the request has 
>>>>> completed
>>>>> so I'm leaning towards looking at the first possibility. Can
anyone
>>>>
>>>>
>>>> give
>>>>
>>>>
>>>>> me an overview of the 'life cycle' of CoyoteRequestFacade? Where
is it
>>>>> created, managed, assigned/reclaimed from a particular request,
etc?
>>>>>
>>>>> Better yet, has anyone run into this and found a solution? The
nearest
>>>>> thing I could find was Bug# 21611 which sounds like the same
problem.
>>>>
>>>>
>>>>> From the commentary, it doesn't look like there's a known cause
yet;
>>>>
>>>>
>>>>> what would be the best way to track this down (as I say, I can
>>>>
>>>>
>>>> reproduce
>>>>
>>>>
>>>>> the behaviour easily here)?
>>>>>
>>>>> Thanks,
>>>>>
>>>>> L.
>>>>>
>>>>>
>>>>>
>>>>>
---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail:
tomcat-user-unsubscribe@jakarta.apache.org 
>>>>> For additional commands, e-mail:
tomcat-user-help@jakarta.apache.org 
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> 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: tomcat-user-unsubscribe@jakarta.apache.org 
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message