10

Is possible to keep HTTP session between redeploys on WildFly?

cassiomolin
  • 124,154
  • 35
  • 280
  • 359

2 Answers2

8

You might try configuring session persistence. Here is a blog on how to do it.

<servlet-container name="default">
    <persistent-sessions path="session" relative-to="jboss.server.temp.dir"/>
    <jsp-config/>
</servlet-container>

However, it seems that this feature is available startinng from v8.2. I'll quote a note from this blog

You can also achieve session passivation, when you are using a non-ha profile, by adding <distributable/> to your web.xml (for those using WildFly 8.1.0 or less).

Predrag Maric
  • 23,938
  • 5
  • 52
  • 68
  • Thanks so much! `` works like a charm for WildFly 8.1. I'll try the solution for WildFly 8.2 too. – cassiomolin Dec 19 '14 at 16:18
  • I am going to set all my session variable class to "implements Serializable" – Thang Hoang Jul 05 '16 at 10:41
  • Seems distributable attribute must be in web.xml in order for persistent-sessions to work. Using Wildfly 16 and Keycloak 5 with Elytron. Thought distributable only applied to domain/cluster setups, but apparently it applies to standalone setup too. Note: session persistence on single server mode (non clustered) worked in GlassFish without distributable... – Ryan Jun 04 '19 at 20:15
2

<distributable/> in web.xml deployed to standalone may lead you to WFLY-3715 (logs polluted with undertow exceptions).

Alternative option can be to configure persistent sessions in standalone.xml or with jboss-cli.sh. JBoss CLI command worth to mention, as it can be used within maven plugin for WildFly.

/subsystem=undertow/servlet-container=default/setting=persistent-sessions:add(path="session", relative-to="jboss.server.temp.dir")

Log pollution example:

2016-12-29 09:39:48,464 ERROR [io.undertow.request] (default task-26) UT005023: Exception handling request to /resources/js/holder.js: org.infinispan.util.concurrent.TimeoutException: ISPN000299: Unable to acquire lock after 15 seconds for key SessionCreationMetaDataKey(EkmgBEYcvqFxNF_T2dDwEfyXkh7Nzcv2nTKBYy9G) and requestor GlobalTransaction::13:local. Lock is held by GlobalTransaction::12:local
        at org.infinispan.util.concurrent.locks.impl.DefaultLockManager$KeyAwareExtendedLockPromise.lock(DefaultLockManager.java:238)
        at org.infinispan.interceptors.locking.AbstractLockingInterceptor.lockAndRecord(AbstractLockingInterceptor.java:193)
        at org.infinispan.interceptors.locking.AbstractTxLockingInterceptor.checkPendingAndLockKey(AbstractTxLockingInterceptor.java:193)
        at org.infinispan.interceptors.locking.AbstractTxLockingInterceptor.lockOrRegisterBackupLock(AbstractTxLockingInterceptor.java:116)
        at org.infinispan.interceptors.locking.PessimisticLockingInterceptor.visitDataReadCommand(PessimisticLockingInterceptor.java:71)
        at org.infinispan.interceptors.locking.AbstractLockingInterceptor.visitGetKeyValueCommand(AbstractLockingInterceptor.java:80)
        at org.infinispan.commands.read.GetKeyValueCommand.acceptVisitor(GetKeyValueCommand.java:43)
        at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:99)
        at org.infinispan.interceptors.TxInterceptor.enlistReadAndInvokeNext(TxInterceptor.java:346)
        at org.infinispan.interceptors.TxInterceptor.visitGetKeyValueCommand(TxInterceptor.java:331)
        at org.infinispan.commands.read.GetKeyValueCommand.acceptVisitor(GetKeyValueCommand.java:43)
        at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:99)
        at org.infinispan.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:114)
        at org.infinispan.interceptors.InvocationContextInterceptor.handleDefault(InvocationContextInterceptor.java:83)
        at org.infinispan.commands.AbstractVisitor.visitGetKeyValueCommand(AbstractVisitor.java:85)
        at org.infinispan.commands.read.GetKeyValueCommand.acceptVisitor(GetKeyValueCommand.java:43)
........
Jens Piegsa
  • 7,399
  • 5
  • 58
  • 106
Lauri
  • 201
  • 1
  • 6