Results 1 to 3 of 3

Thread: Spring Batch Unit test error

  1. #1
    Join Date
    Jan 2012
    Posts
    21

    Default Spring Batch Unit test error

    Hi All

    Unit test of my Spring Batch based application are failing due to following error. Can anyone please help me out

    Code:
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cacheInterceptor' defined in URL [jar:file:/C:/Users/rafiquea/.m2/repository/org/springframework/batch/spring-batch-admin-manager/1.2.1.RELEASE/spring-batch-admin-manager-1.2.1.RELEASE.jar!/META-INF/spring/batch/bootstrap/manager/jmx-context.xml]: Invocation of init method failed; nested exception is net.sf.ehcache.ObjectExistsException: Cache simple already exists
        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.aop.framework.ProxyFactoryBean.initializeAdvisorChain(ProxyFactoryBean.java:454)
        at org.springframework.aop.framework.ProxyFactoryBean.getObject(ProxyFactoryBean.java:240)
        at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
        ... 58 more
    Caused by: net.sf.ehcache.ObjectExistsException: Cache simple already exists
        at net.sf.ehcache.CacheManager.addCacheNoCheck(CacheManager.java:993)
        at net.sf.ehcache.CacheManager.addCache(CacheManager.java:938)
        at net.sf.ehcache.CacheManager.addCache(CacheManager.java:916)
        at org.springframework.batch.admin.util.SimpleEhCacheInterceptor.afterPropertiesSet(SimpleEhCacheInterceptor.java:77)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
        ... 67 more
    I am running my unit test though maven.

  2. #2

    Default

    Hi,

    I think it means that something else already registered that cache, probably some other dependency in your project.
    Make sure to view the dependency tree and exclude duplications. You can use Maven Enforcer plugin, will help a lot in this case.


    Sincerely,
    David Gevorkyan

  3. #3
    Join Date
    Jan 2012
    Posts
    21

    Default

    I get the same error even if I run the unit test through eclipse. I have 8 test cases for 8 different jobs. When I run them in one go, 5 of them are successfull and rest of them fail. If I run failed test individually, they succeed.


    since the problem occurs on creating cacheInterceptor
    Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'cacheInterceptor' defined in URL [jar:file:/C:/Users/rafiquea/.m2/repository/org/springframework/batch/spring-batch-admin-manager/1.2.1.RELEASE/spring-batch-admin-manager-1.2.1.RELEASE.jar!/META-INF/spring/batch/bootstrap/manager/jmx-context.xml]: Invocation of init method failed; nested exception is net.sf.ehcache.ObjectExistsException: Cache simple already exists
    I overrided the beans defined in spring-batch-admin-manager-1.2.1.RELEASE.jar!/META-INF/spring/batch/bootstrap/manager/jmx-context.xml using following.
    Code:
    	<bean id="batchMBeanExporter" class="java.lang.String"/>
    	<bean id="mbeanExporter" class="java.lang.String"/>
    	<bean id="cacheInterceptor" class="java.lang.String"/>
    It seems that it has solved the problem but I am still not sure why the problem is occurring and how did above solved it.
    Any help is greatly appreciated.
    Thanks
    Last edited by amique; Jun 18th, 2012 at 10:57 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •