Custom eviction using JndiMultiplexedJBossCacheRegionFactory
ducon_lajoie Mar 16, 2010 11:27 AMHi,
I'm trying to use a custom eviction policy for an ear that uses JPA (following chap. 4 of the JBoss Cache Guide). I have an exploded ear, an exploded sar. My ear contains the required files and jars used for persistence. The persistence.xml file is as such:
<?
xml version="1.0" encoding="UTF-8"?> <
persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="HibernateTest"
transaction-type="JTA">
<jta-data-source>java:datasources/HibernateTest</jta-data-source>
<properties>
<property name="hibernate.dialect" value="com.xxx.hibernate.dialect.SQLServerUnicodeDialect" />
<property name="hibernate.hbm2ddl.auto" value="none" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.generate_statistics" value="true" />
<property name="hibernate.cache.use_second_level_cache" value="true" />
<property name="hibernate.cache.use_query_cache" value="true" />
<property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.jbc2.JndiMultiplexedJBossCacheRegionFactory" />
<property name="hibernate.cache.region.jbc2.cachefactory" value="java:CacheManager" />
<property name="hibernate.cache.region.jbc2.cfg.entity" value="mvcc-entity" />
<property name="hibernate.cache.region.jbc2.cfg.query" value="local-query" />
<property name="hibernate.cache.region_prefix" value="HibernateTest" />
</properties>
</persistence-unit> </
persistence>
My jboss-service.xml file in my sar is as such:
<
server>
<mbean
code="org.hibernate.cache.jbc2.JndiMultiplexedJBossCacheRegionFactory"
name="jboss.cache:service=JBossCacheManager">
<attribute name="EvictionPolicyConfig">
<config>
<attribute name="wakeUpIntervalSeconds">5</attribute>
<attribute name="policyClass">org.jboss.cache.eviction.LRUPolicy
</attribute>
<region name="/_default_">
<attribute name="maxNodes">500</attribute>
<attribute name="timeToLiveSeconds">300</attribute>
<attribute name="minTimeToLiveSeconds">120</attribute>
</region>
<region name="/TS" policyClass="org.jboss.cache.eviction.NullEvictionPolicy" />
<region name="/HibernateTest/HibernateTest">
<attribute name="maxNodes">1</attribute>
<attribute name="timeToLiveSeconds">10</attribute>
<attribute name="minTimeToLiveSeconds">5</attribute>
</region>
<region name="/HibernateTest/com/c3/hibernate/test/dto">
<attribute name="maxNodes">50000</attribute>
<attribute name="timeToLiveSeconds">1200</attribute>
<attribute name="minTimeToLiveSeconds">120</attribute>
</region>
</config>
</attribute>
</mbean> </
server>
Except that trying to deploy this results in an exception:
*** DEPLOYMENTS IN ERROR: Name -> Error
vfsfile:/T:/JBoss-Deploy/HibernateTest.sar/ -> org.jboss.deployers.spi.DeploymentException: Error deploying: jboss.cache:service=JBossCacheManager
DEPLOYMENTS IN ERROR:
Deployment "vfsfile:/T:/JBoss-Deploy/HibernateTest.sar/" is in error due to the following reason(s): javax.management.NotCompliantMBeanException: Class does not expose a management interface: java.lang.Object
at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:993)
at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:939)
at org.jboss.deployers.plugins.main.MainDeployerImpl.checkComplete(MainDeployerImpl.java:873)
at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.checkComplete(MainDeployerAdapter.java:128)
at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDScanner.java:369)
at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScanner.java:255)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
preceded by:
11:23:44,001 ERROR [AbstractKernelController] Error installing to Instantiated: name=jboss.cache:service=JBossCacheManager state=Described mode=Manual requiredState=Configured
javax.management.NotCompliantMBeanException: Class does not expose a management interface: java.lang.Object
Does anyone have any idea how I'm supposed to configure an eviction policy in my sar for this particular factory?
Thanks in advance,
Greg