[Javalist] Spring JPA + Hibernate + ehcache probléma - NoCacheRegionFactoryAvailableException

Bartuszek Viktor viktor.bartuszek at rhodeus.hu
2013. Feb. 7., Cs, 09:29:26 CET


Szia,

Köszönöm a választ. Azzal is próbálkoztam, de az hibernate3-hoz van. Ebben
a pillanatban lett jó, a megoldás pusztán annyi volt, hogy nem szabad
összekeverni a sessionfactory-t az entitymanager-el :)

A módosult konfig:

<bean id="entityManagerFactory"

class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="packagesToScan" value="my.spring.model" />
        <property name="jpaVendorAdapter">
            <bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                <property name="showSql"
value="$persistence{hibernate.show_sql}" />
            </bean>
        </property>
        <property name="jpaProperties">
            <props>
                <prop
key="hibernate.current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</prop>
                <prop
key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>
                <prop key="hibernate.cache.use_query_cache">true</prop>
                <prop
key="hibernate.cache.use_second_level_cache">true</prop>
                <prop
key="hibernate.cache.provider_configuration_file_resource_path">classpath:ehcache.xml</prop>
                <prop key="hibernate.generate_statistics">true</prop>
                <prop
key="hibernate.cache.use_structured_entries">true</prop>
            </props>
        </property>
        <property name="persistenceUnitName" value="s2aUnit" />
    </bean>

A sessionFactory bean meg kuka, és így jó :)

Köszi mégegyszer,
Bartuszek Viktor


On Thu, Feb 7, 2013 at 9:06 AM, cx.chico <cx.chico at gmail.com> wrote:

