0 Replies Latest reply on Mar 12, 2013 3:59 AM by varsha g

    Sharing data between wars using infinispan

    varsha g Newbie

        Hello ,

           I'm having an ear which contains two wars and a jar,I want to share some variables between war and instantiated by jar.

           This can be done by Infinispan.But I'm not getting how to make this work.

           I've created simple app,

          Which has 2 servlets 1 puts data to cache and other accesses same cache to get data.I shared DefaultCacheManager's object using session to make it work.

          Now how to do this under two wars?


          These are my servlet contents


                  HttpSession session1=request.getSession(true);

                  DefaultCacheManager m =new DefaultCacheManager("cluster.xml");

                  Cache<Integer, Ticket> cache = m.getCache();

                  session1.setAttribute("DefaultCacheManager", m);

                  cache.put(1, new Ticket("abc","Evening"));

                  cache.put(2, new Ticket("pqr","Morning"));

                  cache.put(3, new Ticket("lmn","Afternoon"));

                  System.out.println("Added to cache.");



                  HttpSession session1=request.getSession(false);

                  DefaultCacheManager m=(DefaultCacheManager)session1.getAttribute("DefaultCacheManager");

                  Cache<Integer, Ticket> cache = m.getCache();


                  Set<Integer> set = cache.keySet();

                  for (Integer ticket: set) {






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



                        <transport clusterName="demoCluster"/>

                        <globalJmxStatistics enabled="true"/>



                        <jmxStatistics enabled="true"/>

                        <clustering mode="distribution">

                       <l1 enabled="true" lifespan="60000"/>

                       <hash numOwners="2" rehashRpcTimeout="120000"/>






          I'm very new to this concept.Please help.