Another unnamed CacheManager already exists in the same VM.

nested exception is net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following:
1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary
2. Shutdown the earlier cacheManager before creating new one with same name.
The source of the existing CacheManager is: DefaultConfigurationSource [ ehcache.xml or ehcache-failsafe.xml ]
at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:389)
at org.springframework.web.context.ContextLoader.loadParentContext(ContextLoader.java:358)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:193)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:649)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1581)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
<bean id=sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" lazy-init="true">
<property name="dataSource"><ref bean="dataSource" /></property>
<property name="mappingLocations">
<list><value>classpath*:com/xxx/*.hbm.xml</value></list>
</property>
<property name="hibernateProperties">
<value>
hibernate.bytecode.use_reflection_optimizer={hibernate.bytecode.use_reflection_optimizer}
hibernate.dialect=${hibernate.dialect}
hibernate.jdbc.fetch_size=${hibernate.jdbc.fetch_size}
hibernate.jdbc.batch_size=${hibernate.jdbc.batch_size}
hibernate.hbm2ddl.auto=${hibernate.hbm2ddl.auto}
hibernate.show_sql=${hibernate.show_sql}
hibernate.format_sql=${hibernate.format_sql}
hibernate.query.factory_class=${hibernate.query.factory_class}
hibernate.default_batch_fetch_size=${hibernate.default_batch_fetch_size}
hibernate.transaction.factory_class=${hibernate.transaction.factory_class}
hibernate.transaction.auto_close_session=${hibernate.transaction.auto_close_session}
hibernate.cache.use_query_cache=${hibernate.cache.use_query_cache}
hibernate.cache.use_second_level_cache=${hibernate.cache.use_second_level_cache}
hibernate.cache.region.factory_class=net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory
net.sf.ehcache.configurationResourceName=/com/xxx/ehcache.xml
</value>
</property>
</bean>

用个项目中多个sessionfactory使用hibernate的ehcache或者hibernate和业务共同使用ehcache使用SingletonEhCacheRegionFactory。

原创文章,转载请注明: 转载自海波无痕

本文链接地址: Another unnamed CacheManager already exists in the same VM.

文章的脚注信息由WordPress的wp-posturl插件自动生成

此条目发表在javaee, server, spring分类目录,贴了, , , 标签。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已用*标注

评论链接可以 移除 nofollow.