> Szia!
>
> Személyes tapasztalatom nincs a témában, de egy helyen ezt láttam:
>
> <property
> name="hibernate.cache.region.factory_class">Net.sf.ehcache.hibernate.EhCacheRegionFactory<
> /property>
>
> Ehhez lehet, hogy kell a nem-hibernate-s ehcache is a pom.xml-be.
>
> Üdv,
> Chico
>
>
> 2013/2/6 Bartuszek Viktor <viktor.bartuszek at rhodeus.hu>:
> > Sziasztok!
> >
> > Meggyűlt a bajom a ${subject} kombóval, és már sajnos a 30+ konfig után
> már
> > nem tudom merre menjek tovább. Erre a felállásra nem találtam sajno
> howto.
> >
> > Jelen pillanatban a releváns spring konfigok így néznek ki:
> >
> > <jpa:repositories base-package="my.spring.repository"
> >         entity-manager-factory-ref="entityManagerFactory"
> > transaction-manager-ref="transactionManager" />
> >
> > <bean id="transactionManager"
> > class="org.springframework.orm.hibernate4.HibernateTransactionManager">
> >         <property name="dataSource" ref="dataSource" />
> >         <property name="sessionFactory" ref="sessionFactory" />
> >     </bean>
> >
> >     <bean id="sessionFactory"
> > class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
> >         <property name="dataSource" ref="dataSource"/>
> >         <property name="hibernateProperties">
> >             <props>
> >                 <prop
> >
> key="hibernate.current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</prop>
> >                 <prop
> >
> key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>
> >                 <prop key="hibernate.cache.use_query_cache">true</prop>
> >                 <prop
> > key="hibernate.cache.use_second_level_cache">true</prop>
> >                 <prop
> >
> key="hibernate.cache.provider_configuration_file_resource_path">classpath:ehcache.xml</prop>
> >                 <prop key="hibernate.generate_statistics">true</prop>
> >                 <prop
> > key="hibernate.cache.use_structured_entries">true</prop>
> >             </props>
> >         </property>
> >         <property name="packagesToScan" value="my.spring.model" />
> >     </bean>
> >
> >     <bean id="entityManagerFactory"
> >
> >
> class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
> >         <property name="dataSource" ref="dataSource" />
> >         <property name="packagesToScan" value="my.spring.model" />
> >         <property name="jpaVendorAdapter">
> >             <bean
> > class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
> >                 <property name="showSql"
> > value="$persistence{hibernate.show_sql}" />
> >             </bean>
> >         </property>
> >         <property name="persistenceUnitName" value="myUnit" />
> >     </bean>
> >
> > A logban a lényegi bejegyzések:
> > 2013-02-06 16:34:11,031 DEBUG [][] n.s.e.config.ConfigurationFactory -
> > Configuring ehcache from ehcache.xml found in the classpath:
> > file:/home/bartuszekv/.../target/classes/ehcache.xml
> > 2013-02-06 16:34:11,031 DEBUG [][] n.s.e.config.ConfigurationFactory -
> > Configuring ehcache from URL:
> > file:/home/bartuszekv/.../target/classes/ehcache.xml
> > 2013-02-06 16:34:11,031 DEBUG [][] n.s.e.config.ConfigurationFactory -
> > Configuring ehcache from InputStream
> > 2013-02-06 16:34:11,040 DEBUG [][] net.sf.ehcache.config.BeanHandler -
> > Ignoring ehcache attribute xmlns:xsi
> > 2013-02-06 16:34:11,040 DEBUG [][] net.sf.ehcache.config.BeanHandler -
> > Ignoring ehcache attribute xsi:noNamespaceSchemaLocation
> > 2013-02-06 16:34:11,040 DEBUG [][] n.s.e.config.DiskStoreConfiguration -
> > Disk Store Path: /tmp/EhCacheSpringStore
> > 2013-02-06 16:34:11,084 DEBUG [][] net.sf.ehcache.util.PropertyUtil -
> > propertiesString is null.
> > 2013-02-06 16:34:11,088 DEBUG [][] n.s.e.config.ConfigurationHelper - No
> > CacheManagerEventListenerFactory class specified. Skipping...
> > 2013-02-06 16:34:11,125 DEBUG [][] net.sf.ehcache.Cache - No
> > BootstrapCacheLoaderFactory class specified. Skipping...
> > 2013-02-06 16:34:11,125 DEBUG [][] net.sf.ehcache.Cache - CacheWriter
> > factory not configured. Skipping...
> > 2013-02-06 16:34:11,126 DEBUG [][] n.s.e.config.ConfigurationHelper - No
> > CacheExceptionHandlerFactory class specified. Skipping...
> > 2013-02-06 16:34:11,128 DEBUG [][] net.sf.ehcache.Cache - No
> > BootstrapCacheLoaderFactory class specified. Skipping...
> > 2013-02-06 16:34:11,129 DEBUG [][] net.sf.ehcache.Cache - CacheWriter
> > factory not configured. Skipping...
> > 2013-02-06 16:34:11,129 DEBUG [][] n.s.e.config.ConfigurationHelper - No
> > CacheExceptionHandlerFactory class specified. Skipping...
> > 2013-02-06 16:34:11,129 DEBUG [][] net.sf.ehcache.Cache - No
> > BootstrapCacheLoaderFactory class specified. Skipping...
> > 2013-02-06 16:34:11,129 DEBUG [][] net.sf.ehcache.Cache - CacheWriter
> > factory not configured. Skipping...
> > 2013-02-06 16:34:11,129 DEBUG [][] n.s.e.config.ConfigurationHelper - No
> > CacheExceptionHandlerFactory class specified. Skipping...
> > 2013-02-06 16:34:11,129 WARN  [][] net.sf.ehcache.Cache - Cache:
> > org.hibernate.cache.UpdateTimestampsCache has a maxElementsInMemory of 0.
> > In Ehcache 2.0 this has been changed to mean a store with no capacity
> limit.
> > Set it to 1 if you want no elements cached in memory
> > 2013-02-06 16:34:11,146 DEBUG [][] net.sf.ehcache.Cache - Initialised
> cache:
> > org.hibernate.cache.UpdateTimestampsCache
> > 2013-02-06 16:34:11,146 DEBUG [][] n.s.e.config.ConfigurationHelper -
> > CacheDecoratorFactory not configured. Skipping for
> > 'org.hibernate.cache.UpdateTimestampsCache'.
> > 2013-02-06 16:34:11,146 DEBUG [][] n.s.e.config.ConfigurationHelper -
> > CacheDecoratorFactory not configured for defaultCache. Skipping for
> > 'org.hibernate.cache.UpdateTimestampsCache'.
> > 2013-02-06 16:34:11,153 DEBUG [][]
> n.s.e.s.c.f.DiskOverflowStorageFactory -
> > Deleting data file org.hibernate.cache.StandardQueryCache.data
> > 2013-02-06 16:34:11,164 DEBUG [][] net.sf.ehcache.Cache - Initialised
> cache:
> > org.hibernate.cache.StandardQueryCache
> > 2013-02-06 16:34:11,164 DEBUG [][] n.s.e.config.ConfigurationHelper -
> > CacheDecoratorFactory not configured. Skipping for
> > 'org.hibernate.cache.StandardQueryCache'.
> > 2013-02-06 16:34:11,164 DEBUG [][] n.s.e.config.ConfigurationHelper -
> > CacheDecoratorFactory not configured for defaultCache. Skipping for
> > 'org.hibernate.cache.StandardQueryCache'.
> > 2013-02-06 16:34:11,193 INFO  [][] org.hibernate.validator.util.Version -
> > Hibernate Validator 4.2.0.Final
> > 2013-02-06 16:34:11,499 DEBUG [][] net.sf.ehcache.Cache - Initialised
> cache:
> > my.spring.model.Entity1
> > 2013-02-06 16:34:11,500 DEBUG [][] n.s.e.config.ConfigurationHelper -
> > CacheDecoratorFactory not configured for defaultCache. Skipping for
> > 'my.spring.model.Entity1'.
> > 2013-02-06 16:34:11,514 DEBUG [][] net.sf.ehcache.Cache - Initialised
> cache:
> > my.spring.model.Entity2
> > 2013-02-06 16:34:11,515 DEBUG [][] n.s.e.config.ConfigurationHelper -
> > CacheDecoratorFactory not configured for defaultCache. Skipping for
> > 'my.spring.model.Entity2'.
> > ...
> >
> > Majd mikor nekifekszik az entitásoknak:
> >
> > 2013-02-06 16:34:13.151:WARN::Nested in
> > org.springframework.beans.factory.BeanCreationException: Error creating
> bean
> > with name
> >
> 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0':
> > Initialization of bean failed; nested exception is
> > org.springframework.beans.factory.BeanCreationException: Error creating
> bean
> > with name 'entityManagerFactory' defined in class path resource
> > [persistence-context.xml]: Invocation of init method failed; nested
> > exception is javax.persistence.PersistenceException: [PersistenceUnit:
> > myUnit] Unable to build EntityManagerFactory:
> > org.hibernate.cache.NoCacheRegionFactoryAvailableException: Second-level
> > cache is used in the application, but property
> > hibernate.cache.region.factory_classis not gaven, please either disable
> > second level cache or set correct region factory class name to property
> > hibernate.cache.region.factory_class (and make sure the second level
> cache
> > provider, hibernate-infinispan, for example, available in the classpath).
> >     at
> >
> org.hibernate.cache.internal.NoCachingRegionFactory.buildEntityRegion(NoCachingRegionFactory.java:69)
> >     at
> >
> org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:347)
> >     at
> >
> org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1740)
> >     at
> >
> org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94)
> >     at
> >
> org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)
> >     at
> >
> org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889)
> >     at
> >
> org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
> >
> > pom.xml erre vonatkozó bejegyzése:
> >
> > <dependency>
> >             <groupId>org.hibernate</groupId>
> >             <artifactId>hibernate-entitymanager</artifactId>
> >             <version>${hibernate.version}</version>
> >         </dependency>
> >         <dependency>
> >             <groupId>org.hibernate</groupId>
> >             <artifactId>hibernate-validator</artifactId>
> >             <version>${hibernate.validator.version}</version>
> >         </dependency>
> >         <dependency>
> >             <groupId>org.hibernate</groupId>
> >             <artifactId>hibernate-ehcache</artifactId>
> >             <version>${hibernate.version}</version>
> >         </dependency>
> >
> > Aholis a hibernate verzió 4.1.1.Final
> >
> > Megbírkózott már esetleg valaki ezzel? Az is nagy segítség lenne, ha
> valami
> > erre vonatkozó dokumentációt tudna linkelni valaki.
> >
> > A válaszokat előre is köszönöm,
> > Bartuszek Viktor
> >
> > _______________________________________________
> > Javalist mailing list
> > Javalist at lists.javaforum.hu
> > http://lists.javaforum.hu/mailman/listinfo/javalist
> >
> _______________________________________________
> Javalist mailing list
> Javalist at lists.javaforum.hu
> http://lists.javaforum.hu/mailman/listinfo/javalist
>
--------- következő rész ---------
Egy csatolt HTML állomány át lett konvertálva...
URL: <http://lists.javaforum.hu/pipermail/javalist/attachments/20130207/0e849b88/attachment.html>


További információk a(z) Javalist levelezőlistáról