[Logo] Terracotta Discussion Forums
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
problem setting up ehcache jmx monitoring with jboss 4.3.0.  XML
Forum Index -> Ehcache
Author Message
latchkey

journeyman

Joined: 11/03/2009 11:23:54
Messages: 10
Offline

Hi everyone,

I'm using Hibernate with JBoss 4.3.0 and EJB3 entities.

I've defined my persistence.xml like this:

<?xml version="1.0" encoding="UTF-8"?>
<persistence>
<persistence-unit name="heart">
<jta-data-source>java:/HeartDS</jta-data-source>
<properties>
<property name="hibernate.query.jpaql_strict_compliance" value="false"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.max_fetch_depth" value="0"/>
<property name="hibernate.cache.use_query_cache" value="true"/>
<property name="hibernate.generate_statistics" value="true"/>
<property name="hibernate.cache.provider_class" value="net.sf.ehcache.hibernate.SingletonEhCacheProvider"/>
</properties>
</persistence-unit>
</persistence>

Thus, my caches are named like this automatically by Hibernate...

cache named [heart_ear,heart-biz_jar,heart.com.kink.heart.entity.liveshow.LiveShow]

I've created a simple EJB3 @Service bean in order to enable ehcache jmx monitoring based on some reading I did in the documentation and googling around for examples.

@Service(name="CacheBeanMgr", objectName="Kink.heart:service=CacheBeanMgr")
@LocalBinding(jndiBinding=CacheBean.JNDI_NAME)
@RemoteBinding(jndiBinding=CacheBeanRemote.JNDI_NAME)
public class CacheBeanMgr extends EntityManipulatorBean implements CacheBean, CacheBeanRemote, SimpleLifecycle
{
/** */
@SuppressWarnings("unused")
private static final Log log = LogFactory.getLog(CacheBeanMgr.class);

@Override
@PermitAll
public void start() throws Exception
{
ObjectName on = new ObjectName("Hibernate:type=statistics,application=heart");
StatisticsService statsMBean = new StatisticsService();
statsMBean.setSessionFactory(this.hem.getHibernateSession().getSessionFactory());
statsMBean.setStatisticsEnabled(true);
MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();

mbeanServer.registerMBean(statsMBean, on);

// Enable Ehcache JMX Statistics
CacheManager cacheMgr = CacheManager.getInstance();
ManagementService.registerMBeans(cacheMgr, mbeanServer, true, true, true, true);
}

@Override
@PermitAll
public void stop() throws Exception
{
}
}

I've confirmed that the cacheMgr.getCacheNames() returns a list of off my cache names.

However, the service bean fails with the following exception:

Caused by: net.sf.ehcache.CacheException: net.sf.ehcache.CacheException: javax.management.MalformedObjectNameException: Invalid character ',' in key part of property
at net.sf.ehcache.management.ManagementService.init(ManagementService.java:165)
at net.sf.ehcache.management.ManagementService.registerMBeans(ManagementService.java:141)
at com.kink.heart.biz.admin.CacheBeanMgr.start(CacheBeanMgr.java:64)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
... 172 more
Caused by: net.sf.ehcache.CacheException: javax.management.MalformedObjectNameException: Invalid character ',' in key part of property
at net.sf.ehcache.management.Cache.createObjectName(Cache.java:73)
at net.sf.ehcache.management.Cache.<init>(Cache.java:61)
at net.sf.ehcache.management.CacheManager.getCache(CacheManager.java:105)
at net.sf.ehcache.management.CacheManager.getCaches(CacheManager.java:124)
at net.sf.ehcache.management.ManagementService.init(ManagementService.java:157)
... 184 more
Caused by: javax.management.MalformedObjectNameException: Invalid character ',' in key part of property
at javax.management.ObjectName.construct(ObjectName.java:535)
at javax.management.ObjectName.<init>(ObjectName.java:1403)
at net.sf.ehcache.management.Cache.createObjectName(Cache.java:70)
... 188 more

The key part of the property is my cache name as described above...

heart_ear,heart-biz_jar,heart.com.kink.heart.entity.liveshow.LiveShow

Since I don't seem to have control over the names of my caches as they are automatically defined, what do you think a solution to this problem might be?

thanks,

jon
latchkey

journeyman

Joined: 11/03/2009 11:23:54
Messages: 10
Offline

Ok, problem solved... I added this to the persistence.xml...

<!-- removes the heart_ear,heart-biz_jar,heart. prefix on the cache name -->
<property name="hibernate.cache.region_prefix" value=""/>
teck

seraphim
[Avatar]
Joined: 05/24/2006 15:03:25
Messages: 1099
Offline

thanks for letting us know you found a workaround :-)

Tim Eck (terracotta engineer)
rajoshi

seraphim

Joined: 07/04/2011 04:36:10
Messages: 1465
Offline

The issue seems to be resolved.Please let know in case of more information.

Rakesh Joshi
Terracotta.
 
Forum Index -> Ehcache
Go to:   
Powered by JForum 2.1.7 © JForum Team