[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
15 years, 6 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
15 years, 6 months
[Installation, Configuration & DEPLOYMENT] - Re: Migration problem to JBoss 5 GA
by onur.aktas
Hi.. Thank you for your reply. This EJB work with JBoss 4.2.3 GA and does not work with JBoss 5.0 GA
| package com.test.model.ejb.system;
|
| import com.test.model.entity.system.Usr;
| import javax.ejb.Stateless;
|
| @Stateless(name = "UsrEJB")
| public class UsrEJBBean implements UsrEJB, UsrEJBLocal {
| @PersistenceContext(name = "testPU")
| EntityManager em;
|
| public UsrEJBBean() {
| }
|
| public Usr persist(Usr usrEntity) {
| em.persist(usrEntity);
| return usrEntity;
| }
| }
It does not give any error, just warnings but it does not bind EJB to JNDI Tree like JBoss 4.2.3 GA.
Related Console logs when i deploy:
19:59:20,145 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
| 19:59:20,145 INFO [UpdateTimestampsCache] starting update timestamps cache at region: persistence.unit:unitName=test.ear/testEjb.jar#testPU.org.hibernate.cache.UpdateTimestampsCache
| 19:59:20,145 INFO [StandardQueryCache] starting query cache at region: persistence.unit:unitName=test.ear/testEjb.jar#testPU.org.hibernate.cache.StandardQueryCache
|
| 19:59:20,285 INFO [SessionSpecContainer] Starting jboss.j2ee:ear=test.ear,jar=testEjb.jar,name=UsrEJB,service=EJB3
| 19:59:20,286 INFO [EJBContainer] STARTED EJB: com.test.model.ejb.system.UsrEJBBean ejbName: UsrEJB
| 19:59:20,286 INFO [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:
|
|
| 19:59:20,339 WARN [WebServiceDeployerEJB] Ingore ejb deployment with null classname: org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData@97955a49{UsrEJB}
| 19:59:20,768 INFO [TomcatDeployment] deploy, ctxPath=/, vfsUrl=test.ear/testWeb.war
| 19:59:21,381 INFO [JBossSerializationProvider] Using JBoss Serialization for JavaServer Faces.
| 19:59:21,398 INFO [JBossSerializationProvider] Using JBoss Serialization for JavaServer Faces.
Jndi Tree:
Other components with java:comp namespace
|
| java:comp namespace of the component jboss.j2ee:ear=test.ear,jar=testEjb.jar,name=UsrEJB,service=EJB3 :
|
| +- EJBContext (class: javax.ejb.EJBContext)
| +- TransactionSynchronizationRegistry[link -> java:TransactionSynchronizationRegistry] (class: javax.naming.LinkRef)
| +- UserTransaction (class: org.jboss.ejb3.tx.UserTransactionImpl)
| +- env (class: org.jnp.interfaces.NamingContext)
| | +- testPU (class: org.jboss.jpa.tx.TransactionScopedEntityManager)
| +- ORB[link -> java:/JBossCorbaORB] (class: javax.naming.LinkRef)
|
|
| java: Namespace
|
| +- securityManagement (class: org.jboss.security.integration.JNDIBasedSecurityManagement)
| +- comp (class: javax.namingMain.Context)
| +- testds (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
| +- XAConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
| +- JmsXA (class: org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl)
| +- TransactionPropagationContextImporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
| +- policyRegistration (class: org.jboss.security.plugins.JBossPolicyRegistration)
| +- ClusteredConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
| +- Mail (class: javax.mail.Session)
| +- TransactionPropagationContextExporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
| +- DefaultDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
| +- jaas (class: javax.naming.Context)
| | +- HsqlDbRealm (class: org.jboss.security.plugins.SecurityDomainContext)
| | +- profileservice (class: org.jboss.security.plugins.SecurityDomainContext)
| +- ClusteredXAConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
| +- TransactionSynchronizationRegistry (class: com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple)
| +- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory)
| +- ConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
| +- DefaultJMSProvider (class: org.jboss.jms.jndi.JNDIProviderAdapter)
| +- TransactionManager (class: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate)
| +- timedCacheFactory (class: javax.naming.Context)
| Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy cannot be cast to javax.naming.NamingEnumeration
|
|
| Global JNDI Namespace
|
| +- UserTransactionSessionFactory (proxy: $Proxy104 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
| +- UUIDKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.uuid.UUIDKeyGeneratorFactory)
| +- HiLoKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory)
| +- XAConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
| +- topic (class: org.jnp.interfaces.NamingContext)
| +- ClusteredConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
| +- ProfileService (class: AOPProxy$0)
| +- queue (class: org.jnp.interfaces.NamingContext)
| | +- DLQ (class: org.jboss.jms.destination.JBossQueue)
| | +- ExpiryQueue (class: org.jboss.jms.destination.JBossQueue)
| +- ClusteredXAConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
| +- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
| +- ConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
| +- jmx (class: org.jnp.interfaces.NamingContext)
| | +- invoker (class: org.jnp.interfaces.NamingContext)
| | | +- RMIAdaptor (proxy: $Proxy100 implements interface org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface org.jboss.jmx.adaptor.rmi.RMIAdaptorExt)
| | +- rmi (class: org.jnp.interfaces.NamingContext)
| | | +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class: javax.naming.LinkRef)
| +- TomcatAuthenticators (class: java.util.Properties)
| +- persistence.unit:unitName=test.ear (class: org.jnp.interfaces.NamingContext)
| | +- testEjb.jar#testPU (class: org.hibernate.impl.SessionFactoryImpl)
| +- console (class: org.jnp.interfaces.NamingContext)
| | +- PluginManager (proxy: $Proxy101 implements interface org.jboss.console.manager.PluginManagerMBean)
Thank you very much.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4198518#4198518
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4198518
15 years, 6 months