Hibernate 2nd lvl Cache for EJB3
marcreis May 24, 2006 12:42 PMHi I have a some questions about seting up the hibernate 2nd level Chach. I read some docu on this and mainly followed the http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossCacheHibernate
I am using 4.0.4.GA all.
When I use the hibernate-recommended-config.xml from the cache package (renamed to TreeCache-service.xml) I get an exception:
18:02:41,640 INFO [ServiceConfigurator] Problem configuring service jboss.cache :service=MyTreeCache org.jboss.deployment.DeploymentException: Exception setting attribute javax.mana gement.Attribute@16f8834 on mbean jboss.cache:service=MyTreeCache; - nested thro wable: (java.lang.IllegalArgumentException: setCacheMode(): caching mode -1 is i nvalid) at org.jboss.system.ServiceConfigurator.setAttribute(ServiceConfigurator .java:698) at org.jboss.system.ServiceConfigurator.configure(ServiceConfigurator.ja va:332) at org.jboss.system.ServiceConfigurator.internalInstall(ServiceConfigura tor.java:460) at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java :171) at org.jboss.system.ServiceController.install(ServiceController.java:226 ) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39) ...
I thought the CacheMode must be wrong and tried around with the other modes, with the REPL_ASYNC I get a step further and get this:
18:20:56,546 INFO [ServiceConfigurator] Problem configuring service jboss.cache :service=MyTreeCache org.jboss.deployment.DeploymentException: No Attribute found with name: FetchInM emoryState at org.jboss.system.ServiceConfigurator.configure(ServiceConfigurator.ja va:318) at org.jboss.system.ServiceConfigurator.internalInstall(ServiceConfigura tor.java:460) at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java :171) at org.jboss.system.ServiceController.install(ServiceController.java:226 ) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch) ...
So I tryed it with the existing cahes and configured my hibernate.cfg.xml to use :
<property name="cache.provider_class">org.jboss.ejb3.entity.TreeCacheProviderHook</property> <property name="treecache.mbean.object_name">jboss.cache:service=EJB3EntityTreeCache</property>
This works at first, but produces this on the node of the cluster, where my EJB's are "not called".
17:47:16,078 ERROR [STDERR] java.lang.NullPointerException 17:47:16,078 ERROR [STDERR] at org.jboss.ejb3.cache.tree.StatefulEvictionPol icy.evict(StatefulEvictionPolicy.java:48) 17:47:16,078 ERROR [STDERR] at org.jboss.cache.eviction.LRUAlgorithm.evictCa cheNode(LRUAlgorithm.java:197) 17:47:16,078 ERROR [STDERR] at org.jboss.cache.eviction.LRUAlgorithm.prune(L RUAlgorithm.java:303) 17:47:16,078 ERROR [STDERR] at org.jboss.cache.eviction.LRUAlgorithm.process (LRUAlgorithm.java:55) 17:47:16,078 ERROR [STDERR] at org.jboss.cache.eviction.EvictionTimerTask.ru n(EvictionTimerTask.java:37) 17:47:16,078 ERROR [STDERR] at java.util.TimerThread.mainLoop(Timer.java:512 ) 17:47:16,078 ERROR [STDERR] at java.util.TimerThread.run(Timer.java:462)
I also tried it with the "org.jboss.hibernate.cache.DeployedTreeCacheProvider" then it seems that the "EJB3EntityTreeCache" is not looked for but .. (have a look ->)
18:37:00,312 WARN [DeployedTreeCacheProvider] Unable to locate TreeCache MBean under object name [jboss.cache:service=HibernateTreeCache] java.lang.RuntimeException: Error creating MBeanProxy: jboss.cache:service=Hiber nateTreeCache at org.jboss.mx.util.MBeanProxyExt.init(MBeanProxyExt.java:415) at org.jboss.mx.util.MBeanProxyExt.<init>(MBeanProxyExt.java:99) at org.jboss.mx.util.MBeanProxyExt.create(MBeanProxyExt.java:394) at org.jboss.mx.util.MBeanProxyExt.create(MBeanProxyExt.java:349) at org.jboss.hibernate.cache.DeployedTreeCacheProvider.start(DeployedTre eCacheProvider.java:74) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java: 180) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav a:1213) at de.mediacare.test.util.HibTestUtil.<clinit>(HibTestUtil.java:22) at de.mediacare.test.ejbean.NatPersLstSFBean.getNatPersLst(NatPersLstSFB ean.java:43) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
So I am kind of confused on what I have to do, too do it right. Most likley I missed some obvious config somewhere...
Sincerly
Marc