CDV ❯ MalformedObjectNameException with hibernate cache
-
Bug
-
Status: Closed
-
2 Major
-
Resolution: Fixed
-
-
-
kkannaiy
-
Reporter: teck
-
March 10, 2010
-
0
-
Watchers: 0
-
February 12, 2013
-
April 07, 2010
Description
http://forums.terracotta.org/forums/posts/list/3268.page
Hopefully we’ll get the stack traces, but I think anywhere we construct ObjectNames for the beans we register, we need to make any Strings we acquire from the environment to construct that name are sanitized
The old hibernate cache implementation has some workaround for this exact issue I think
Comments
Tim Eck 2010-03-11
Gary Keim 2010-04-07
s = s.replaceAll(“: | \n | =”, “.”) |
Kalai Kannaiyan 2010-05-10
Reproduced this issue with 3.2.1 with events hibernate sample, when cache.region_prefix property and cachemanager are set with invalid character “:”, MBeanRegistrationException and javax.management.MalformedObjectNameException are thrown
Verified with 3.2.1_2 kit with hibernate sample, it is working fine. When cache.region_prefix property and cachemanager are set with invalid character “:”, it is replaced with “.” and NO exception is thrown as excepted.
- SET the cache.region_prefix property with invalid character “:”
Steps:
- set the cache.region_prefix property with invalid character “:” i.e, “Events” to “Events:” in the hibernate.cfg.xml under \terracotta-3.2.1\ehcache\samples\hibernate\src\main\resources
- start the TC server
- start the db
- start the hibernate sample
- Hit the http://localhost:9081/Events
- Launch the jconsole and connect to TC server
Actual: No exception is thrown as expected and “:” is replaced with “.” ObjectName is displayed with cache region prefix contains invalid character “:” is replaced with “.” i.e, Events..
- SET the cache manager with invalid character “:”
Steps:
- set the cache manager name with invalid character “:” i.e, “EventCache” to “EventsCache:” in the ehcache.xml under \terracotta-3.2.1\ehcache\samples\hibernate\src\main\resources
- start the TC server
- start the db
- start the hibernate sample
- Hit the http://localhost:9081/Events
- Launch the jconsole and connect to TC server
Actual: No exception is thrown as expected and “:” is replaced with “.” ObjectName is displayed with cache manager contains invalid character “:” is replaced with “.” i.e., EventCache.
2010-05-10 14:51:34,125 [Thread-27] INFO com.tc.management.remote.connect.ClientConnectEventHandler - Tunneled MBean ‘net.sf.ehcache.hibernate:name=EventCache.,type=EhcacheHibernateStats,clients=Clients,node=kkannapc.terracotta.lan/1787’ 2010-05-10 14:51:34,671 [Thread-27] INFO com.tc.management.remote.connect.ClientConnectEventHandler - Tunneled MBean ‘net.sf.ehcache:SampledCacheManager=EventCache.,name=Events..org.hibernate.tutorial.domain.Event,type=SampledCache,clients=Clients,node=kkannapc.terracotta.lan/1787’ 2010-05-10 14:51:36,187 [Thread-27] INFO com.tc.management.remote.connect.ClientConnectEventHandler - Tunneled MBean ‘net.sf.ehcache:SampledCacheManager=EventCache.,name=Events..org.hibernate.cache.UpdateTimestampsCache,type=SampledCache,clients=Clients,node=kkannapc.terracotta.lan/1787’ 2010-05-10 14:51:36,343 [Thread-27] INFO com.tc.management.remote.connect.ClientConnectEventHandler - Tunneled MBean ‘net.sf.ehcache:SampledCacheManager=EventCache.,name=Events..org.hibernate.cache.StandardQueryCache,type=SampledCache,clients=Clients,node=kkannapc.terracotta.lan/1787’
OK, so here it is :
If I do not set the hibernate.cache.region_prefix property I get :
10:11:11,086 WARN [SampledMBeanRegistrationProvider] Error registering cache for management for 10_rmp-logger-bali-SNAPSHOT_jar,LogUP.com.runmyprocess.log.instrument.RequestInfo . Error was null javax.management.MBeanRegistrationException at net.sf.ehcache.management.sampled.SampledMBeanRegistrationProvider.registerCacheMBean(SampledMBeanRegistrationProvider.java:166) at net.sf.ehcache.management.sampled.SampledMBeanRegistrationProvider.notifyCacheAdded(SampledMBeanRegistrationProvider.java:229) at net.sf.ehcache.event.CacheManagerEventListenerRegistry.notifyCacheAdded(CacheManagerEventListenerRegistry.java:159) at net.sf.ehcache.CacheManager.addCacheNoCheck(CacheManager.java:943) at net.sf.ehcache.CacheManager.addCache(CacheManager.java:915) at net.sf.ehcache.CacheManager.addCache(CacheManager.java:870) at net.sf.ehcache.hibernate.AbstractEhcacheProvider.buildCache(AbstractEhcacheProvider.java:66) at org.hibernate.cache.CacheFactory.createCache(CacheFactory.java:61) at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:214)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:713)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:127)
[... snip ...]
at $Proxy5.deploy(Unknown Source)
at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
at org.jboss.Main.boot(Main.java:200)
at org.jboss.Main$1.run(Main.java:508)
at java.lang.Thread.run(Thread.java:637)
Caused by: javax.management.MalformedObjectNameException: Invalid character ',' in key part of property
at javax.management.ObjectName.construct(ObjectName.java:535)
at javax.management.ObjectName.(ObjectName.java:1403)
at net.sf.ehcache.management.sampled.SampledEhcacheMBeans.getCacheObjectName(SampledEhcacheMBeans.java:100)
at net.sf.ehcache.management.sampled.SampledMBeanRegistrationProvider.registerCacheMBean(SampledMBeanRegistrationProvider.java:162)
... 154 more
10:11:11,156 ERROR [STDERR] Exception in thread "MyCache"
10:11:11,174 ERROR [STDERR] org.hibernate.cache.CacheException: javax.management.MalformedObjectNameException: Invalid character ':' in value part of property
at net.sf.ehcache.hibernate.management.impl.ProviderMBeanRegistrationHelper$RegisterMBeansTask.run(ProviderMBeanRegistrationHelper.java:91)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
Caused by: javax.management.MalformedObjectNameException: Invalid character ':' in value part of property
at javax.management.ObjectName.construct(ObjectName.java:602)
at javax.management.ObjectName.(ObjectName.java:1403)
at net.sf.ehcache.hibernate.management.impl.EhcacheHibernateMbeanNames.getCacheManagerObjectName(EhcacheHibernateMbeanNames.java:51)
at net.sf.ehcache.hibernate.management.impl.EhcacheHibernateMBeanRegistrationImpl.registerBean(EhcacheHibernateMBeanRegistrationImpl.java:85)
at net.sf.ehcache.hibernate.management.impl.EhcacheHibernateMBeanRegistrationImpl.registerMBeanForCacheManager(EhcacheHibernateMBeanRegistrationImpl.java:68)
at net.sf.ehcache.hibernate.management.impl.ProviderMBeanRegistrationHelper$RegisterMBeansTask.run(ProviderMBeanRegistrationHelper.java:88)
... 2 more
(snipped traces available on request ;-) mainly jboss plumbing )
When I set the hibernate.cache.region_prefix property but not the hibernate.session_factory_name property, I get :
10:48:19,385 ERROR [STDERR] Exception in thread “MyCache” 10:48:19,396 ERROR [STDERR] org.hibernate.cache.CacheException: javax.management.MalformedObjectNameException: Invalid character ‘:’ in value part of property at net.sf.ehcache.hibernate.management.impl.ProviderMBeanRegistrationHelper$RegisterMBeansTask.run(ProviderMBeanRegistrationHelper.java:91) at java.util.TimerThread.mainLoop(Timer.java:512) at java.util.TimerThread.run(Timer.java:462) Caused by: javax.management.MalformedObjectNameException: Invalid character ‘:’ in value part of property at javax.management.ObjectName.construct(ObjectName.java:602) at javax.management.ObjectName.(ObjectName.java:1403)
at net.sf.ehcache.hibernate.management.impl.EhcacheHibernateMbeanNames.getCacheManagerObjectName(EhcacheHibernateMbeanNames.java:51)
at net.sf.ehcache.hibernate.management.impl.EhcacheHibernateMBeanRegistrationImpl.registerBean(EhcacheHibernateMBeanRegistrationImpl.java:85)
at net.sf.ehcache.hibernate.management.impl.EhcacheHibernateMBeanRegistrationImpl.registerMBeanForCacheManager(EhcacheHibernateMBeanRegistrationImpl.java:68)
at net.sf.ehcache.hibernate.management.impl.ProviderMBeanRegistrationHelper$RegisterMBeansTask.run(ProviderMBeanRegistrationHelper.java:88)
... 2 more
(much harder to diagnose, since the incriminated name is not logged…, it was : ‘persistence.units:jar=10_rmp-logger-bali-SNAPSHOT.jar,unitName=LogUP’ in this case).