0 Replies Latest reply: Jun 12, 2012 1:59 AM by 878913 RSS

    Coherence with toplink grid

    878913
      Hi All , I am working with J PA coherence using top Link grid i have taken a dynamic web project from eclipse .(My requirement is to my web application is integrating with database in that i am using coherence as well when ever the database got shutdown i have to retrieve  the data from the coherence cache)
      *1.created the JPA dynamic webproject*
      *2.calling entities from the tables(configured the persistence.xml)*
      *3.I have created the jsp file to put the data into the database*

      <%@ page import=" javax.persistence.EntityManager"%>
      <%@ page import= "javax.persistence.EntityManagerFactory" %>
      <%@ page import= "javax.persistence.Persistence"%>
      <%@ page import=" com.lakshman.weblogicJPA.Employee"%>
      <%
      EntityManagerFactory emf = Persistence.createEntityManagerFactory("WeblogicJPA");
                     
                     EntityManager em = emf.createEntityManager();
                
                     em.getTransaction().begin();
                     //Employee emp = new Employee();
                emp.setEmpId(101);
                emp.setEmpSummary("my jpa web apps");
                emp.setEmpDescription("????????????");
                
                     em.persist(emp);
      %>
      Its working fine (Successfully Inserted data into the database)

      After that ihave created another method to get the data from database which i have inserted before...
      code:
      Employee emp1=em.find(Employee.class,116L);
                out.println(emp1.getEmpDescription());
                out.println(emp1.getEmpId());
                     em.getTransaction().commit();

      This is also working fine(I got the data what ever inserted before)

      *4.created coherence-cache-config.xml(to created the cache server )*
      code :
      <?xml version="1.0"?>
      <!DOCTYPE cache-config SYSTEM "cache-config.dtd">

      <cache-config>
      <defaults>
      <serializer system-property="tangosol.coherence.serializer"/>

      <socket-provider system-property="tangosol.coherence.socketprovider"/>
      </defaults>


      <caching-scheme-mapping>
      <cache-mapping>
      <!-- Set the name of the cache to be the entity name -->
      <cache-name>Employee</cache-name>
      <!-- Configure this cache to use the scheme defined below -->
      <scheme-name>jpa-distributed</scheme-name>
      </cache-mapping>
      </caching-scheme-mapping>
      <caching-schemes>
      <distributed-scheme>
      <scheme-name>jpa-distributed</scheme-name>
      <service-name>JpaDistributedCache</service-name>
      <backing-map-scheme>
      <read-write-backing-map-scheme>
      <!--
      Define the cache scheme
      -->
      <internal-cache-scheme>
      <local-scheme/>
      </internal-cache-scheme>
      <cachestore-scheme>
      <class-scheme>
      <class-name>com.tangosol.coherence.jpa.JpaCacheStore</class-name>
      <init-params>
      <!--
      This param is the entity name
      This param is the fully qualified entity class
      This param should match the value of the
      persistence unit name in persistence.xml
      -->
      <init-param>
      <param-type>java.lang.String</param-type>
      <param-value>{cache-name}</param-value>
      </init-param>
      <init-param>
      <param-type>java.lang.String</param-type>
      <param-value>com.lakshman.weblogicJPA.{cache-name}</param-value>
      </init-param>
      <init-param>
      <param-type>java.lang.String</param-type>
      <param-value>WeblogicJPA</param-value>
      </init-param>
      </init-params>
      </class-scheme>
      </cachestore-scheme>
      </read-write-backing-map-scheme>
      </backing-map-scheme>
      <autostart>true</autostart>
      </distributed-scheme>
      </caching-schemes>
      </cache-config>

      After deploying my application into the weblogic server .

      The data was  not inserted into cache server_
      when i am trying to start cache server its showing the following error :_

      i imported  cohernce-cache-config.xml path  into my default cache , coherence servers as well
      1.coherence.jpa.jar,coherence-eclipselink.jar.javax-persistance.jar,coherence-common.jar,toplinkgrid,jar into cache

      <param-value>Employee</param-value>
      </init-param>
      <init-param>
      <param-type>java.lang.String</param-type>
      <param-value>com.lakshman.weblogicJPA.Employee</param-value>
      </init-param>
      <init-param>
      <param-type>java.lang.String</param-type>
      <param-value>WeblogicJPA</param-value>
      </init-param>
      </init-params>
      </class-scheme>) java.lang.ClassNotFoundException: com.tangosol.coherence.jpa.JpaCacheStore
      at com.tangosol.util.Base.ensureRuntimeException(Base.java:293)
      at com.tangosol.run.xml.XmlHelper.createInstance(XmlHelper.java:2542)
      at com.tangosol.run.xml.XmlHelper.createInstance(XmlHelper.java:2426)
      at com.tangosol.net.DefaultConfigurableCacheFactory.instantiateAny(DefaultConfigurableCacheFactory.java:3256)
      at com.tangosol.net.DefaultConfigurableCacheFactory.instantiateCacheStore(DefaultConfigurableCacheFactory.java:3106)
      at com.tangosol.net.DefaultConfigurableCacheFactory.instantiateReadWriteBackingMap(DefaultConfigurableCacheFactory.java:1674)
      at com.tangosol.net.DefaultConfigurableCacheFactory.configureBackingMap(DefaultConfigurableCacheFactory.java:1429)
      at com.tangosol.net.DefaultConfigurableCacheFactory$Manager.instantiateBackingMap(DefaultConfigurableCacheFactory.java:3904)
      at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$Storage.instantiateResourceMap
      at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$Storage.setCacheName(Partition
      at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache.ensureKnownStorage(Partitioned
      at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache.finalizeAcceptingClients(Parti
      at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.PartitionedService.finalizeStartup(PartitionedService.CDB:15)
      at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.PartitionedService.onServiceStarted(PartitionedService.CDB:70)
      at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache.onServiceStarted(PartitionedCa
      at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid$MemberWelcomeRequest$Poll.onCompletion(Grid.CDB:18)
      at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.PartitionedService$MemberWelcomeRequest$Poll.onCompletion(Partitio
      at com.tangosol.coherence.component.net.Poll.close(Poll.CDB:13)
      at com.tangosol.coherence.component.net.Poll.onResponded(Poll.CDB:32)
      at com.tangosol.coherence.component.net.Poll.onResponse(Poll.CDB:3)
      at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.onMessage(Grid.CDB:26)
      at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.onNotify(Grid.CDB:33)
      at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.PartitionedService.onNotify(PartitionedService.CDB:3)
      at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache.onNotify(PartitionedCache.CDB:
      at com.tangosol.coherence.component.util.Daemon.run(Daemon.CDB:42)
      at java.lang.Thread.run(Thread.java:662)
      Caused by: java.lang.ClassNotFoundException: com.tangosol.coherence.jpa.JpaCacheStore
      at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:169)
      at com.tangosol.util.ExternalizableHelper.loadClass(ExternalizableHelper.java:3011)
      at com.tangosol.run.xml.XmlHelper.createInstance(XmlHelper.java:2500)
      ... 24 more
      2012-06-11 19:05:59.647/1.915 Oracle Coherence GE 3.6.0.4 <D4> (thread=DistributedCache:JpaDistributedCache, member=2): Asking member 7 for 20 primary
      2012-06-11 19:05:59.780/2.049 Oracle Coherence GE 3.6.0.4 <D4> (thread=DistributedCache:JpaDistributedCache, member=2): Asking member 8 for 21 primary
      2012-06-11 19:05:59.916/2.184 Oracle Coherence GE 3.6.0.4 <D4> (thread=DistributedCache:JpaDistributedCache, member=2): Asking member 1 for 21 primary
      2012-06-11 19:06:00.035/2.303 Oracle Coherence GE 3.6.0.4 <D4> (thread=DistributedCache:JpaDistributedCache, member=2): Asking member 7 for 1 primary
      2012-06-11 19:06:00.138/2.406 Oracle Coherence GE 3.6.0.4 <D4> (thread=DistributedCache:JpaDistributedCache, member=2): Asking member 1 for 1 primary

      without shutdown the database also data is not showing in cache ,(My requirement is to data should be available even database shutdown also)
      Is it correct way  to interacting with coherence ,

      How to approach to solve this problem , pls help me how to do my requirement
      is there any extra settings i need to do change to store the data into cache  servers...

      pls provide me the details ...

      is there any storage i need to create to store the data in cache


      Thanks-laxman