4 Replies Latest reply on Nov 29, 2011 1:14 AM by Dzung Leonhart

    Got error when using infinispan for hibernate second-level cache

    Dzung Leonhart Newbie

      Hi Infinispan team,

       

      I'm applying infinispan for hibernate second-level cache in my project that deployed on clustering environment.

      I got this weird error when starting the second node:

          

      2011-11-21 11:30:57,572 [main] INFO  org.infinispan.remoting.transport.jgroups.JGroupsTransport - ISPN000094: Received new cluster view: [HK6HZP1-26057|1] [HK6HZP1-26057, HK6HZP1-59862]

      2011-11-21 11:30:57,572 [main] INFO  org.infinispan.remoting.transport.jgroups.JGroupsTransport - ISPN000079: Cache local address is HK6HZP1-59862, physical addresses are [192.168.76.38:8801]

      2011-11-21 11:30:57,573 [main] INFO  org.infinispan.factories.GlobalComponentRegistry - ISPN000128: Infinispan version: Infinispan 'Pagoa' 5.0.1.FINAL

      2011-11-21 11:30:57,610 [main] INFO  org.infinispan.remoting.rpc.RpcManagerImpl - ISPN000074: Trying to fetch state from HK6HZP1-26057

      2011-11-21 11:30:57,640 [Incoming-2,infinispan-hibernate-cache-cluster,HK6HZP1-59862] ERROR org.infinispan.remoting.transport.jgroups.JGroupsTransport - ISPN000096: Caught while requesting or applying state

      org.infinispan.statetransfer.StateTransferException: java.io.InvalidClassException: org.hibernate.cache.infinispan.util.CacheHelper$EvictAll; Class is non-public or has no public no-arg constructor

          at org.infinispan.statetransfer.StateTransferManagerImpl.applyInMemoryState(StateTransferManagerImpl.java:313)

          at org.infinispan.statetransfer.StateTransferManagerImpl.applyState(StateTransferManagerImpl.java:277)

          at org.infinispan.remoting.InboundInvocationHandlerImpl.applyState(InboundInvocationHandlerImpl.java:244)

          at org.infinispan.remoting.transport.jgroups.JGroupsTransport.setState(JGroupsTransport.java:607)

          at org.jgroups.blocks.MessageDispatcher$ProtocolAdapter.handleUpEvent(MessageDispatcher.java:711)

          at org.jgroups.blocks.MessageDispatcher$ProtocolAdapter.up(MessageDispatcher.java:771)

          at org.jgroups.JChannel.up(JChannel.java:1441)

          at org.jgroups.stack.ProtocolStack.up(ProtocolStack.java:1074)

          at org.jgroups.protocols.pbcast.STREAMING_STATE_TRANSFER.connectToStateProvider(STREAMING_STATE_TRANSFER.java:523)

          at org.jgroups.protocols.pbcast.STREAMING_STATE_TRANSFER.handleStateRsp(STREAMING_STATE_TRANSFER.java:462)

          at org.jgroups.protocols.pbcast.STREAMING_STATE_TRANSFER.up(STREAMING_STATE_TRANSFER.java:223)

          at org.jgroups.protocols.FRAG2.up(FRAG2.java:189)

          at org.jgroups.protocols.FlowControl.up(FlowControl.java:418)

          at org.jgroups.protocols.FlowControl.up(FlowControl.java:400)

          at org.jgroups.protocols.pbcast.GMS.up(GMS.java:908)

          at org.jgroups.protocols.pbcast.STABLE.up(STABLE.java:246)

          at org.jgroups.protocols.UNICAST.handleDataReceived(UNICAST.java:613)

          at org.jgroups.protocols.UNICAST.up(UNICAST.java:294)

          at org.jgroups.protocols.pbcast.NAKACK.up(NAKACK.java:703)

          at org.jgroups.protocols.VERIFY_SUSPECT.up(VERIFY_SUSPECT.java:133)

          at org.jgroups.protocols.FD.up(FD.java:275)

          at org.jgroups.protocols.FD_SOCK.up(FD_SOCK.java:275)

          at org.jgroups.protocols.MERGE2.up(MERGE2.java:209)

          at org.jgroups.protocols.Discovery.up(Discovery.java:293)

          at org.jgroups.protocols.TP.passMessageUp(TP.java:1109)

          at org.jgroups.protocols.TP$IncomingPacket.handleMyMessage(TP.java:1665)

          at org.jgroups.protocols.TP$IncomingPacket.run(TP.java:1647)

          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

          at java.lang.Thread.run(Thread.java:662)

      Caused by: java.io.InvalidClassException: org.hibernate.cache.infinispan.util.CacheHelper$EvictAll; Class is non-public or has no public no-arg constructor

          at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1250)

          at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:272)

          at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)

          at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:37)

          at org.infinispan.container.entries.ImmortalCacheEntry$Externalizer.readObject(ImmortalCacheEntry.java:132)

          at org.infinispan.container.entries.ImmortalCacheEntry$Externalizer.readObject(ImmortalCacheEntry.java:123)

          at org.infinispan.marshall.jboss.ExternalizerTable$ExternalizerAdapter.readObject(ExternalizerTable.java:356)

          at org.infinispan.marshall.jboss.ExternalizerTable.readObject(ExternalizerTable.java:244)

          at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:351)

          at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)

          at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:37)

          at org.infinispan.marshall.exts.SetExternalizer.readObject(SetExternalizer.java:78)

          at org.infinispan.marshall.exts.SetExternalizer.readObject(SetExternalizer.java:47)

          at org.infinispan.marshall.jboss.ExternalizerTable$ExternalizerAdapter.readObject(ExternalizerTable.java:356)

          at org.infinispan.marshall.jboss.ExternalizerTable.readObject(ExternalizerTable.java:244)

          at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:351)

          at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)

          at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:37)

          at org.infinispan.marshall.jboss.GenericJBossMarshaller.objectFromObjectStream(GenericJBossMarshaller.java:194)

          at org.infinispan.marshall.VersionAwareMarshaller.objectFromObjectStream(VersionAwareMarshaller.java:191)

          at org.infinispan.statetransfer.StateTransferManagerImpl.applyInMemoryState(StateTransferManagerImpl.java:308)

          ... 29 more

       

      -----------------

       

      Please help me out of this.

      Here're my configurations:

       

           1. Jar files:

                hibernate-core-3.6.3.Final.jar

                hibernate-infinispan-3.6.8.Final.jar

                infinispan-core-5.0.1.jar

       

           2. Spring bean:

      <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">

              <property name="hibernateProperties">

                  <props>

                      <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>

                      <prop key="hibernate.cache.use_second_level_cache">true</prop>

                      <prop key="hibernate.cache.use_query_cache">true</prop>

                      <prop key="hibernate.cache.infinispan.cachemanager">java:CacheManager</prop>

                      <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.infinispan.InfinispanRegionFactory</prop>

                      <prop key="hibernate.cache.infinispan.cfg">hibernate-cache-infinispan.xml</prop>

       

                      <prop key="hibernate.search.default.directory_provider">infinispan</prop>

                      <prop key="hibernate.search.infinispan.configuration_resourcename">hibernate-search-infinispan.xml</prop>

                  </props>

              </property>

          </bean>

       

          3. hibernate-cache-infinispan.xml

      <?xml version="1.0" encoding="UTF-8"?>

      <infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

          xsi:schemaLocation="urn:infinispan:config:5.0 http://www.infinispan.org/schemas/infinispan-config-5.0.xsd"

          xmlns="urn:infinispan:config:5.0">

          <!-- *************************** -->

          <!-- System-wide global settings -->

          <!-- *************************** -->

          <global>

              <!-- Duplicate domains are allowed so that multiple deployments with default

                  configuration of Hibernate Search applications work - if possible it would

                  be better to use JNDI to share the CacheManager across applications -->

              <globalJmxStatistics enabled="false"

                  cacheManagerName="HibernateCache" allowDuplicateDomains="true" />

       

              <transport clusterName="infinispan-hibernate-cache-cluster"

                  distributedSyncTimeout="60000"

                  transportClass="org.infinispan.remoting.transport.jgroups.JGroupsTransport">

                  <properties>

                      <property name="configurationFile" value="jgroups-cache.xml" />

                  </properties>

              </transport>

       

              <!-- Used to register JVM shutdown hooks. hookBehavior: DEFAULT, REGISTER,

                  DONT_REGISTER. Hibernate Search takes care to stop the CacheManager so registering

                  is not needed -->

              <shutdown hookBehavior="DONT_REGISTER" />

          </global>

       

          <!-- *************************** -->

          <!-- Default "template" settings -->

          <!-- *************************** -->

       

          <default>

              <locking lockAcquisitionTimeout="60000" writeSkewCheck="false"

                  concurrencyLevel="500" useLockStriping="false" />

       

       

              <!--<lazyDeserialization enabled="false"/> -->

              <storeAsBinary enabled="false" />

       

       

              <!-- Invocation batching is required for use with the Lucene Directory -->

              <invocationBatching enabled="true" />

       

       

              <!-- This element specifies that the cache is clustered. modes supported:

                  distribution (d), replication (r) or invalidation (i). Don't use invalidation

                  to store Lucene indexes (as with Hibernate Search DirectoryProvider). Replication

                  is recommended for best performance of Lucene indexes, but make sure you

                  have enough memory to store the index in your heap. Also distribution scales

                  much better than replication on high number of nodes in the cluster. -->

              <clustering mode="replication">

                  <!-- Prefer loading all data at startup than later -->

                  <stateRetrieval timeout="60000" logFlushTimeout="60000"

                      fetchInMemoryState="true" alwaysProvideInMemoryState="true" />

                  <!-- Network calls are synchronous by default -->

                  <sync replTimeout="60000" />

              </clustering>

              <jmxStatistics enabled="false" />

              <eviction maxEntries="-1" strategy="NONE" />

              <expiration maxIdle="-1" />

          </default>

      </infinispan>

       

          4. jgroups-cache.xml

      <config xmlns="urn:org:jgroups" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

          xsi:schemaLocation="urn:org:jgroups JGroups-2.12.xsd">

          <TCP bind_port="${jgroups.tcp.port:8800}" loopback="true"

              port_range="30" recv_buf_size="20000000" send_buf_size="640000"

              discard_incompatible_packets="true" max_bundle_size="64000"

              max_bundle_timeout="30" enable_bundling="true" use_send_queues="true"

              sock_conn_timeout="300" enable_diagnostics="false"

              thread_pool.enabled="true" thread_pool.min_threads="2"

              thread_pool.max_threads="30" thread_pool.keep_alive_time="5000"

              thread_pool.queue_enabled="false" thread_pool.queue_max_size="100"

              thread_pool.rejection_policy="Discard" oob_thread_pool.enabled="true"

              oob_thread_pool.min_threads="2" oob_thread_pool.max_threads="30"

              oob_thread_pool.keep_alive_time="5000" oob_thread_pool.queue_enabled="false"

              oob_thread_pool.queue_max_size="100" oob_thread_pool.rejection_policy="Discard" />

       

       

          <JDBC_PING connection_driver="com.mysql.jdbc.Driver"

              connection_username="root" connection_password="root"

              connection_url="jdbc:mysql://localhost/clientdb2" level="info" />

       

       

          <MERGE2 max_interval="30000" min_interval="10000" />

          <FD_SOCK />

          <FD timeout="3000" max_tries="3" />

          <VERIFY_SUSPECT timeout="1500" />

          <pbcast.NAKACK use_mcast_xmit="false" gc_lag="0"

              retransmit_timeout="300,600,1200,2400,4800" discard_delivered_msgs="false" />

          <UNICAST timeout="300,600,1200" />

          <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"

              max_bytes="400000" />

       

       

          <pbcast.GMS print_local_addr="false" join_timeout="7000"

              view_bundling="true" />

          <UFC max_credits="2000000" min_threshold="0.10" />

          <MFC max_credits="2000000" min_threshold="0.10" />

          <FRAG2 frag_size="60000" />

          <pbcast.STREAMING_STATE_TRANSFER bind_port="8850" />

      </config>

      -----------------

       

      Thanks a lot and Best regards,