1 Reply Latest reply on Aug 23, 2011 3:15 PM by Paul Ferraro

    Infinispan cache question

    ray miller Newbie

      Hi Folks,

       

         I am trying to setup a cache for my project with jboss-6.0.0.Final and infinispan. What I have done is below

       

        a) added a new block in  ..\server\all\deploy\cluster\infinispan-cache-registry.sar\infinispan-configs.xml

       

      <infinispan-config name="infinispanTest" jndi-name="java:CacheManager/infinispanTest">
            <alias>custom-testinfinispan-cache</alias>
            <infinispan xmlns="urn:infinispan:config:4.2">
              <global>
                <transport clusterName="${jboss.partition.name:DefaultPartition}-TestInfinispan" distributedSyncTimeout="17500">
                  <properties>
                    <property name="stack" value="${jboss.default.jgroups.stack:udp}"/>
                  </properties>
                </transport>
                <globalJmxStatistics enabled="true"/>
                <shutdown hookBehavior="DONT_REGISTER"/>
              </global>
              <default>
                <locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000" useLockStriping="false" concurrencyLevel="1000"/>
                <jmxStatistics enabled="true"/>
                <lazyDeserialization enabled="true"/>
                <invocationBatching enabled="true"/>
                <clustering mode="replication">
                  <!-- ISPN-835 workaround, use cluster cache loader in place of state transfer -->
                  <!--stateRetrieval timeout="60000" fetchInMemoryState="true"/-->
                  <async useReplQueue="false"/>
                </clustering>
                <loaders passivation="true">
                  <loader class="org.infinispan.loaders.file.FileCacheStore" fetchPersistentState="true" purgeOnStartup="true">
                    <properties>
                      <property name="location" value="${jboss.server.data.dir}${/}infinispantest"/>
                    </properties>
                  </loader>
                  <loader class="org.infinispan.loaders.cluster.ClusterCacheLoader"/>
                </loaders>
              </default>
              <namedCache name="numbersCache">
                <clustering mode="distribution">
                  <!-- ISPN-835 workaround, use cluster cache loader in place of state transfer -->
                  <!--stateRetrieval timeout="60000" fetchInMemoryState="false"/-->
                  <hash numOwners="2"/>
                  <async useReplQueue="false"/>
                </clustering>
                <loaders passivation="true">
                  <loader class="org.infinispan.loaders.file.FileCacheStore" fetchPersistentState="false" purgeOnStartup="true">
                    <properties>
                      <property name="location" value="${jboss.server.data.dir}${/}infinispantest"/>
                    </properties>
                  </loader>
                  <loader class="org.infinispan.loaders.cluster.ClusterCacheLoader">
                    <properties>
                      <property name="remoteCallTimeout" value="60000"/>
                    </properties>
                  </loader>
                </loaders>
              </namedCache>
            </infinispan>
          </infinispan-config>

       

      b) Then wrote a class  with a method

       

      public void putCacheData(String data, Object obj)
      {

        try
        {

         Hashtable<String, String> hash = new Hashtable<String, String>();
         hash.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
         hash.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");

         hash.put("java.naming.provider.url","jnp://localhost:1099");

         Context context = new InitialContext(hash);


         EmbeddedCacheManager cacheManager = (EmbeddedCacheManager) context.lookup("CacheManager/infinispanTest");

       

         Cache cache = cacheManager.getCache("numbersCache");

         cache.put(data,obj);

        }
        catch(Exception e)
        {
         e.printStackTrace();
        }


      }

       

      and I get the below error when invoking the above method. Am I missing something ?

       

      c)

      javax.naming.NameNotFoundException: CacheManager not bound
          at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
          at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
          at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
          at org.jnp.server.NamingServer.lookup(NamingServer.java:396)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

          at java.lang.reflect.Method.invoke(Method.java:597)
          at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305)
          at sun.rmi.transport.Transport$1.run(Transport.java:159)
          at java.security.AccessController.doPrivileged(Native Method)
          at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
          at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
          at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)

       

       

      Any suggestions on how I can get this resolved..?