WARN net.sf.ehcache.CacheManager - Creating a new instance of CacheManager using the diskStorePath

1,780 views
Skip to first unread message

Thomas Winkler

unread,
Jul 22, 2010, 7:46:58 AM7/22/10
to Ehcache Spring Annotations
Hi,

I have the Problem that ehcache writes this warning in my log: WARN
net.sf.ehcache.CacheManager - Creating a new instance of CacheManager
using the diskStorePath...

On the ehcache website there is described that this is warning is
logged, when several instances of a CachManager are created.

But I have no idea why this happens. Is this normal?

Can you maybe give me a hint?

br

Thomas

Nicholas Blair

unread,
Jul 22, 2010, 9:25:23 AM7/22/10
to ehcache-sprin...@googlegroups.com, Thomas Winkler
Please provide:

- the complete log message
- your Spring configuration

Thomas Winkler

unread,
Jul 22, 2010, 9:36:12 AM7/22/10
to Ehcache Spring Annotations
For sure,

Here is my Spring config:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:ehcache="http://ehcache-spring-annotations.googlecode.com/
svn/schema/ehcache-spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring
http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.1.xsd">

<ehcache:annotation-driven cache-manager="ehCacheManager" />


<bean id="ehCacheManager"
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"/>



<!-- these two configs are necessary for the autowired/component
annotation stuff.
Setting the base-backage is necessary - otherwise it won't work. Be
warned:
if setting it to an unrestrictive value like "com", the scanning can
get very time consuming
-->
<!-- context:annotation-config/-->

<bean

class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>classpath:configuration.properties</value>
</property>
</bean>

<!-- ============================== DATASOURCE
============================== -->
<!-- org.apache.commons.dbcp.BasicDataSource -->
<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-
method="close">
<property name="driverClass" value="oracle.jdbc.OracleDriver" />
<property name="jdbcUrl" value="${db.url}" />
<property name="user" value="${db.username}" />
<property name="password" value="${db.password}" />
<property name="minPoolSize" value="5" />
<property name="maxPoolSize" value="50" />
<property name="initialPoolSize" value="5" />
<property name="maxIdleTime" value="1800" />
<property name="maxConnectionAge" value="43200" />
<property name="idleConnectionTestPeriod" value="1800" />
<property name="preferredTestQuery" value="SELECT 1 FROM DUAL" />
<property name="autoCommitOnClose" value="false" />
</bean>

<!-- ========== TRANSACTION MANAGER ========== -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
<property name="nestedTransactionAllowed" value="true" />
</bean>

<!-- importing other spring files-->
<import resource="classpath:capacityplanning-spring-daos.xml" />
<import resource="classpath:capacityplanning-spring-services.xml" />

</beans>

Here is the complete log message:
....
2010-07-22 15:33:52,305 [main] WARN net.sf.ehcache.CacheManager -
Creating a new instance of CacheManager using the diskStorePath "C:
\Users\thwinkle\wokspace_helios\CapacityPlanningAPI" which is already
used by an existing CacheManager.
The source of the configuration was
net.sf.ehcache.config.generator.ConfigurationSource
$DefaultConfigurationSource@b9b8d0.
The diskStore path for this CacheManager will be set to C:\Users
\thwinkle\wokspace_helios\CapacityPlanningAPI
\ehcache_auto_created_1279805632305.
To avoid this warning consider using the CacheManager factory methods
to create a singleton CacheManager or specifying a separate ehcache
configuration (ehcache.xml) for each CacheManager instance.
.....

Here is my ehcache.xml:

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="false">

<diskStore path="user.dir"/>

<defaultCache
maxElementsInMemory="5000"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="120"

diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
/>

<cache name="com.sonydadc.capacityplanning.api.slaIdcache"
maxElementsInMemory="5000"
eternal="false"
timeToLiveSeconds="300"
overflowToDisk="false">
</cache>

