Your answer is correct, but because the application is modular, I forgot to create an instance of ConnectSession in the main application, so when I created the instance in one of the module and send it to another module, the second module cast te variable to null.