• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How could a session attribute go missing without using removeAttribute()

 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any ideas how a session attribute could go missing ?

MyObject myOb = session.getAttribute("myAttribute");
.......
.......
if (myOb.myMethod()){
.....
//print out session.getAttributeNames()

the second line of code above throws a null pointer, and when printing all the attributes in the session "myAttribute" does not exist. yet it has been definatly been set and no-where in the code is "removeAttribute()" used.
 
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's tough to answer this without seeing the code. Could you being setting in one session and getting in another? Your attribute name is hard-coded. Could there be a spelling mistake? (Case matters. Also use a constant rather than hard-coding) When setting, could you be setting the attribute to null? How do you know the setting "definitely worked"? Does it work sometimes but not others? If so, in what situations does it work and not work? Did it previously work but now doesn't? If so what changed to make it not work?
 
Mark Wa
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the help tom. I cannot provide sample code because its a massive app. there are numerous places it's being set and got. Its a tough one as I dont know what actions the user is making to cause this.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The only ways this could happen is if the scoped variable is being removed by code, or different sessions are being queried.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

How are you setting the Attribute? Are there any calls to invalidate? What does getMaxInactiveInterval() give?
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mark Wa wrote:thanks for the help tom. I cannot provide sample code because its a massive app. there are numerous places it's being set and got. Its a tough one as I dont know what actions the user is making to cause this.


In that case I would add logging to the code to record user-generated events.
reply
    Bookmark Topic Watch Topic
  • New Topic