<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
TreeCache error after Hibernate sessionFacotry close
</h3>
<span style="margin-bottom: 10px;">
created by <a href="https://community.jboss.org/people/erangac">Eranga Samararathna</a> in <i>JBoss Cache</i> - <a href="https://community.jboss.org/message/724584#724584">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>I am using a Hibernate 3.1.13 with jboss-cache 3.2.5</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I'm running my application with second level caching enabled and in middle of the application (based on user operation ) I am closing the existing session factory (sessionFactory.close();) and create a new one.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Up to this moment my second level cache work fine and after closing and creating new session factory I am getting following error from the Treecache.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Error</p><p>================================================</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Caused by: org.jboss.cache.CacheException: java.lang.reflect.InvocationTargetException</p><p>       at org.jboss.cache.util.reflect.ReflectionUtil.invokeAccessibly(ReflectionUtil.java:148)</p><p>       at org.jboss.cache.factories.ComponentRegistry$PrioritizedMethod.invoke(ComponentRegistry.java:1012)</p><p>       at org.jboss.cache.factories.ComponentRegistry.internalStart(ComponentRegistry.java:778)</p><p>       at org.jboss.cache.factories.ComponentRegistry.start(ComponentRegistry.java:632)</p><p>       at org.jboss.cache.invocation.CacheInvocationDelegate.start(CacheInvocationDelegate.java:345)</p><p>       at org.hibernate.cache.jbc2.builder.SharedCacheInstanceManager.start(SharedCacheInstanceManager.java:155)</p><p>       at org.hibernate.cache.jbc2.JBossCacheRegionFactory.start(JBossCacheRegionFactory.java:106)</p><p>       at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:192)</p><p>       at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1304)</p><p>       at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814)</p><p>       at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732)</p><p>       at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)</p><p>       at com.valista.rse.server.SessionFactoryHolder.refreshSessionFactory(SessionFactoryHolder.java:102)</p><p>       ... 32 more</p><p>    Caused by: java.lang.reflect.InvocationTargetException</p><p>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)</p><p>       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)</p><p>       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)</p><p>       at java.lang.reflect.Method.invoke(Method.java:597)</p><p>       at org.jboss.cache.util.reflect.ReflectionUtil.invokeAccessibly(ReflectionUtil.java:144)</p><p>       ... 44 more</p><p>    Caused by: org.jboss.cache.CacheException: Unable to fetch state on startup</p><p>       at org.jboss.cache.RPCManagerImpl.start(RPCManagerImpl.java:385)</p><p>       ... 49 more</p><p>    Caused by: org.jboss.cache.CacheException: Cache instance at 127.0.0.1:47082 cannot integrate state since state provider could not provide state due to null</p><p>       at org.jboss.cache.statetransfer.DefaultStateTransferManager.setState(DefaultStateTransferManager.java:169)</p><p>       at org.jboss.cache.remoting.jgroups.ChannelMessageListener.setState(ChannelMessageListener.java:191)</p><p>       at org.jgroups.blocks.MessageDispatcher$ProtocolAdapter.handleUpEvent(MessageDispatcher.java:665)</p><p>       at org.jgroups.blocks.MessageDispatcher$ProtocolAdapter.up(MessageDispatcher.java:765)</p><p>       at org.jgroups.JChannel.up(JChannel.java:1183)</p><p>       at org.jgroups.stack.ProtocolStack.up(ProtocolStack.java:444)</p><p>       at org.jgroups.protocols.pbcast.STATE_TRANSFER.handleStateRsp(STATE_TRANSFER.java:421)</p><p>       at org.jgroups.protocols.pbcast.STATE_TRANSFER.up(STATE_TRANSFER.java:120)</p><p>       at org.jgroups.protocols.pbcast.GMS.up(GMS.java:787)</p><p>       at org.jgroups.protocols.FRAG.unfragment(FRAG.java:290)</p><p>       at org.jgroups.protocols.FRAG.up(FRAG.java:150)</p><p>       at org.jgroups.protocols.UNICAST.handleDataReceived(UNICAST.java:616)</p><p>       at org.jgroups.protocols.UNICAST.up(UNICAST.java:282)</p><p>       at org.jgroups.protocols.pbcast.STABLE.up(STABLE.java:233)</p><p>       at org.jgroups.protocols.pbcast.NAKACK.up(NAKACK.java:735)</p><p>       at org.jgroups.protocols.VERIFY_SUSPECT.up(VERIFY_SUSPECT.java:167)</p><p>       at org.jgroups.protocols.FD.up(FD.java:284)</p><p>       at org.jgroups.protocols.MERGE2.up(MERGE2.java:144)</p><p>       at org.jgroups.protocols.Discovery.up(Discovery.java:263)</p><p>       at org.jgroups.protocols.TP.passMessageUp(TP.java:1275)</p><p>       at org.jgroups.protocols.TP.access$100(TP.java:49)</p><p>       at org.jgroups.protocols.TP$IncomingPacket.handleMyMessage(TP.java:1818)</p><p>       at org.jgroups.protocols.TP$IncomingPacket.run(TP.java:1797)</p><p>       ... 3 more</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>My treecache configuration file</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>================================</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><?xml version="1.0" encoding="UTF-8"?></p><p>    </p><p>    <!-- ===================================================================== --></p><p>    <!--                                                                       --></p><p>    <!--  Sample TreeCache Service Configuration                               --></p><p>    <!--                                                                       --></p><p>    <!-- ===================================================================== --></p><p>    </p><p>    <server></p><p>    </p><p>        <classpath codebase="../lib" archives="jbosscache-core.jar, jgroups.jar"/></p><p>    </p><p>    </p><p>        <!-- ==================================================================== --></p><p>        <!-- Defines TreeCache configuration                                      --></p><p>        <!-- ==================================================================== --></p><p>    </p><p>        <mbean code="org.jboss.cache.TreeCache"</p><p>            name="jboss.cache:service=TreeCache"></p><p>    </p><p>            <depends>jboss:service=Naming</depends></p><p>            <!-- <depends>jboss:service=TransactionManager</depends></p><p>                TransactionManager configuration not required for Hibernate!</p><p>            --></p><p>    </p><p>    </p><p>            <!--</p><p>                Node isolation level : SERIALIZABLE</p><p>                                     REPEATABLE_READ (default)</p><p>                                     READ_COMMITTED</p><p>                                     READ_UNCOMMITTED</p><p>                                     NONE</p><p>            --></p><p>            <attribute name="IsolationLevel">READ_COMMITTED</attribute></p><p>    </p><p>            <!--</p><p>                 Valid modes are LOCAL</p><p>                                 REPL_ASYNC</p><p>                                 REPL_SYNC</p><p>            --></p><p>            <attribute name="CacheMode">REPL_SYNC</attribute></p><p>    </p><p>            <!-- Name of cluster. Needs to be the same for all clusters, in order</p><p>                 to find each other</p><p>            --></p><p>            <attribute name="ClusterName">TreeCache-Cluster</attribute></p><p>    </p><p>            <!-- JGroups protocol stack properties. Can also be a URL,</p><p>                 e.g. file:/home/bela/default.xml</p><p>               <attribute name="ClusterProperties"></attribute></p><p>            --></p><p>    </p><p>          <attribute name="ClusterConfig"></p><p>                <config></p><p>                     UDP: if you have a multihomed machine,</p><p>                    set the bind_addr attribute to the appropriate NIC IP address</p><p>                     UDP: On Windows machines, because of the media sense feature</p><p>                     being broken with multicast (even after disabling media sense)</p><p>                     set the loopback attribute to true</p><p>                    <UDP mcast_addr="228.1.2.3" mcast_port="45566" bind_addr="127.0.0.1"</p><p>                        ip_ttl="64" ip_mcast="true"</p><p>                        mcast_send_buf_size="150000" mcast_recv_buf_size="80000"</p><p>                        ucast_send_buf_size="150000" ucast_recv_buf_size="80000"</p><p>                        loopback="false"/></p><p>                    <PING timeout="2000" num_initial_members="3"</p><p>                        up_thread="false" down_thread="false"/></p><p>                    <MERGE2 min_interval="10000" max_interval="20000"/></p><p>                    <FD shun="true" up_thread="true" down_thread="true"/></p><p>                    <VERIFY_SUSPECT timeout="1500"</p><p>                        up_thread="false" down_thread="false"/></p><p>                    <pbcast.NAKACK gc_lag="50" retransmit_timeout="600,1200,2400,4800"</p><p>                        up_thread="false" down_thread="false"/></p><p>                    <pbcast.STABLE desired_avg_gossip="20000"</p><p>                        up_thread="false" down_thread="false"/></p><p>                    <UNICAST timeout="600,1200,2400" window_size="100" min_threshold="10"</p><p>                        down_thread="false"/></p><p>                    <FRAG frag_size="8192"</p><p>                        down_thread="false" up_thread="false"/></p><p>                    <pbcast.GMS join_timeout="5000" join_retry_timeout="2000"</p><p>                        shun="true" print_local_addr="false"/></p><p>                    <pbcast.STATE_TRANSFER up_thread="false" down_thread="false"/></p><p>                </config></p><p>            </attribute></p><p>          </p><p>          </p><p>                </p><p>            <!--</p><p>                 Max number of entries in the cache. If this is exceeded, the</p><p>                 eviction policy will kick some entries out in order to make</p><p>                 more room</p><p>            --></p><p>            <attribute name="MaxCapacity">20000</attribute></p><p>    </p><p>            <!--</p><p>                The max amount of time (in milliseconds) we wait until the</p><p>                initial state (ie. the contents of the cache) are retrieved from</p><p>                existing members in a clustered environment</p><p>            --></p><p>            <attribute name="InitialStateRetrievalTimeout">20000</attribute></p><p>    </p><p>            <!--</p><p>                Number of milliseconds to wait until all responses for a</p><p>                synchronous call have been received.</p><p>            --></p><p>            <attribute name="SyncReplTimeout">10000</attribute></p><p>    </p><p>            <!-- Max number of milliseconds to wait for a lock acquisition --></p><p>            <attribute name="LockAcquisitionTimeout">15000</attribute></p><p>    </p><p>            <!-- Max number of milliseconds we hold a lock (not currently</p><p>            implemented) --></p><p>            <attribute name="LockLeaseTimeout">60000</attribute></p><p>    </p><p>            <!-- Name of the eviction policy class. Not supported now. --></p><p>            <attribute name="EvictionPolicyClass"></attribute></p><p>        </mbean></p><p>    </p><p>    </p><p>    </server></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>My Hibernate configuration file</p><p>=================================</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p># hibernate properties (general settings)</p><p>    </p><p>    # Note: Define C3P0 settings in c3p0.properties, NOT in this file.</p><p>    </p><p>    # Debugging</p><p>    hibernate.show_sql=false</p><p>    #hibernate.cglib.use_reflection_optimizer=false</p><p>    </p><p>    # Database isolation 1=read uncommitted, 2=read committed, 4=repeatable read, 8=serializable</p><p>    hibernate.connection.isolation = 2</p><p>    </p><p>    #configurations for jboss-cache as second level cache</p><p>    hibernate.cache.use_second_level_cache=true</p><p>    hibernate.cache.region.factory_class=org.hibernate.cache.jbc2.SharedJBossCacheRegionFactory</p><p>    hibernate.cache.region.jbc2.cfg.shared=treecache.xml</p><p>    hibernate.cache.use_query_cache=false</p><p>    </p><p>    # Filtered values based on db type</p><p>    hibernate.connection.url=@db.url@</p><p>    hibernate.connection.username=@db.users.owner.username@</p><p>    hibernate.connection.password=@db.users.owner.password@</p><p>    </p><p>    hibernate.database.startup.enabled=@db.startup.enabled@</p><p>    </p><p>    db.type=@db.type@</p><p>   </p><p>    hibernate.generate_statistics=true</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Appreciate you people help on this matter</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/724584#724584">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Cache at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2052">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>