<cache name="com.sonydadc.capacityplanning.api.leadTimecache"
maxElementsInMemory="5000"
eternal="false"
timeToLiveSeconds="300"
overflowToDisk="false">
</cache>

<cache name="com.sonydadc.capacityplanning.api.minTatcache"
maxElementsInMemory="5000"
eternal="false"
timeToLiveSeconds="300"
overflowToDisk="false">
</cache>

<cache name="com.sonydadc.capacityplanning.api.timezonecache"
maxElementsInMemory="5000"
eternal="false"
timeToLiveSeconds="300"
overflowToDisk="false">
</cache>


</ehcache>

Thanks in advance...

Nicholas Blair

unread,
Jul 22, 2010, 9:40:30 AM7/22/10
to ehcache-sprin...@googlegroups.com
What else is constructing an instance of net.sf.ehcache.CacheManager in
your project?

Do you have another CacheManager bean in either
"capacityplanning-spring-daos.xml" or capacityplanning-spring-services.xml"?

Or do you have a class somewhere in your project that is calling
CacheManager's constructors and using the same ehcache.xml?

Thomas Winkler

unread,
Jul 22, 2010, 9:51:39 AM7/22/10
to Ehcache Spring Annotations
in capacityplanning-spring-daos.xml" or capacityplanning-spring-
services.xml I don't have a CacheManager bean. I checked it.
Thats thats the way is use the annotations:

@Cacheable(cacheName =
"com.sonydadc.capacityplanning.api.minTatcache")
@Override
public int getMinTatHours(final String businessUnit, final String
deal){
....



return mintathours;
}
I have not class in my Project that should call the CacheManager
constructor.

Is it possible that for every cache a new CacheManager is created and
this is a bug?

br,

tom

On 22 Jul., 15:40, Nicholas Blair <nbl...@doit.wisc.edu> wrote:
> What else is constructing an instance of net.sf.ehcache.CacheManager in
> your project?
>
> Do you have another CacheManager bean in either
> "capacityplanning-spring-daos.xml" or capacityplanning-spring-services.xml"?
>
> Or do you have a class somewhere in your project that is calling
> CacheManager's constructors and using the same ehcache.xml?
>
> On 07/22/2010 08:36 AM, Thomas Winkler wrote:
>
> > For sure,
>
> > Here is my Spring config:
>
> > <?xml version="1.0" encoding="UTF-8"?>
> > <beans xmlns="http://www.springframework.org/schema/beans"
> >      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >      xmlns:context="http://www.springframework.org/schema/context"
> >      xmlns:tx="http://www.springframework.org/schema/tx"
> >      xmlns:ehcache="http://ehcache-spring-annotations.googlecode.com/
> > svn/schema/ehcache-spring"
> >      xsi:schemaLocation="http://www.springframework.org/schema/beans
> >          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
> >          http://www.springframework.org/schema/context
> >          http://www.springframework.org/schema/context/spring-context-3.0.xsd
> >          http://www.springframework.org/schema/tx
> >          http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
> >          http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-s...
> >          http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-s...">

Nicholas Blair

unread,
Jul 22, 2010, 9:58:05 AM7/22/10
to ehcache-sprin...@googlegroups.com
Nothing in ehcache-spring-annotations constructs a CacheManager
instance; we depend on deployers to define one and inject it (via the
cache-manager attribute on <context:annotation-config/>).

Without seeing your entire project, I really can't say why you would see
this error. There may be some dependency you have that is constructing a
CacheManager.

You may have to search a little deeper through your project's
dependencies, or contact the ehcache list for further help.

Thomas Winkler

unread,
Jul 23, 2010, 7:35:06 AM7/23/10
to Ehcache Spring Annotations
Hi,

I solved my problem, I had a problem in my unit tests, which recreated
the Spring Context more than once.

Thanks for your help.

br
Reply all
Reply to author
Forward
Message has been deleted
0 new messages