• Bug
  • Status: Closed
  • 2 Major
  • Resolution: Fixed
  • ehcache-monitor
  • Reporter: matbanik
  • May 23, 2010
  • 0
  • Watchers: 1
  • July 15, 2010
  • May 27, 2010

Attachments

Description

After following the README.TXT file from the monitor package this error occurred:

1081 [Thread-2] INFO org.terracotta.ehcachedx.monitor.probe.ProbeDxService - Started probe at http://192.168.11.2:57273/monitor/list Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0’ defined in ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sessionFactory’ defined in ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]: Invocation of init method failed; nested exception is org.terracotta.ehcachedx.com.javabi.sizeof.ClassDefinitionInitialisationException: java.lang.NoSuchFieldException: header at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:687) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:408) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:785) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:519) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:581) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:613) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sessionFactory’ defined in ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]: Invocation of init method failed; nested exception is org.terracotta.ehcachedx.com.javabi.sizeof.ClassDefinitionInitialisationException: java.lang.NoSuchFieldException: header at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1412) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:387) at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:266) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:139) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.(PersistenceExceptionTranslationInterceptor.java:79) at org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.(PersistenceExceptionTranslationAdvisor.java:70) at org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:99) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1431) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1400) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) ... 34 more Caused by: org.terracotta.ehcachedx.com.javabi.sizeof.ClassDefinitionInitialisationException: java.lang.NoSuchFieldException: header at org.terracotta.ehcachedx.com.javabi.sizeof.ClassDefinitionMap.(ClassDefinitionMap.java:49) at org.terracotta.ehcachedx.monitor.probe.counter.sampled.memory.MemorySamplerSupport.(MemorySamplerSupport.java:27) at org.terracotta.ehcachedx.monitor.probe.SampledCacheStatistics.(SampledCacheStatistics.java:44) at org.terracotta.ehcachedx.monitor.probe.CacheManagerService.registerCache(CacheManagerService.java:621) at org.terracotta.ehcachedx.monitor.probe.ProbePeerListener.notifyCacheAdded(ProbePeerListener.java:108) at net.sf.ehcache.event.CacheManagerEventListenerRegistry.notifyCacheAdded(CacheManagerEventListenerRegistry.java:159) at net.sf.ehcache.CacheManager.addCacheNoCheck(CacheManager.java:988) at net.sf.ehcache.CacheManager.addConfiguredCaches(CacheManager.java:608) at net.sf.ehcache.CacheManager.init(CacheManager.java:339) at net.sf.ehcache.CacheManager.(CacheManager.java:280) at net.sf.ehcache.CacheManager.create(CacheManager.java:642) at net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory.start(SingletonEhCacheRegionFactory.java:65) at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:248) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1385) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:855) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:774) at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1469) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409) ... 49 more Caused by: java.lang.NoSuchFieldException: header at java.lang.Class.getDeclaredField(Class.java:1897) at org.terracotta.ehcachedx.com.javabi.sizeof.definition.LinkedListDefinition.(LinkedListDefinition.java:36) at org.terracotta.ehcachedx.com.javabi.sizeof.ClassDefinitionMap.defineOptionalTypes(ClassDefinitionMap.java:76) at org.terracotta.ehcachedx.com.javabi.sizeof.ClassDefinitionMap.(ClassDefinitionMap.java:45) ... 67 more 1192 [Thread-7] INFO org.terracotta.ehcachedx.monitor.probe.ProbeDxService - ProbeDXService Registered with monitor at address 'localhost' and port '9889' 1194 [Thread-7] WARN org.terracotta.ehcachedx.license.LicenseResolver - No Ehcache Monitor license key found. This monitoring probe software is not licensed for production usage, and is only licensed for development usage. See LICENSE.txt for details. A temporary key will be generated for development usage. When the temporary key expires, the Ehcache monitoring probe capability will be suspended but your ability to continue to use Ehcache will not be affected. Please contact [email protected] to request a license. 1201 [Thread-7] INFO org.terracotta.ehcachedx.license.LicenseResolver - --------- Ehcache Monitor license key --------- License type = DevOnly License number = 0 Licensee = DevOnly User Product = Ehcache Monitor Capabilities = monitor Expiration date = 2010-05-26 ----------------------------------------------- 1201 [Thread-7] INFO org.terracotta.ehcachedx.monitor.probe.ProbeDxService - Null license registered

