Skip Headers

# Refreshing a Session When the Class Loader Changes

Previous

Next

In a non-CMP J2EE environment, if you require hot deployment or redeployment to a running application server, you must tell the session manager to refresh your session if the class loader changes, as Example: Forcing a Reparse of the sessions.xml File shows. This option makes the session manager refresh the session if the class loader changes, which occurs when the application is redeployed. When this option is set to `true`, the same class loader must always be used to retrieve the session.

Forcing a Reparse of the sessions.xml File

    //In this example, XMLSessionConfigLoader loads sessions.xml from the classpath
    SessionManager manager = SessionManager.getManager();
    Session session = manager.getSession(
        new XMLSessionConfigLoader(), // XMLSessionConfigLoader (sessions.xml file)
        "mysession", // session name
        YourApplicationClass.getClassLoader(), // class loader
        true,   // log in session
        false,  // do not refresh session when loaded
        true    // do refresh session if class loader changes
    );

In a CMP J2EE environment, the TopLink runtime and CMP integration handles this for you automatically.