1 2 Previous Next 26 Replies Latest reply: Mar 14, 2014 4:42 PM by Paul Ferraro RSS

Jboss 7.x - HA Web Sessions via Database Persistence with Oracle

manish suriya Newbie

Hello Everyone,

 

Refering to the article : https://community.jboss.org/wiki/HAWebSessionsViaDatabasePersistence   where it describes to achieve data persistence for jboss 5.x.

 

I would like to achieve the same but with Jboss 7.x. Since there are various changes in structure from AS5 to AS7, I am not sure how should I configure it. I have some problems.

 

1. There is no Context.xml in jboss 7.x, Not sure where should I use <Manager> and <Store> tags .

2. There is no module defined for class org.jboss.web.tomcat.service.session.persistent.DataSourcePersistentManager in AS7 as given in the article for AS5.

3. Somewhere in comments below the article, its written I can use jboss-web.xml for AS7. Again, I am not sure how should my jboss-web.xml should look-like/ contain.

 

Any help regarding this will be appreciated !

 

Thanks & Regards

Manish Suriya

  • 1. Re: Jboss 7.x - HA Web Sessions via Database Persistence with Oracle
    manish suriya Newbie

    I was expecting a reply

    Anyway.. I found this link http://mastertheboss.com/jboss-application-server/432-develop-a-clustered-application-with-infinispan-data-grid.html?start=1 and now trying to implement the same (using injection). But I am getting this error at the end (with out any stack trace). I am using jboss 7.0.2 bunddled with liferay 6.1 EE.

     

    ERROR [org.jboss.as.deployment] (DeploymentScanner-threads - 1) {"Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => "Operation handler failed to complete"}}

     

    Here is my cache container placed under <Subsystem> of standalone.xml

     

    <cache-container name="cluster" default-cache="dist">
            <alias>cluster </alias>
            <transport lock-timeout="60000"/>
            <distributed-cache owners="3" mode="ASYNC" name="dist" batching="true">
                        <file-store/>
            </distributed-cache>
    </cache-container>
    

     

     

    I have a Oracle datasource

     

    <datasource jndi-name="java:jboss/datasources/LiferayPool_test" pool-name="OracleDS" enabled="true" jta="true" use-java-context="true" use-ccm="true">
                        <connection-url>
                            jdbc:oracle:thin:@<myaddress>:XE
                        </connection-url>
                        <driver>
                            oracle
                        </driver>
                        <transaction-isolation>
                            TRANSACTION_READ_COMMITTED
                        </transaction-isolation>
                        <pool>
                            <prefill>
                                true
                            </prefill>
                            <use-strict-min>
                                false
                            </use-strict-min>
                            <flush-strategy>
                                FailingConnectionOnly
                            </flush-strategy>
                        </pool>
                        <security>
                            <user-name>
                                username
                            </user-name>
                            <password>
                               password
                            </password>
                        </security>
     </datasource>
    

     

    This is how I am invoking the cache

     

    @Resource(lookup="java:jboss/infinispan/container/cluster")
        private CacheContainer container;  
    

     

     

    Secondaly, I also tried without using injection, as expalined in comments of this link ( https://docs.jboss.org/author/display/ISPN/Getting+Started+Guide+-+JBoss+AS+7 ), like this

     

    InitialContext ic = new InitialContext();
       CacheContainer cc = (CacheContainer) ic.lookup("java:jboss/infinispan/container/cluster");
       Cache<String, Object> cache = cc.getCache();
    

     

    But in this case I got this error:

     

    ERROR [stderr] (MSC service thread 1-4)     java.lang.IllegalStateException

    ERROR [stderr] (MSC service thread 1-4)    at org.jboss.msc.value.InjectedValue.getValue(InjectedValue.java:47)

    ERROR [stderr] (MSC service thread 1-4)    at org.jboss.as.naming.service.BinderService.getValue(BinderService.java:116)

    ERROR [stderr] (MSC service thread 1-4)    at org.jboss.as.naming.service.BinderService.getValue(BinderService.java:43)

    ERROR [stderr] (MSC service thread 1-4)    at org.jboss.msc.service.ServiceControllerImpl.getValue(ServiceControllerImpl.java:1216)

     

     

    Could experts please guide what I am doing wrong. I am new to liferay and jboss 7. Thanks for the help !

  • 3. Re: Jboss 7.x - HA Web Sessions via Database Persistence with Oracle
    Paul Ferraro Master

    To enable session persistence to a database:

    1. Configure your datasource.  See https://community.jboss.org/wiki/DataSourceConfigurationInAS7

    2. Assuming you're using an HA profile (e.g. standalone-ha.xml), change the default cache of the "web" cache container within the infinispan subsystem to use an invalidation-cache configured with a shared write-through jdbc cache store using the datasource defined in step 1.

    e.g.

    <cache-container name="web" default-cache="database" module="org.jboss.as.clustering.web.infinispan">
      <invalidation-cache name="database" mode="ASYNC" batching="true">
        <key-based-jdbc-store datasource="java:jboss/datasources/LiferayPool_test" passivation="false" purge="false" shared="true"/>
      </invalidation-cache>
    </cache-container>

     

    3. Make sure your web application's web.xml declares itself as <distributable/>.

  • 4. Re: Jboss 7.x - HA Web Sessions via Database Persistence with Oracle
    Ben Schofield Novice

    Paul, Manish was specifically asking about creating HA web sessions.  In your comment you make mention of using a non-HA profile.  Will the configuration you mention properly manage sessions when two non-HA profiles are pointed at the same database and therefore achieve HA web sessions?  For example would JBoss instance A recognize changes to the database and therefore the active session made by JBoss instance B?  If a session is started on instance A and the user gets bounced to instance B and then logs out invalidating the session, will the session get cleaned up on instance A?

  • 5. Re: Jboss 7.x - HA Web Sessions via Database Persistence with Oracle
    manish suriya Newbie

    Thanks Paul for the reply... getting following error with Jboss 7.0.2 and 7.1.1 ..

     

    Message: JBAS014788: Unexpected attribute 'module' encountered.

     

    Pls let me know which version supports the module tag.

  • 6. Re: Jboss 7.x - HA Web Sessions via Database Persistence with Oracle
    Paul Ferraro Master

    The module attribute is new to the 1.3 version of the infinispan subsystem schema (found in 7.1.2.Final).  For older versions - you should omit this attribute.

  • 7. Re: Jboss 7.x - HA Web Sessions via Database Persistence with Oracle
    manish suriya Newbie

    Hi Paul,

     

    Even the key-based-jdbc-store is not supporting in 7.1.1 and below versions. I cannt swithc to 7.1.2 as it is not avaialble for downloads.

    Could you please give me a code which suits/works for 7.1.1 or 7.0.2.

     

    Thanks

  • 8. Re: Jboss 7.x - HA Web Sessions via Database Persistence with Oracle
    Paul Ferraro Master

    <key-based-jdbc-store/> was called <jdbc-store/> in 7.1.1 and earlier.

    To use 7.1.2, download and build the source code from here: https://github.com/jbossas/jboss-as/zipball/7.1.2.Final

  • 9. Re: Jboss 7.x - HA Web Sessions via Database Persistence with Oracle
    Paul Ferraro Master

    Ben,

    You're right - configuring HA web sessions in this way is not quite as robust as the traditional replication approach.  A shared database session store *requires* sticky sessions (this is not a requirement for replicated sessions) - so the kind of bouncing you're talking about would only occur if the instance A was actually unavailable (crash, undeploy, restart, etc.), thus instance A would no longer know about the session in question and would look for it in the database, and when not found, assume it does not exist (or was invalidated).

  • 10. Re: Jboss 7.x - HA Web Sessions via Database Persistence with Oracle
    Paul Ferraro Master

    Actually, you can eliminate the sticky session requirement by using an <invalidation-cache/> instead of a <local-cache/>.  This, of course, would require that you use an HA-aware profile (e.g. standalone-ha.xml).

  • 11. Re: Jboss 7.x - HA Web Sessions via Database Persistence with Oracle
    manish suriya Newbie

    Paul Ferraro wrote:

     

    Actually, you can eliminate the sticky session requirement by using an <invalidation-cache/> instead of a <local-cache/>.  This, of course, would require that you use an HA-aware profile (e.g. standalone-ha.xml).

    Hi Paul,

     

    Thanks for your reply.

    As per your suggestions I am using <invalidation-cache> in standalone-ha.xml... I am getting below error..

     

    15:06:38,303 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC00001: Failed to start service jboss.infinispan.web.database.config: org.jboss.msc.service.StartException in service jboss.infinispan.web.database.config: JBAS010291: Failed to add INVALIDATION_ASYNC database cache to non-clustered web cache container.
            at org.jboss.as.clustering.infinispan.subsystem.CacheConfigurationService.start(CacheConfigurationService.java:100)
            at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
            at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) [rt.jar:1.6.0_03]
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) [rt.jar:1.6.0_03]
            at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_03]
    
    15:06:38,350 INFO  [org.infinispan.cdi.InfinispanExtension] (MSC service thread 1-2) ISPN017001: Infinispan CDI extension version: 5.1.4.FINAL
    

     

    configuration in standalone-ha.xml is.. since infinispan 1.2 doesn't supports <key-based-jdbc-store>  i am using <string-keyed-jdbc-store>. database type is oracle.

     

    <cache-container name="web" default-cache="database">
      <invalidation-cache name="database" mode="ASYNC"  batching="true"> 
       <string-keyed-jdbc-store datasource="java:jboss/datasources/LiferayPool_test" passivation="false" preload="true" purge="false">
                <property name="databaseType">oracle</property>
                <string-keyed-table prefix="stringbased ">
                    <id-column name="id" 
                               type="VARCHAR2"/> 
                        <data-column name="datum" 
                                 type="BLOB"/> 
                        <timestamp-column name="version" 
                                  type="NUMBER"/> 
                </string-keyed-table>
            </string-keyed-jdbc-store>
      </invalidation-cache>
    </cache-container>
    

     

    Could you please guide me what I am doing wrong ?

  • 12. Re: Jboss 7.x - HA Web Sessions via Database Persistence with Oracle
    manish suriya Newbie

    Ok I added the  <transport lock-timeout="60000"/> to cache-container... It starts attempting to create a table but by default suffixin "//deafult-host//<context-name>" to the table name ..hence causing SQL error. Below is the error I am getting now..

     

    13:14:08,233 ERROR [org.infinispan.loaders.jdbc.TableManipulation] (MSC service thread 1-4) ISPN008011: Error while creating table; used DDL statement: 'CREATE TABLE stringbased_//default-host//JavaServerFaces (id VARCHAR2 NOT NULL, datum BLOB, version NUMBER, PRIMARY KEY (id))': java.sql.SQLException: ORA-00922: missing or invalid option
    
            at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
            at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
            at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
            at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
            at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:207)
            at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:946)
            at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1168)
            at oracle.jdbc.driver.OracleStatement.executeUpdateInternal(OracleStatement.java:1614)
            at oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:1579)
            at org.jboss.jca.adapters.jdbc.WrappedStatement.executeUpdate(WrappedStatement.java:371)
            at org.infinispan.loaders.jdbc.TableManipulation.executeUpdateSql(TableManipulation.java:154)
            at org.infinispan.loaders.jdbc.TableManipulation.createTable(TableManipulation.java:130)
            at org.infinispan.loaders.jdbc.TableManipulation.start(TableManipulation.java:231)
            at org.infinispan.loaders.jdbc.stringbased.JdbcStringBasedCacheStore.doConnectionFactoryInitialization(JdbcStringBasedCacheStore.java:365)
            at org.infinispan.loaders.jdbc.stringbased.JdbcStringBasedCacheStore.start(JdbcStringBasedCacheStore.java:121)
            at org.infinispan.loaders.CacheLoaderManagerImpl.start(CacheLoaderManagerImpl.java:129) [infinispan-core-5.1.2.FINAL.jar:5.1.2.FINAL]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_03]
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [rt.jar:1.6.0_03]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_03]
            at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_03]
            at org.infinispan.util.ReflectionUtil.invokeAccessibly(ReflectionUtil.java:236) [infinispan-core-5.1.2.FINAL.jar:5.1.2.FINAL]
            at org.infinispan.factories.AbstractComponentRegistry$PrioritizedMethod.invoke(AbstractComponentRegistry.java:882) [infinispan-core-5.1.2.FINAL.jar:5.1.2.FINAL]
            at org.infinispan.factories.AbstractComponentRegistry.invokeStartMethods(AbstractComponentRegistry.java:637) [infinispan-core-5.1.2.FINAL.jar:5.1.2.FINAL]
            at org.infinispan.factories.AbstractComponentRegistry.internalStart(AbstractComponentRegistry.java:626) [infinispan-core-5.1.2.FINAL.jar:5.1.2.FINAL]
            at org.infinispan.factories.AbstractComponentRegistry.start(AbstractComponentRegistry.java:530) [infinispan-core-5.1.2.FINAL.jar:5.1.2.FINAL]
            at org.infinispan.factories.ComponentRegistry.start(ComponentRegistry.java:173) [infinispan-core-5.1.2.FINAL.jar:5.1.2.FINAL]
            at org.infinispan.CacheImpl.start(CacheImpl.java:499) [infinispan-core-5.1.2.FINAL.jar:5.1.2.FINAL]
            at org.infinispan.manager.DefaultCacheManager.createCache(DefaultCacheManager.java:626) [infinispan-core-5.1.2.FINAL.jar:5.1.2.FINAL]
            at org.infinispan.manager.DefaultCacheManager.getCache(DefaultCacheManager.java:516) [infinispan-core-5.1.2.FINAL.jar:5.1.2.FINAL]
            at org.infinispan.manager.DefaultCacheManager.getCache(DefaultCacheManager.java:530) [infinispan-core-5.1.2.FINAL.jar:5.1.2.FINAL]
            at org.jboss.as.clustering.infinispan.DefaultEmbeddedCacheManager.getCache(DefaultEmbeddedCacheManager.java:148)
            at org.jboss.as.clustering.infinispan.DefaultEmbeddedCacheManager.getCache(DefaultEmbeddedCacheManager.java:139)
            at org.jboss.as.clustering.web.infinispan.DistributedCacheManagerFactory.getDistributedCacheManager(DistributedCacheManagerFactory.java:97)
            at org.jboss.as.web.session.DistributableSessionManager.<init>(DistributableSessionManager.java:159) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
            at org.jboss.as.web.deployment.JBossContextConfig.processWebMetaData(JBossContextConfig.java:250) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
            at org.jboss.as.web.deployment.JBossContextConfig.applicationWebConfig(JBossContextConfig.java:169) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
            at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:417) [jbossweb-7.0.13.Final.jar:]
            at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:182) [jbossweb-7.0.13.Final.jar:]
    

     

    I am not sure why its appending //deafult-host//... to atble name every time i start server. Below is my new cache entry

     

     <cache-container name="web" default-cache="database">
                    <transport lock-timeout="60000"/>
                    <invalidation-cache name="database" mode="ASYNC" batching="true">
                        <string-keyed-jdbc-store datasource="java:jboss/datasources/LiferayPool_test" preload="true" passivation="false" purge="false">
                            <property name="databaseType">
                                oracle
                            </property>
                            <string-keyed-table prefix="stringbased">
                                <id-column name="id" type="VARCHAR2(200)"/>
                                <data-column name="datum" type="BLOB"/>
                                <timestamp-column name="version" type="NUMBER"/>
                            </string-keyed-table>
                        </string-keyed-jdbc-store>
                    </invalidation-cache>
                </cache-container>
    

     

    Please advice !!!! I am stuck

  • 13. Re: Jboss 7.x - HA Web Sessions via Database Persistence with Oracle
    manish suriya Newbie

    Here an update:

    I just checked and I strange to note that even with the above exception message onto server console it does creating a table in Oracle DB  with name stringbased_database  !!!  However nothing is getting stored so far....! Please advice how can I store Httpsessions in db. Thanks !!!

1 2 Previous Next