How to store http sessions in database for WebLogic Cluster

In this example we are going use Postgres database for session replication. It can be downloaded from here

Once installed, you need to execute the following query to create the table to store session

 

create table wl_servlet_sessions ( wl_id TEXT NOT NULL, wl_context_path TEXT NOT NULL, wl_is_new CHAR(1),
 wl_create_time NUMERIC(20),     wl_is_valid CHAR(1), wl_session_values BYTEA, wl_access_time NUMERIC(20), 
wl_max_inactive_interval INTEGER, PRIMARY KEY (wl_id, wl_context_path) );

Once the database setup is complete, we need to create a postgres datasource on Weblogic Server.
You can follow the steps here if needed.Then you need to update the deployment descriptor (weblogic.xml) of your application as follows.

 

<session-descriptor>
   <persistent-store-type>jdbc</persistent-store-type>
   <persistent-store-pool>postgresds</persistent-store-pool>
   <persistent-store-table>WL_SERVLET_SESSIONS</persistent-store-table>
</session-descriptor>

 

Now you can log in to your application, store objects in session.

If you want to have a look at the session details in the database, you can use the pgAdmin tool.

replication-session

 

Please feel free to get in touch with us if you have any queries.

 

Cheers!

Wonders Team