I have tried many different setting and none work. When I name the xml file ehcache.xml it works fine no matter what I specify as a resource name. I have looked at the ehcache configuration code online and it seems to always pick this option (below)and does not find the file.
Any help would be appreciated.
Code:
117     /***
118      * Configures a bean from an XML file in the classpath.
119      */
120     public static Configuration parseConfiguration() throws CacheException {
121         ClassLoader standardClassloader = ClassLoaderUtil.getStandardClassLoader();
122         URL url = null;
123         if (standardClassloader != null) {
124             url = standardClassloader.getResource(DEFAULT_CLASSPATH_CONFIGURATION_FILE);
125         }
126         if (url == null) {
127             url = ConfigurationFactory.class.getResource(DEFAULT_CLASSPATH_CONFIGURATION_FILE);
128         }
129         if (url != null) {
130             LOG.debug("Configuring ehcache from ehcache.xml found in the classpath: " + url);
131         } else {
132             url = ConfigurationFactory.class.getResource(FAILSAFE_CLASSPATH_CONFIGURATION_FILE);
133 
134             LOG.warn("No configuration found. Configuring ehcache from ehcache-failsafe.xml "
135                     + " found in the classpath: {}", url);
136 
137         }
138         Configuration configuration = parseConfiguration(url);
139         configuration.setSource(ConfigurationSource.getConfigurationSource());
140         return configuration;
141     }
codes.hibernate.cfg
Code:
<property name="hibernate.cache.provider_class">net.sf.ehcache.hibernate.SingletonEhCacheProvider</property>           
<property name="net.sf.ehcache.configurationResourceName">/ehcachx.xml</property> 
or to hibernate.properties
Code:
hibernate.cache.region.factory_class=net.sf.ehcache.hibernate.EhCacheRegionFactory
net.sf.ehcache.configurationResourceName="ehcachx.xml"
hibernate.cache.use_second_level_cache=true
hibernate.cache.use_query_cache=true  
hibernate.generate_statistics=true
The log file
Code:
2010-11-08 09:44:18,720 [ main] DEBUG service.ECacheWrapperTest - testCacheWrapper
2010-11-08 09:44:18,752 [ main] DEBUG ehcache.CacheManager - Configuring ehcache from classpath.
2010-11-08 09:44:18,752 [ main] WARN  config.ConfigurationFactory - No configuration found. Configuring ehcache from ehcache-failsafe.xml  found in the classpath: jar:file:/C:/Documents%20and%20Settings/dg03118/.m2/repository/net/sf/ehcache/ehcache-core/2.3.0/ehcache-core-2.3.0.jar!/ehcache-failsafe.xml
2010-11-08 09:44:18,752 [ main] DEBUG config.ConfigurationFactory - Configuring ehcache from URL: jar:file:/C:/Documents%20and%20Settings/dg03118/.m2/repository/net/sf/ehcache/ehcache-core/2.3.0/ehcache-core-2.3.0.jar!/ehcache-failsafe.xml
2010-11-08 09:44:18,752 [ main] DEBUG config.ConfigurationFactory - Configuring ehcache from InputStream
2010-11-08 09:44:18,845 [ main] DEBUG config.BeanHandler - Ignoring ehcache attribute xmlns:xsi
2010-11-08 09:44:18,845 [ main] DEBUG config.BeanHandler - Ignoring ehcache attribute xsi:noNamespaceSchemaLocation
2010-11-08 09:44:18,845 [ main] DEBUG config.DiskStoreConfiguration - Disk Store Path: C:\DOCUME~1\dg03118\LOCALS~1\Temp\
2010-11-08 09:44:18,861 [ main] DEBUG config.DiskStoreConfiguration - Disk Store Path: C:\DOCUME~1\dg03118\LOCALS~1\Temp\
2010-11-08 09:44:18,861 [ main] DEBUG util.PropertyUtil - propertiesString is null.
2010-11-08 09:44:18,861 [ main] DEBUG config.ConfigurationHelper - No CacheManagerEventListenerFactory class specified. Skipping...
2010-11-08 09:44:18,939 [ main] DEBUG ehcache.Cache - No BootstrapCacheLoaderFactory class specified. Skipping...
2010-11-08 09:44:18,939 [ main] DEBUG ehcache.Cache - CacheWriter factory not configured. Skipping...
2010-11-08 09:44:18,939 [ main] DEBUG config.ConfigurationHelper - No CacheExceptionHandlerFactory class specified. Skipping...
The junit test
Code:
import static org.junit.Assert.assertEquals;
import net.sf.ehcache.CacheManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.PropertyConfigurator;
import org.junit.Before;
import org.junit.Test;
import org.springframework.util.StopWatch;
import us.tn.state.trust.utility.codes.domain.CountyAddressId;
import us.tn.state.trust.utility.codes.domain.LUCountyAddress;
public class ECacheWrapperTest {
   private static final Log logger = LogFactory.getLog(ECacheWrapperTest.class);
   private StopWatch sw;
   private Integer counter;
   @Before
   public void before() {
      PropertyConfigurator.configure("src/test/java/log4j.properties");
   }
   @Test
   public void testCacheWrapper(){
      logger.debug("testCacheWrapper");
       CacheManager cacheManager = new CacheManager();
       String[] cn = cacheManager.getCacheNames();
       int i;
       for (i=1;i<cn.length;i++){System.out.println(cn[i]);}
       LUCountyAddress countyAddress = new LUCountyAddress();
       CountyAddressId aid = new CountyAddressId() ;
       aid.setAddrId(11);
       aid.setCntyCde("19");
       countyAddress.setId(aid);
       EhcacheWrapper<Long ,LUCountyAddress > cw = new EhcacheWrapper<Long ,LUCountyAddress >(LUCountyAddress.class.getName(),cacheManager);
//      EhcacheWrapper<String ,String > cw = new EhcacheWrapper<String ,String >(LUCountyAddress.class.getName(),cacheManager);
      cw.put(new Long(1), countyAddress);
      LUCountyAddress str = cw.get(new Long(1));
      int ii = str.getId().getAddrId();
      assertEquals(11,ii);
      logger.debug("testCacheWrapper Finish");
   }
}
Code:
      <dependency>
         <groupId>net.sf.ehcache</groupId>
         <artifactId>ehcache</artifactId>
         <version>2.2.0</version>
         <type>pom</type>
         <scope>compile</scope>
      </dependency>
      <dependency>
         <groupId>org.hibernate</groupId>
         <artifactId>hibernate</artifactId>
         <version>3.5.4-Final</version>
         <type>pom</type>
         <scope>compile</scope>
      </dependency>
      <dependency>
         <groupId>org.hibernate</groupId>
         <artifactId>hibernate-annotations</artifactId>
         <version>3.5.6-Final</version>
         <type>jar</type>
         <scope>compile</scope>
      </dependency>
      <dependency>
         <groupId>org.hibernate</groupId>
         <artifactId>hibernate-entitymanager</artifactId>
         <version>3.5.6-Final</version>
         <type>jar</type>
         <scope>compile</scope>
      </dependency>
      <dependency>
         <groupId>org.hibernate</groupId>
         <artifactId>hibernate-validator</artifactId>
         <version>4.0.2.GA</version>
         <type>jar</type>
         <scope>compile</scope>
      </dependency>
      <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-jcl</artifactId>
         <version>1.5.8</version>
         <type>jar</type>
         <scope>compile</scope>
      </dependency>
      <dependency>
         <groupId>net.sf.ehcache</groupId>
         <artifactId>ehcache-core</artifactId>
         <version>2.3.0</version>
         <type>jar</type>
         <scope>compile</scope>
      </dependency>