org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'displayNameCache' defined in ServletContext resource [/WEB-INF/spring/root-context.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: LRU isn't a valid eviction policy

SpringSource Issue Tracker | Mike Youngstrom | 6 years ago
  1. 0

    I attempted to create a simple test case for this issue that I found when using ehCache. However, I was unable to find a simpler duplication. So I've just provided a test case that actually uses ehcache. The issue here is that I am using the org.springframework.cache.ehcache.EhCacheFactoryBean in spring config and attempting to set the memoryStoreEvictionPolicy property. MemoryStoreEvictionPolicy does not overide the equals method so if you are able to create a new instance of MemoryStoreEvictionPolicy with the string "LRU" .equals() tests will fail. Spring will normally find some magical way to convert my "LRU" string into a factory provided instance of MemoryStoreEvictionPolicy. One of the steps in Spring's conversion process is it will ask the property type for a constructor that takes a String.class (TypeConverterDelegate.convertIfNecessary:191). MemoryStoreEvictionPolicy has a private constructor that takes String.class. Spring fails to find this constructor normally and moves on to eventually convert the String correctly. When running under spring loaded however TypeConverterDelegate.convertIfNecessary:191 actually finds the private constructor and uses that constructor to create a new instance of MemoryStoreEvictionPolicy which ends up later failing a .equals() comparison. Throwing the exception below. I've provided a testcase that will duplicate the issue. Start it up with spring loaded enabled and it will fail. Start it up without Spring loaded enabled and it will work. ERROR: org.springframework.web.context.ContextLoader - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'displayNameCache' defined in ServletContext resource [/WEB-INF/spring/root-context.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: LRU isn't a valid eviction policy at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420) 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:190) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) 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:4205) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4704) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:623) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675) at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1320) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061) at org.apache.catalina.core.StandardHost.start(StandardHost.java:862) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) 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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Caused by: java.lang.IllegalArgumentException: LRU isn't a valid eviction policy at net.sf.ehcache.store.compound.impl.OverflowToDiskStore.determineEvictionPolicy(OverflowToDiskStore.java:85) at net.sf.ehcache.store.compound.impl.OverflowToDiskStore.create(OverflowToDiskStore.java:64) at net.sf.ehcache.Cache.initialise(Cache.java:1104) at net.sf.ehcache.CacheManager.addCacheNoCheck(CacheManager.java:1057) at net.sf.ehcache.CacheManager.addCache(CacheManager.java:980) at org.springframework.cache.ehcache.EhCacheFactoryBean.afterPropertiesSet(EhCacheFactoryBean.java:302) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417) ... 36 more

    SpringSource Issue Tracker | 6 years ago | Mike Youngstrom
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'displayNameCache' defined in ServletContext resource [/WEB-INF/spring/root-context.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: LRU isn't a valid eviction policy
  2. 0

    I attempted to create a simple test case for this issue that I found when using ehCache. However, I was unable to find a simpler duplication. So I've just provided a test case that actually uses ehcache. The issue here is that I am using the org.springframework.cache.ehcache.EhCacheFactoryBean in spring config and attempting to set the memoryStoreEvictionPolicy property. MemoryStoreEvictionPolicy does not overide the equals method so if you are able to create a new instance of MemoryStoreEvictionPolicy with the string "LRU" .equals() tests will fail. Spring will normally find some magical way to convert my "LRU" string into a factory provided instance of MemoryStoreEvictionPolicy. One of the steps in Spring's conversion process is it will ask the property type for a constructor that takes a String.class (TypeConverterDelegate.convertIfNecessary:191). MemoryStoreEvictionPolicy has a private constructor that takes String.class. Spring fails to find this constructor normally and moves on to eventually convert the String correctly. When running under spring loaded however TypeConverterDelegate.convertIfNecessary:191 actually finds the private constructor and uses that constructor to create a new instance of MemoryStoreEvictionPolicy which ends up later failing a .equals() comparison. Throwing the exception below. I've provided a testcase that will duplicate the issue. Start it up with spring loaded enabled and it will fail. Start it up without Spring loaded enabled and it will work. ERROR: org.springframework.web.context.ContextLoader - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'displayNameCache' defined in ServletContext resource [/WEB-INF/spring/root-context.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: LRU isn't a valid eviction policy at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420) 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:190) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) 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:4205) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4704) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:623) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675) at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1320) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061) at org.apache.catalina.core.StandardHost.start(StandardHost.java:862) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) 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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Caused by: java.lang.IllegalArgumentException: LRU isn't a valid eviction policy at net.sf.ehcache.store.compound.impl.OverflowToDiskStore.determineEvictionPolicy(OverflowToDiskStore.java:85) at net.sf.ehcache.store.compound.impl.OverflowToDiskStore.create(OverflowToDiskStore.java:64) at net.sf.ehcache.Cache.initialise(Cache.java:1104) at net.sf.ehcache.CacheManager.addCacheNoCheck(CacheManager.java:1057) at net.sf.ehcache.CacheManager.addCache(CacheManager.java:980) at org.springframework.cache.ehcache.EhCacheFactoryBean.afterPropertiesSet(EhCacheFactoryBean.java:302) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417) ... 36 more

    SpringSource Issue Tracker | 6 years ago | Mike Youngstrom
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'displayNameCache' defined in ServletContext resource [/WEB-INF/spring/root-context.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: LRU isn't a valid eviction policy
  3. 0

    Frontend throws exception when started without SSO configured

    GitHub | 2 years ago | cmader
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestSingleLogoutFilter' defined in ServletContext resource [/WEB-INF/classes/cas-context-security.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.security.web.authentication.logout.LogoutFilter]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: ${cas.logout.url} isn't a valid redirect URL
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Problem installing the 2.0.1 Packages

    GitHub | 2 years ago | paulmassey42
    java.lang.IllegalArgumentException: ${cas.logout.url} isn't a valid redir ect URL
  6. 0

    Frontend throws exception when started without SSO configured

    GitHub | 2 years ago | cmader
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestSingleLogoutFilter' defined in ServletContext resource [/WEB-INF/classes/cas-context-security.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.security.web.authentication.logout.LogoutFilter]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: ${cas.logout.url} isn't a valid redirect URL

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalArgumentException

      LRU isn't a valid eviction policy

      at net.sf.ehcache.store.compound.impl.OverflowToDiskStore.determineEvictionPolicy()
    2. ApacheDS All
      OverflowToDiskStore.create
      1. net.sf.ehcache.store.compound.impl.OverflowToDiskStore.determineEvictionPolicy(OverflowToDiskStore.java:85)
      2. net.sf.ehcache.store.compound.impl.OverflowToDiskStore.create(OverflowToDiskStore.java:64)
      2 frames
    3. Ehcache
      CacheManager.addCache
      1. net.sf.ehcache.Cache.initialise(Cache.java:1104)
      2. net.sf.ehcache.CacheManager.addCacheNoCheck(CacheManager.java:1057)
      3. net.sf.ehcache.CacheManager.addCache(CacheManager.java:980)
      3 frames
    4. Spring Context Support
      EhCacheFactoryBean.afterPropertiesSet
      1. org.springframework.cache.ehcache.EhCacheFactoryBean.afterPropertiesSet(EhCacheFactoryBean.java:302)
      1 frame
    5. Spring Beans
      DefaultListableBeanFactory.preInstantiateSingletons
      1. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
      2. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
      3. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
      4. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      5. org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
      6. org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
      7. org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
      8. org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
      9. org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
      9 frames
    6. Spring Context
      AbstractApplicationContext.refresh
      1. org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
      2. org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
      2 frames
    7. Spring
      ContextLoaderListener.contextInitialized
      1. org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
      2. org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
      3. org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
      3 frames
    8. Glassfish Core
      Catalina.start
      1. org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4205)
      2. org.apache.catalina.core.StandardContext.start(StandardContext.java:4704)
      3. org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
      4. org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
      5. org.apache.catalina.core.StandardHost.addChild(StandardHost.java:623)
      6. org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675)
      7. org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601)
      8. org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
      9. org.apache.catalina.startup.HostConfig.start(HostConfig.java:1320)
      10. org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
      11. org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
      12. org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061)
      13. org.apache.catalina.core.StandardHost.start(StandardHost.java:862)
      14. org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
      15. org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
      16. org.apache.catalina.core.StandardService.start(StandardService.java:525)
      17. org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
      18. org.apache.catalina.startup.Catalina.start(Catalina.java:595)
      18 frames
    9. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:597)
      4 frames
    10. Glassfish Core
      Bootstrap.main
      1. org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
      2. org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
      2 frames