Keeping HTTP session between redeploys in WildFly - java

Is possible to keep HTTP session between redeploys on WildFly?

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).

<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)
........

Related

Wildfly datasource Enable is not working at runtime when configured through CLI

We are migrating from jboss Eap 6.4 to Wildfly. During migration, as part of our application installation, we will configure different xa-datasources in domain.xml. This configuration will be done through jboss-cli.sh.
After configuring the data sources, when deploying the ears, (particularly at *-ejb.jar) we are getting an error saying that the 'persistent unit' is not available and the deployment is rolled back.
Loggers are showing the below:
WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"xxyy.ear/xxyy-ejb.jar#xxyyDBUnit\" is missing [jboss.naming.context.java.jboss.datasources.xxyyDS]"]
Post restart of the jboss service, the same deployment works fine. So, we believe that the datasources configured in the domain.xml is not activated or enabled (although we have set the attribute 'enabled=true' for the xa-datasource. We could see the following warning while adding the xa-datasource in jboss.
2021-09-21 16:57:48,308 INFO [org.jboss.as.connector] (Host Controller Service Threads - 8) WFLYJCA0093: The 'enable' operation is deprecated. Use of the 'add' or 'remove' operations is preferred, or if required the 'write-attribute' operation can used to set the deprecated 'enabled' attribute
With this warning, we understood that the enable/disable operation has been removed in the jboss wildfly. Is there anyway we can make it enabled on the runtime without restart of the jboss service.
Below are the commands which we use to create the xa-datasource in wildfly.
/profile=full-ha/subsystem=datasources/xa-data-source=xxyyDS:add(use-java-context=true,use-ccm=false,driver-name=com.mysql,transaction-isolation=TRANSACTION_READ_COMMITTED,min-pool-size=15,max-pool-size=150,pool-prefill=true,flush-strategy=IdleConnections,valid-connection-checker-class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker",stale-connection-checker-class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker",exception-sorter-class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter",set-tx-query-timeout=true,blocking-timeout-wait-millis=5000,idle-timeout-minutes=1,query-timeout=300,prepared-statements-cache-size=100,share-prepared-statements=true,jndi-name="java:jboss/datasources/xxyyDS",user-name=jboss,password="${VAULT::ds_MySqlDS::password::1}")
/profile=full-ha/subsystem=datasources/xa-data-source=xxyyDS/xa-datasource-properties=DatabaseName:add(value=xxyy_db)
/profile=full-ha/subsystem=datasources/xa-data-source=xxyyDS/xa-datasource-properties=ServerName:add(value=xx-cluster)
/profile=full-ha/subsystem=datasources/xa-data-source=xxyyDS/xa-datasource-properties=AutoReconnectForPools:add(value=true)
/profile=full-ha/subsystem=datasources/xa-data-source=xxyyDS/xa-datasource-properties=AutoReconnect:add(value=true)
/profile=full-ha/subsystem=datasources/xa-data-source=xxyyDS/xa-datasource-properties=useSSL:add(value=false)
/profile=full-ha/subsystem=datasources/xa-data-source=xxyyDS:enable
Any inputs on how to enable the xa-datasource on runtime would help us.
You can enable the datasource via the CLI:
/subsystem=datasources/xa-data-source=xxyyDS:write-attribute(name=enabled,value=true)
It might be required to reload:
:reload
After running through many trial and error method, we found that when adding the datasources by default it will be in enabled state. So no need to do explicitly enable when adding a datasource.
So we removed the below line from the list of CLIs.
/profile=full-ha/subsystem=datasources/xa-data-source=xxyyDS:enable
Post removing the line, the configuration of datasources through CLI and the deployment of ears went fine without issues. Posting this solution as it will be helpful for others who are facing similar kind of issue.
Finally our datasource CLIs will be like the ones below.
/profile=full-ha/subsystem=datasources/xa-data-source=xxyyDS:add(use-java-context=true,use-ccm=false,driver-name=com.mysql,transaction-isolation=TRANSACTION_READ_COMMITTED,min-pool-size=15,max-pool-size=150,pool-prefill=true,flush-strategy=IdleConnections,valid-connection-checker-class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker",stale-connection-checker-class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker",exception-sorter-class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter",set-tx-query-timeout=true,blocking-timeout-wait-millis=5000,idle-timeout-minutes=1,query-timeout=300,prepared-statements-cache-size=100,share-prepared-statements=true,jndi-name="java:jboss/datasources/xxyyDS",user-name=jboss,password="${VAULT::ds_MySqlDS::password::1}")
/profile=full-ha/subsystem=datasources/xa-data-source=xxyyDS/xa-datasource-properties=DatabaseName:add(value=xxyy_db)
/profile=full-ha/subsystem=datasources/xa-data-source=xxyyDS/xa-datasource-properties=ServerName:add(value=xx-cluster)
/profile=full-ha/subsystem=datasources/xa-data-source=xxyyDS/xa-datasource-properties=AutoReconnectForPools:add(value=true)
/profile=full-ha/subsystem=datasources/xa-data-source=xxyyDS/xa-datasource-properties=AutoReconnect:add(value=true)
/profile=full-ha/subsystem=datasources/xa-data-source=xxyyDS/xa-datasource-properties=useSSL:add(value=false)

Websphere JTA - Last resource Configuration

In a Websphere application we have a requirement for JTA transactions with JMS + Gemfire. Based on product recommendations, we're trying to configure Gemfire as last-resource. There is not enough support/example in the documentation
http://gemfire82.docs.pivotal.io/docs-gemfire/latest/developing/transactions/JTA_transactions_with_GemFire.html#concept_csy_vfb_wk
JTA - Websphere UOW
Resources - JMS, Gemfire (8.2.1)
Can someone publish a sample websphere-ra.xml?
There are no websphere-specific resource deployment descriptors for WebSphere Application Server. Last agent optimization can be configured for a server or for an application. To configure it for a server, in full profile, you enable 'Accept Heuristic Hazard' in the transaction service settings. Example:
https://www.ibm.com/support/knowledgecenter/en/SSAW57_7.0.0/com.ibm.websphere.nd.doc/info/ae/ae/udat_contranserv.html
If you choose instead the application level, you need to use the websphere-specific extensions to the deployment descriptor for applications. The setting is called 'Last participant support'. Example:
https://www.ibm.com/support/knowledgecenter/en/SSAW57_8.5.5/com.ibm.websphere.nd.doc/lao/tasks/tla_cfap2.html
When correctly configured, the server will allow a single one-phase resource to enlist in a global transaction, and will treat it as the last agent. If more than one one-phase resource is enlisted, you will get an exception. In this specific case, you would need to make sure that the JMS resources are XA-capable so that they will not try to be the last agent.

Jms session.commit() throws exceptoin when I run my application in Jboss server

I am using ActiveMQ v5.11.1 with managed beans on Jboss EAP v6.3 server so I get exception when i perfrom jms session.commit() or rollback()
(ActiveMQ Session Task-1) javax.jms.IllegalStateException: Not a transacted session
But when i run as java application it gives no exception why ?
Could it be because of version mismatch ?Please help.
Read here.
If your jms resource is controlled by JTA, you can't commit or rollback manually

JBoss : Timeout Exception during deployment of War File

I'm trying to deploy a war on my remote server which is continuously failing with an error like TimeOutException.
I've checked over the web for similar issue but is out of luck as of now:
Please have a look below of the Logs generated out of it as I'm not sure what I'm missing here. Also I've updated my standalone.xml (added the deployment-timeout="240L" ) file as below:
<subsystem xmlns="urn:jboss:domain:deployment-scanner:2.0">
<deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000" deployment-timeout="240L" runtime-failure-causes-rollback="${jboss.deployment.scanner.rollback.on.failure:false}"/>
</subsystem>
But still I'm getting a same exception seems like I'm missing something here, Logs are as below:
http://pastebin.com/BS6hrJ4z
Your setting for deploy-timeout is incorrect.
<subsystem xmlns="urn:jboss:domain:deployment-scanner:1.0">
<deployment-scanner scan-interval="5000" relative-to="jboss.server.base.dir" path="deployments" deployment-timeout="240" runtime-failure-causes-rollback="${jboss.deployment.scanner.rollback.on.failure:false}"/>
</subsystem>
Remove the 'L' from the deploy timeout setting, which should be numeric only, then it should work fine.
NOTE: This deployment-timeout is in seconds
Additionally, you are getting a couple of Spring initialization errors during deployment. To get more information you need to increase the log level to see what the root cause may be:
2016-03-28 09:10:44,422 WARN [org.jboss.as.ee] (MSC service thread 1-7) WFLYEE0007: Not installing optional component org.springframework.http.server.ServletServerHttpAsyncRequestControl due to an exception (enable DEBUG log level to see the cause)
2016-03-28 09:10:44,423 WARN [org.jboss.as.ee] (MSC service thread 1-7) WFLYEE0007: Not installing optional component org.springframework.web.context.request.async.StandardServletAsyncWebRequest due to an exception (enable DEBUG log level to see the cause)
After looking at your logs, it seems that your deployment is taking more than 5 minutes to finish. Increasing the timeout is not the solution.
Instead, you should be breaking your deployment into smaller pieces and checking what's going on.
Things I'd check:
Assess your dependency on Spring. I know Spring folks will hate me for that, but most applications nowadays don't need "the full Spring". Pretty much everything can be achieved with Java EE standards, which are provided to you by your container (Wildfly, in this case). This reduces the overall footprint for your application, making the WAR file slimmer and deployment faster.
Answer to yourself: why do I need ehcache? You are using a very capable application server, providing you with JPA and second-level caching "for free" to you. You don't need to ship Hibernate and ehcache, unless you need to use very specific versions/features of Hibernate+ehcache.
Try to deploy some applications from the Java EE samples into your Wildfly. Are they also taking "long", comparing to, say, a reasonable machine on EC2/OpenShift? If so, this could indicate that the problem is on the environment, not on your application. Java EE samples: https://github.com/javaee-samples/javaee7-samples

oc4j enterprise manager console session timeout?

How can I change the session timeout for the OC4J Enterprise Manager console?
It times out too quickly between deployments in our development environment.
The default session timeout of an application in OC4J is 20 minutes. If you need to change the same for an application, you have to explicitly set the session timeout value in web.xml.
This holds good even for Enterprise Manager as well, which is deployed as the application ascontrol. The web.xml file of ascontrol will be available at $ORACLE_HOME/j2ee/OC4J_INSTANCE/config/applications/ascontrol/ascontrol/WEB-INF/web.xml. You will have to introduce the session-timeout element in this file at the appropriate location (usually at the end), so that the XML is valid. A restart of the OC4J instance is required.
Do note that, this comes with no guarantees, and it is better to confirm via Oracle Support if this configuration change is supported.
Alternatively, you can use admin_client.jar or admin.jar to deploy your application.

Categories