FAQ Database Discussion Community


Is there a way to make Ehcache file based configuration override programmatic configuration?

java,ehcache
I have an application using Ehcache 2.6. This application uses programmatic configuration of its Ehcache instances and this programmatic configuration can only be changed through code changes. I would like to be able to tune this application using a file-based configuration. Can I introduce an ehcache.xml configuration file to the...

Cache is empty after setting up and using ehcache in Spring

java,spring,annotations,ehcache,spring-annotations
My code is below, when I get to the end and try to print out something from the cache, the key list is empty. @Configuration @EnableCaching public class EhcacheConfiguration implements CachingConfigurer { CacheConfiguration cacheConfiguration = new CacheConfiguration(); cacheConfiguration.setName("DataCache"); cacheConfiguration.setMemoryStoreEvictionPolicy("LRU"); cacheConfiguration.setMaxEntiresLocalHeap(1000); cacheConfiguration.setEternal(false); net.sf.ehcache.config.Configuration config = new net.sf.ehcache.config.Configuration();...

Hibernate Too Many Connections With Cache

java,hibernate,caching,connection-pooling,ehcache
I'm using hibernate to try and retrieve a cached query. @Transactional public interface ProductDAO extends JpaRepository<Product, Long> { @QueryHints({ @QueryHint(name = "org.hibernate.cacheable", value = "true") }) Product findByCode(String code); } I'm load testing and I'm doing this in a large loop of 1000 iterations. for (int i = 0; i...

Spring Cache: enable/disable caching

xml,spring,caching,ehcache
I'm developing a REST API with Spring. I'm caching data with EHCache (with Spring Cache). My caches are configured in ehcache.xml file and the CacheManager is configured in applicationContext.xml file. Moreover, I use @Cacheable to denote which data must be cached. It works properly, but now I want to enable/disable...

kill ehcache warn messages

java,hibernate,logging,configuration,ehcache
I have this ehcache configuration xml: <ehcache> <defaultCache maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="false" diskSpoolBufferSizeMB="30" diskPersistent="false" diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU" /> </ehcache> And also, I have some packages with entities (around 150). If I deploy my application on tomcat server, there is a lot WARN messages in log: 2015-04-29 11:59:02,712 [RMI TCP Connection(3)-127.0.0.1]...

Does ehcache reserve (allocate) heap memory set with maxBytesLocalHeap?

memory-management,jvm,ehcache
I use ehache 2.8. I am not sure I understand the documentation correctly regarding reservation of the memory for the cache. Is the memory set in ehcache.xml like this: <ehcache maxBytesLocalHeap="256M"> (...) </ehcache> ..actually being allocated at start and this cache will use exactly 256MB of heap or does this...

unable to start terracota

centos,ehcache,digital-ocean,terracotta
I'm having issue when starting terracota, I did grep on 37.139.24.150 ip in whole system but couldn't find any file containing this IP, any other places to look for? Also i couldn't find tc-config.xml in terracota its actually an old system I'm just starting terracota its not installed/configured by me....

Second level cache in Hibernate 3.2.0 final

java,hibernate,ehcache,noclassdeffounderror,second-level-cache
I have been facing problem in using second level cache. following are the required source you need to find out what the problem is. hibernate.cfg.xml <?xml version="1.0" encoding="UTF-8"?> <!-- a SessionFactory instance --> <session-factory> <!-- User / Password --> <property name="connection.username">root</property> <property name="connection.password"></property> <!-- Database / Dialect Settings --> <property...

ehCache Statistics with spring boot

statistics,spring-boot,ehcache
I have spring boot application with ehcache as below @Bean public EhCacheManagerFactoryBean ehCacheManagerFactoryBean() { EhCacheManagerFactoryBean ehCacheManagerFactoryBean = new EhCacheManagerFactoryBean(); ehCacheManagerFactoryBean.setConfigLocation(new ClassPathResource("ehcache.xml")); //ehCacheManagerFactoryBean.setCacheManagerName("messageCache"); ehCacheManagerFactoryBean.setShared(true); return ehCacheManagerFactoryBean; } @Bean public EhCacheCacheManager cacheManager() { return new...

EHCache and DropWizard: Returning no response

jersey,ehcache,dropwizard
I have successfully integrated SimplePageCachingFilter with DropWizard. However, there is one thing standing in my way. Whenever an exception in my application is thrown, instead of being routed to my ExceptionMapper I get "Response contains no data" in my API Browser. I also happen to see this pass by in...

Java - Shiro - ehcache config

java,spring,ehcache,shiro
I am using Shiro(v1.2.3) in a java web project using Spring (v4.1.4). I enabled Ehcache for shiro, to help store shiro session. My question is: Do I need to define a <cache> entity for shiro session in ehcache.xml config file, or shiro will manage that automatically? In one word, do...

ehcache - restrict access

java,caching,ehcache
I use ehcache (not replicated or distributed) in my application and as I know it can be accessed only from the same JVM but all the applications in the same JVM (e.g. deployed in a app server) can get values from the cache. Am I right? What I want is...

Disable ehcache at runtime with jmx

java,spring,ehcache
I'm trying to disable a distributed ehcache at runtime. This is needed to facilitate rolling deploys to our several servers so new version of code wouldn't interfere with servers awaiting update to the newer code. I came up with the following class @Component @ManagedResource(objectName = "net.sf.ehcache:category=CustomCacheManager,name=cache-ms", description = "Custom managing...

Some cached elements are not deleted after cache evictAll()

java,spring,hibernate,jpa,ehcache
This is a Spring + JPA + Hibernate + EhCache application. I am facing some issues with cache (or I am assuming that is due to cache configuration). I am trying to cache some objects (it works fine, I can see in the cache statistics). The problem is that I...

Best practices configuring ehCache in modular java application

java,spring,hibernate,configuration,ehcache
We would like to use ehcache in the following two scenarios: Hibernate second level cache Spring method cache Since we have a persistence.xml file in each module but only need one persistence unit, we are using org.springframework.data.jpa.support.MergingPersistenceUnitManager. Now we would like to have a similar setup for ehcache: each module...

Cache inconsistency - Entity not always persisted in cached Collection

java,hibernate,jpa,caching,ehcache
I'm having an issue where a Validation instance is added to a Collection on a Step instance. Declaration is as follows: Step class: @Entity @Table @Cacheable @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class Step extends AbstractEntity implements ValidatableStep { @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) @JoinColumn(name = "step_id", nullable...

Difference between @CacheEvict and @TriggersRemove annotations

caching,annotations,ehcache,spring-annotations,spring-cache
I want to use Ehcache in my portlet application. If I want to remove data from cache, it is better to use @CacheEvict or @TriggersRemove? According to documentation it looks like @CacheEvict and @TriggersRemove annotations are very similar....

Issue with Hibernate EHCache program

java,hibernate,ehcache
I am learning how to configure Hibernate with EHCache but facing some issues with it. I have below details in my `hibernate.cfg.xml file: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property...

Element does not allow attribute “maxBytesLocalDisk”

spring,tomcat,caching,liferay,ehcache
I want to use data caching with ehcache in my liferay portlet. I use Liferay 6.2 community edition bundled with Tomcat 7.0.42. dependecies in pom.xml <properties> <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <spring.version>4.1.0.RELEASE</spring.version> <spring.data.version>1.7.1.RELEASE</spring.data.version> <log4j.version>1.2.17</log4j.version>...

Ehcache cache .data files have escaped unicode characters

windows,ehcache,datastore
My caches' data filenames seem to contain escaped unicode characters in the data store. Strangely only capital letters in the cache names are replaced. Eg: %004c%004f%0043%0041%004c%004dodifier%004cinking%004danager.data Should be: LOCALModifierLinkingManager.data Why is this the case? How can I fix it? Environment: Windows 7 x64...

Is GAE Supports EHCache's Write-Behind Operation?

google-app-engine,ehcache
I am trying to create a web application that uses ehcache to store and retrieve data. For me, the following configuration is working fine for me. <?xml version="1.0" encoding="UTF-8"?> <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd" > <cacheManagerEventListenerFactory class="" properties=""/> <defaultCache maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" memoryStoreEvictionPolicy="LRU"> <!-- <persistence...

migration from play framework 2.0.8 to 2.1.0 ERROR: cache play already exists

java,playframework,playframework-2.0,ehcache,playframework-2.1
I have migrated from play framework 2.0.8 to 2.1.0 and every thing seems perfect but i am getting following error: play.api.UnexpectedException: Unexpected exception[ObjectExistsException: Cache play already exists] at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$1.apply(ApplicationProvider.scala:142) ~[play_2.10.jar:2.1.0] at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$1.apply(ApplicationProvider.scala:106) ~[play_2.10.jar:2.1.0] at scala.Option.map(Option.scala:145) ~[scala-library.jar:na] at...

NoClassDefFoundError with new EHCache config

java,caching,ehcache,noclassdeffounderror
I have a Java class that has a static implementation that fetches cache configuration and instantiate it like below: import net.sf.ehcache.Cache; import net.sf.ehcache.CacheManager; import net.sf.ehcache.Element; import org.apache.log4j.Logger; import java.net.URL; public final class MyCacheImplementation { private MyCacheImplementation() { super(); } private static Cache myCache; private static final String EHCACHFILENAME = "..........

Hibernate object not getting cached

java,hibernate,ehcache
In our application we have configured Hibernate to work with EHcache. Aim is that once object is loaded in Cache, no db call should every be invoked unless object is changed. In order to test this, i am making call to object and printing identityhashcode [using call System.identityHashCode(this)] of object....

Class bean in application context for Cacheable annotation

java,spring,caching,ehcache
I'm using Spring 4.1.4 and Ehcache 2.9 and caching using the @Cacheable annotation. I've noticed that every public class that has a method with this annotation must be referenced in applicationContext.xml as follows <bean class="com.example.web.Test"/> this forces me to add every public class that i want to cache into the...

Liferay 6.2 clustering issue with multicast

lucene,cluster-computing,liferay-6,ehcache,jgroups
I am trying to cluster ehcache and lucene with Liferay 6.2 EE sp2 bundle on 2 servers with mutlicast enabled. WE have Apache HTTPD servers fronting tomcat servers using reverse proxy. A valid 6.2 license is deployed on both the nodes. We user the following properties in the portal-ext.properties: cluster.link.enabled=true...

Use @CacheResult when the method has no argument

java,caching,ehcache,spring-cache,jcache
I have a method that returns the (rarely-changed) configuration of a system and want to cache it. The configuration is built from different pieces of data so I don't want to cache the individual pieces, but the SystemConfiguration object itself. There is no argument to the method, how can I...

Injecting PlatformTransactionManager into Ehcache

java,spring,ehcache
I am trying to inject Spring's PlatformTransactionManager into Ehcache, based on the documentation here. My existing transaction manager is defined as follows: @Bean public PlatformTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) { JpaTransactionManager jpaTransactionManager = new JpaTransactionManager(); jpaTransactionManager.setEntityManagerFactory(entityManagerFactory); return jpaTransactionManager; } The documentation states that you need to write your own class that implements...

Ehcache Distributed Multiple channel

java,spring,caching,ehcache
I am using ehcache in ditributed mode . The caches are synchronized by channel . <cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProviderFactory" properties="channelName=CHANNEL1:connect=UDP(mcast_port=45568)" propertySeparator=":" /> For a new requirement , i need to synch with two channels : CHANNEL1 and CHANNEL2 . Is this possible ? if yes , how i can do that ?...