0

I have a variable in a class that is transient because it is not serialize, only when the tomcat is org.apache.catalina.core.StandardContext reload this same variable is null, don't know why ...

public class bean extends UnicastRemoteObject implements clientInterface{
 (...)
    private transient OAuthService service;
 (...)
}

when it appears in netbeans in Apache tomcat log org.apache.catalina.core.StandardContext reload then this variable is null ....

Can someone tell me why?

user2989745
  • 149
  • 1
  • 3
  • 12

1 Answers1

0

This can happen if the variable belongs to an object somehow attached to the HTTP session.

upon reload the contents of the session are serialized, a new classloader is created and then the session gets deserialized.

So if the variable is marked as transient it does not get serialized, and when the reload is finished it's content will be null.

See in the tomcat documentation Persistence across Restarts section for the relation between serialization and reloads, and this blog post Session persistence for some details on how tomcat handles restarts.

Angular University
  • 42,341
  • 15
  • 74
  • 81
  • yes I had read some documentation, only that I could not even reach the solution. Have tried putting in context.xml: Only then he reload each time you break the session. And would not it .... – user2989745 Dec 12 '13 at 14:19
  • maybe it's better to post the code of the class where the OAuth service is being used, it seems it's being attached to the session which is strange – Angular University Dec 12 '13 at 14:29
  • I edited the post, I have saved the session with an instantiated bean object type. – user2989745 Dec 12 '13 at 14:44