EHC ❯ ClassDefinitionInitialisationException: java.lang.NoSuchFieldException: header
-
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.
Comments
Hung Huynh 2010-05-23
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
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.
Could you add some info regarding your env? version of spring, jdk (which I think is the main culprit)