[JBoss Cache: Core Edition] - Error function when working with passivation.
by kenees
Hi guys, I wrote a test application to test passivation function with JDBCCacheLoader, the application is simple, two threads, the writer thread try to put 20 nodes into the cache and the reader thread do the read operation periodically. I only set maxNodes to be 10 and passivation to be true, so I was except that there should be only 10 nodes in the cache and the other 10 are in the database, I ran the test, before passivation every thing is correct, but after the passivation operation the reader threads can not read nothing, i checked the database found JBOSSCACHE.NODE column seems contain an empty object for the object passivated here, i did try to debug the cache, found when jbossCache try to passivate a node, the node data property is always NULL, i'm not sure what the problem it was, so can anybody help me? Thanks.
My cache configuration:
<?xml version="1.0" encoding="UTF-8"?>
| <jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.0">
|
| <!-- Configure the TransactionManager -->
| <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
|
| <!-- Specific eviction policy configurations -->
| <eviction wakeUpInterval="5000">
| <!-- Cache wide default -->
| <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="200000">
| <property name="maxNodes" value="5000" />
| <property name="timeToLive" value="3000" />
| </default>
| <region name="/testRegion">
| <property name="maxNodes" value="10" />
| <property name="timeToLive" value="3000" />
| </region>
| </eviction>
|
| <!-- Cache Passivation for Tree Cache
| On passivation, The objects are written to the backend store on eviction if passivation
| is true, otherwise the objects are persisted. On activation, the objects are restored in
| the memory cache and removed from the cache loader if 'passivation' attribute is true,
| otherwise the objects are only loaded from the cache loader -->
| <loaders passivation="true" shared="false">
| <!-- if passivation is true, only the first cache loader is used; the rest are ignored -->
| <loader
| class="org.jboss.cache.loader.JDBCCacheLoader"
| async="false"
| fetchPersistentState="true"
| ignoreModifications="false"
| purgeOnStartup="false">
| <properties>
| cache.jdbc.table.name=jbosscache
| cache.jdbc.table.create=true
| cache.jdbc.table.drop=true
| cache.jdbc.table.primarykey=jbosscache_pk
| cache.jdbc.fqn.column=fqn
| cache.jdbc.fqn.type=varchar(255)
| cache.jdbc.node.column=node
| cache.jdbc.node.type=blob
| cache.jdbc.parent.column=parent
| cache.jdbc.sql-concat=1 || 2
| cache.jdbc.driver =oracle.jdbc.driver.OracleDriver
| cache.jdbc.url=jdbc:oracle:thin:@15.154.146.115:1521:perf
| cache.jdbc.user=malibu_ramon
| cache.jdbc.password=malibu_ramon
| </properties>
| </loader>
| </loaders>
| </jbosscache>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4198538#4198538
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4198538
17 years, 4 months
[Persistence, JBoss/CMP, Hibernate, Database] - Re: Could not find datasource message in client JPA although
by ezanih
Hi
I've changed my BidClient.class by adding the InitialContext code early in the class (see below) but it is giving me this error (server side is deploying OK no errors and BIDDER table created) :
Console:
| Exception in thread "main" javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]
| at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
| at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
| at javax.naming.InitialContext.init(InitialContext.java:223)
| at javax.naming.InitialContext.<init>(InitialContext.java:197)
| at Main.main(Main.java:54)
| Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory
| at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
| at java.security.AccessController.doPrivileged(Native Method)
| at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
| at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
| at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
| at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
| at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
| at java.lang.Class.forName0(Native Method)
| at java.lang.Class.forName(Class.java:242)
| at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42)
| at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
| ... 4 more
|
This is my revised BidClient.class (I run it as a Java Application in Eclipse) with the InitialContext code on top:
JPA Client Coding:
|
|
| import javax.persistence.EntityManager;
| import javax.persistence.EntityManagerFactory;
| import javax.persistence.Persistence;
| import javax.persistence.PersistenceContext;
|
| import org.apache.log4j.Level;
| import org.apache.log4j.Logger;
| import org.apache.log4j.ConsoleAppender;
| import org.apache.log4j.SimpleLayout;
|
| import my.com.eperolehan.entities.Bidder;
|
| import javax.rmi.*;
| import javax.naming.InitialContext;
| import javax.naming.NamingException;
|
| import java.util.*;
|
|
|
| public class Main {
|
|
| private static EntityManagerFactory f;
|
| @PersistenceContext(unitName="BiddingTest")
| private static EntityManager em;
|
|
| public static void main(String[] args) throws NamingException {
|
|
| Logger log = Logger.getLogger(Main.class);
| log.setLevel(Level.WARN);
|
| SimpleLayout layout = new SimpleLayout();
| ConsoleAppender appender = new ConsoleAppender(layout);
|
|
| log.addAppender(appender);
|
|
| try {
|
|
| Properties p = new Properties();
|
| p.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
| p.put("java.naming.provider.url", "localhost:1099");
|
|
| InitialContext ctx = new InitialContext( p );
|
| Object obj = ctx.lookup("/Bidder");
| Bidder bidder = (Bidder) PortableRemoteObject.narrow(obj,Bidder.class);
|
|
| System.out.println("[BidClient] : creating EntityManagerFactory...");
| log.debug("[BidClient] : creating EntityManagerFactory...");
| f = Persistence.createEntityManagerFactory("BiddingTest");
| System.out.println("[BidClient] : Created.");
| log.debug("[BidClient] : Created.");
| System.out.println("[BidClient] : creating EntityManager...");
| em = f.createEntityManager();
| System.out.println("[BidClient] : Created.");
| log.debug("[BidClient] : Created.");
|
|
| em.getTransaction().begin();
|
|
| try {
| System.out.println("[BidClient] : creating a Bidder...");
| //Bidder bidder = new Bidder();
|
| bidder.setBidderName("Bidder No 1");
| bidder.setBidSessionId(1);
|
|
| em.persist(bidder);
| em.getTransaction().commit();
| System.out.println("[BidClient] : Bidder created and commited.");
| log.debug("[BidClient] : Bidder created and commited.");
|
| } catch (Exception ex) {
| em.getTransaction().rollback();
| }
|
| System.out.println("[BidClient] : Bidder person created and persisted successfully.");
| log.debug("[BidClient] : Bidder person created and persisted successfully.");
|
| } catch (RuntimeException e) {
|
| e.printStackTrace();
|
| } finally {
|
|
|
| }
|
|
| System.out.println("[BidClient] : closing entity manager and factory...");
| log.debug("[BidClient] : closing entity manager and factory...");
| em.close();
| //f.close();
| System.out.println("[BidClient] : Closed.");
| log.debug("[BidClient] : Closed.");
|
| }
|
|
| }
|
What's wrong?
Many thanks in advance!
Ezani
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4198534#4198534
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4198534
17 years, 4 months