Ola Pessoal!
Estou tentando ativar o second level cache do hibernate, mas nao estou conseguindo, obtenho uma serio de erros muito estranha... sem o cache, tudo funciona normalmente, porem com o cache habilitado, tenho uma sequence grande de erros, aqui esta o meu hibernate.properties
# Configuracao do Hibernate para Conexao com base de dados
#Configuracao para PostGres
hibernate.dialect org.hibernate.dialect.PostgreSQLDialect
hibernate.connection.driver_class org.postgresql.Driver
hibernate.connection.url jdbc:postgresql://localhost:5432/infotx
hibernate.connection.username postgres
hibernate.connection.password wiling250589*#
hibernate.show_sql true
hibernate.format_sql true
transaction.factory_class org.hibernate.transaction.JDBCTransactionFactory
hibernate.cache.use_query_cache true
hibernate.cache.provider_class org.hibernate.cache.EhCacheProvider
#Aqui as Configuracoes do C3p0, um controlador de pools de conexao
hibernate.c3p0.min_size=5
hibernate.c3p0.max_size=20
hibernate.c3p0.timeout=1800
hibernate.c3p0.max_statements=50
e aqui esta o meu ehcache.xml
<ehcache>
<diskStore path="java.io.tmpdir"/>
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="true"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
/>
<cache name="br.com.infolog.infotx.modelo.Cidade"
maxElementsInMemory="300"
eternal="true"
overflowToDisk="false"
/>
<cache name="br.com.infolog.infotx.modelo.Bairro"
maxElementsInMemory="5000"
eternal="false"
overflowToDisk="false"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
/>
</ehcache>
estou usando hibernate 3.3.1 e hibernate annotations 3.4.0 o meu ehcache.xml esta no classpatch, tambem coloquei la o jar do ehcache, abaixo segue a lista de erros que estou tendo, se alguem puder me ajudar pessoal, ficarei muito grato! pois nao sei o que pode ser isso, inclusive ja tentei outros caches como oscache, mesma coisa…
827 [main] INFO org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge - Cache provider: org.hibernate.cache.EhCacheProvider
Exception in thread "main" java.lang.ExceptionInInitializerError
at br.com.infolog.infotx.dao.DaoFactory.<init>(DaoFactory.java:27)
at br.com.infolog.infotx.dao.DaoFactory.getInstance(DaoFactory.java:32)
at br.com.infolog.infotx.persistencia.Teste.main(Teste.java:10)
Caused by: org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge]
at org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:412)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:271)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2101)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1325)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at br.com.infolog.infotx.persistencia.HibernateUtil.<clinit>(HibernateUtil.java:22)
... 3 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:407)
... 8 more
Caused by: org.hibernate.cache.CacheException: could not instantiate CacheProvider [org.hibernate.cache.EhCacheProvider]
at org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge.<init>(RegionFactoryCacheProviderBridge.java:66)
... 13 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.cache.EhCacheProvider
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:123)
at org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge.<init>(RegionFactoryCacheProviderBridge.java:63)
... 13 more
Antecipadamente agradeço a boa vontade do pessoal! Abraço a todos