• Bug
  • Status: Open
  • 2 Major
  • Resolution:
  • ehcache-core
  • Reporter: kevinrs
  • July 18, 2011
  • 0
  • Watchers: 2
  • May 28, 2013

Description

I am attempting to upgraded from EhCache 1.5.0 to EhCache 2.4.3. I am receiving a NullPointerException from the CacheManager.configure() method which has an obvious bug in the code base. The call to cacheManagerPeerListeners.putAll(configurationHelper.createCachePeerListeners()); on line 589 is causing the NullPointerException since ConfigurationHelper.createCachePeerListeners() can return null in the case that the className of the factory configuration is null. I removed company name references due to IT Policies with companyxyz.

Here is the stack trace I am seeing on start-up.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘companyxyzCacheManager’ defined in class path resource [com/companyxyz/data/spring-config-data-common.xml]: Cannot create inner bean ‘net.sf.ehcache.CacheManager#102ead5’ of type [net.sf.ehcache.CacheManager] while setting bean property ‘ehCacheManager’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘net.sf.ehcache.CacheManager#102ead5’ defined in class path resource [com/companyxyz/data/spring-config-data-common.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public static net.sf.ehcache.CacheManager net.sf.ehcache.CacheManager.create(java.net.URL) throws net.sf.ehcache.CacheException] threw exception; nested exception is java.lang.NullPointerException at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:230) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:117) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380) at com.companyxyz.util.WebApplicationContextManager.initWebApplicationContext(WebApplicationContextManager.java:68) at com.companyxyz.web.servlet.filter.RootFilter.doFilter(RootFilter.java:135) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:619) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘net.sf.ehcache.CacheManager#102ead5’ defined in class path resource [com/companyxyz/data/spring-config-data-common.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public static net.sf.ehcache.CacheManager net.sf.ehcache.CacheManager.create(java.net.URL) throws net.sf.ehcache.CacheException] threw exception; nested exception is java.lang.NullPointerException at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:444) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:903) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:817) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:219) … 29 more Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public static net.sf.ehcache.CacheManager net.sf.ehcache.CacheManager.create(java.net.URL) throws net.sf.ehcache.CacheException] threw exception; nested exception is java.lang.NullPointerException at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:127) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:435) … 36 more Caused by: java.lang.NullPointerException at java.util.concurrent.ConcurrentHashMap.putAll(ConcurrentHashMap.java:908) at net.sf.ehcache.CacheManager.configure(CacheManager.java:589) at net.sf.ehcache.CacheManager.init(CacheManager.java:358) at net.sf.ehcache.CacheManager.(CacheManager.java:272) at net.sf.ehcache.CacheManager.create(CacheManager.java:770) 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.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:115) ... 37 more

Here is the Spring Configuration code I am using. classpath:com/companyxyz/cache/impl/ehcache.xml

Here is the EhCache Configuration file that I am using.

I have attached my EhCache Configuration to this bug report for reference.

Comments

Kevin Schmidt 2011-07-19

All,

I was able to work around the problem by using a different ehCache configuration. The following configuration file avoids the null pointer exception by removing the XML elements completely.

Fiona OShea 2011-12-08

Is there still an issue to be looked at here?