JBoss,Hibernate and Caching Issue
manjith27 Apr 18, 2006 1:17 PMHi,
I am using Hibernate 3.1 and JBoss 4.0.2.
We have integrated caching, clustering in Jboss.
Now, I keep the instance of SessionFactory in our predefined Cache which implements JBoss supported Caching Framework.
I have written a test JSP which calls the SessionFactory instance from the caching and create a session object from it and does the CRUD functions.
The problem is for the 1st request the SessionFactory object which I placed in the Cache is null. For the 2nd and consecutive requests the SessionFactory object retrieved from the Cache and performs the CRUD functionality properly.
But when I run the same code in the standalone application with a test program, the Test executes without any issues.
I have enable the use_query_cahe to true in hibernate-cfg.xml.
My hibernate-cfg.xml is: -
<property name="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</property> <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property> <property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:test</property> <property name="hibernate.connection.username">test</property> <property name="hibernate.connection.password">test</property> <property name="hibernate.cache.use_query_cache">true</property>
And my treecache-service.xml is:
<server> <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/> <mbean code="org.jboss.cache.TreeCache" name="jboss.cache:service=TreeCache"> <depends>jboss:service=Naming</depends> <depends>jboss:service=TransactionManager</depends> <!-- Configure the TransactionManager --> <attribute name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute> <attribute name="IsolationLevel">SERIALIZABLE</attribute> <attribute name="CacheMode">LOCAL</attribute> <attribute name="UseReplQueue">false</attribute> <attribute name="ReplQueueInterval">20000</attribute> <attribute name="ReplQueueMaxElements">5</attribute> <attribute name="ClusterName">TreeCache-Cluster</attribute> <attribute name="ClusterConfig"> <config> <UDP mcast_addr="228.1.2.3" mcast_port="45566" ip_ttl="32" ip_mcast="true" mcast_send_buf_size="80000" mcast_recv_buf_size="150000" ucast_send_buf_size="80000" ucast_recv_buf_size="150000" loopback="true"/> <PING timeout="2000" num_initial_members="3" up_thread="false" down_thread="false"/> <MERGE2 min_interval="10000" max_interval="20000"/> <FD shun="true" up_thread="true" down_thread="true"/> <VERIFY_SUSPECT timeout="1500" up_thread="false" down_thread="false"/> <pbcast.NAKACK gc_lag="50" retransmit_timeout="600,1200,2400,4800" max_xmit_size="8192" up_thread="false" down_thread="false"/> <UNICAST timeout="600,1200,2400" window_size="100" min_threshold="10" down_thread="false"/> <pbcast.STABLE desired_avg_gossip="20000" up_thread="false" down_thread="false"/> <FRAG frag_size="8192" down_thread="false" up_thread="false"/> <pbcast.GMS join_timeout="5000" join_retry_timeout="2000" shun="true" print_local_addr="true"/> <pbcast.STATE_TRANSFER up_thread="false" down_thread="false"/> </config> </attribute> <attribute name="InitialStateRetrievalTimeout">5000</attribute> <attribute name="SyncReplTimeout">10000</attribute> <!-- Max number of milliseconds to wait for a lock acquisition --> <attribute name="LockAcquisitionTimeout">15000</attribute> <!-- Name of the eviction policy class. Not supported now. --> <attribute name="EvictionPolicyClass"></attribute> <attribute name="FetchStateOnStartup">true</attribute> </mbean> </server>
Please, let me know If I need to add any other configuraton over here.
Thanks In Advace For the solution.
Thanks
Manjith