Comments

Hung Huynh 2010-05-23

Could you add some info regarding your env? version of spring, jdk (which I think is the main culprit)

Matej Banik 2010-05-23

JDK 7 64 bit runtime Spring 3.0.2 Tomcat 6.0.26

The main reason for the JDK 7 is that it runs almost on any 64 bit machine. And 64 bit is required since there is no 1GB heap limit for tomcat.

I did little research in regards to ClassDefinitionInitialisationException I found this http://code.google.com/p/javabi-sizeof/ project but there was no option submit the issue there since I think the adjustment has to be done in the sizeof package. But it seems like you guys adapted the project into your package.

I’m sure the problem would disappear with JDK 5 or 6 but that is not an option for me. I was just hopping there would be fix in the new release of the ehcache-probe.

Looks like this source at line 36 is spot on with the reported exception: http://www.google.com/codesearch/p?hl=en#9xL5JzdfbbE/trunk/javabi-sizeof/src/com/javabi/sizeof/definition/LinkedListDefinition.java&q=LinkedListDefinition%20package:http://javabi-sizeof%5C.googlecode%5C.com&sa=N&cd=1&ct=rc&l=35

It just looks like it needs little TLC and the exception will go away.

Hung Huynh 2010-05-23

yea, that’s what I suspected. The sizeOf library is very delicate and sensitive towards jdk versions since it’s using reflection.

Matej Banik 2010-05-23

I looked up the javadoc for JDK 1.7 version http://download.java.net/jdk7/docs/api/java/lang/Class.html#getDeclaredFields() It says it was the same since JDK 1.1

What I don’t understand the “header” field. What does it do?

Let me know if I can help with this. Do you know if anyone is going to fix this issue?

Hung Huynh 2010-05-23

The error is not from getDeclaredFields(). SizeOf uses reflection to access a field named “header” from LinkedList. JDK 7 changed the implementation of LinkedList hence there is no longer a field name “header” in the code. SizeOf fails trying to access it at runtime.

There’s not much you can do on your end to workaround the issue besides switching back to JDK6. The fix has to be in SizeOf library itself.

Until someone from PM or Greg to look at the bug, you’ll know when it’ll be fixed.

Matej Banik 2010-05-23

I have attached source for the LinkedList from JDK 7 src.zip file. Here is link to the current implementation of linked list: http://kickjava.com/src/java/util/LinkedList.java.htm

Looks like some “if” statements have to be made. There is definitely a lot of change between the two versions.

The major difference: 1.6: private transient Entry header = new Entry(null, null, null); private transient int size = 0;

1.7: transient int size = 0;

/**
 * Pointer to first node.
 * Invariant: (first == null && last == null) ||
 *            (first.prev == null && first.item != null)
 */ transient Node<E> first;

/**
 * Pointer to last node.
 * Invariant: (first == null && last == null) ||
 *            (last.next == null && last.item != null)
 */ transient Node<E> last;

gluck 2010-05-23

the memory use is valuable where it works.

Suggest we make the memory use a config option in the probe, which is on by default but can easily be turned off. Also that we update the docs to advise of this as a known issue.

gluck 2010-05-27

Made memoryMeasurement a configurable property, still defaulted to true.

Himadri Singh 2010-06-02

Verified w/ java version “1.7.0-ea” Java(TM) SE Runtime Environment (build 1.7.0-ea-b95) Java HotSpot(TM) Server VM (build 19.0-b01, mixed mode)

It works with 1.7.0 w/o exceptions and shows 0 instead for memoryMeasurement even with memoryMeasurement=true.

Works as expected for 1.6.0_15, with values shown under memoryMeasurement Chart.