hibernate-memcached and Jboss AS 7

297 views
Skip to first unread message

Dragos Luca

unread,
Apr 26, 2012, 12:49:06 AM4/26/12
to hibernate-memcached, raykr...@gmail.com
Hi all,
I have a J2EE app which is hosted in a Jboss AS 7 server. This
application is using JPA as a persistence store. The best way to
improve this app which will run as a cluster in multiple machines is
to use hibernate-memcached as a second level cache. Below i've posted
my config from the persistence.xml and already added to the JPA
project the specified jars from the configuration page (hibernate-
memcached-1.2.2.jar, memcached-2.3.1.jar and slf4j-jdk14-1.6.4.jar). I
am trying for a few days to make it passed but not having a success.
Maybe i understand wrong the hibernated-memcached usage or i am to new
to this. Please be kind and point me to a good direction or reply with
a solution.

Thank you very much and i want to say that this idea is great and i
really want to see it work :) (if i am on the right track).

error at server startup
---------------------------------------
ERROR [org.jboss.msc.service.fail] (MSC service thread 1-15) MSC00001:
Failed to start service
jboss.persistenceunit."HFPlatform.ear#HFPlatformData":
org.jboss.msc.service.StartException in service
jboss.persistenceunit."HFPlatform.ear#HFPlatformData": Failed to start
service
at org.jboss.msc.service.ServiceControllerImpl
$StartTask.run(ServiceControllerImpl.java:1786)
at org.jboss.msc.service.ServiceControllerImpl
$ClearTCCLTask.run(ServiceControllerImpl.java:2291)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:
1110) [:1.7.0_03]
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:603) [:1.7.0_03]
at java.lang.Thread.run(Thread.java:722) [:1.7.0_03]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit:
HFPlatformData] Unable to build EntityManagerFactory
at
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:
903)
at
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:
879)
at
org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:
73)
at
org.jboss.as.jpa.service.PersistenceUnitService.createContainerEntityManagerFactory(PersistenceUnitService.java:
170)
at
org.jboss.as.jpa.service.PersistenceUnitService.start(PersistenceUnitService.java:
80)
at org.jboss.msc.service.ServiceControllerImpl
$StartTask.run(ServiceControllerImpl.java:1765)
... 4 more
Caused by: org.hibernate.HibernateException: could not instantiate
RegionFactory
[org.hibernate.cache.internal.bridge.RegionFactoryCacheProviderBridge]
at
org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:
355)
at
org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:
217)
at
org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:
2251)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:
2247)
at
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:
1718)
at
org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:
77)
at
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:
894)
... 9 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method) [:1.7.0_03]
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:
57) [:1.7.0_03]
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:
45) [:1.7.0_03]
at java.lang.reflect.Constructor.newInstance(Constructor.java:525) [:
1.7.0_03]
at
org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:
338)
... 15 more
Caused by: org.hibernate.cache.CacheException: could not instantiate
CacheProvider
[com.googlecode.hibernate.memcached.MemcachedCacheProvider]
at
org.hibernate.cache.internal.bridge.RegionFactoryCacheProviderBridge.<init>(RegionFactoryCacheProviderBridge.java:
68)
... 20 more
Caused by: java.lang.ClassNotFoundException:
com.googlecode.hibernate.memcached.MemcachedCacheProvider from [Module
"org.hibernate:main" from local module loader @1839bb3 (roots: C:
\jboss-7.0.0\modules)]
at
org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:
191)
at
org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:
358)
at
org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:
330)
at
org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:
307)
at
org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:
101)
at java.lang.Class.forName0(Native Method) [:1.7.0_03]
at java.lang.Class.forName(Class.java:186) [:1.7.0_03]
at
org.hibernate.internal.util.ReflectHelper.classForName(ReflectHelper.java:
191)
at
org.hibernate.cache.internal.bridge.RegionFactoryCacheProviderBridge.<init>(RegionFactoryCacheProviderBridge.java:
65)
... 20 more

persistence.xml
--------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/
persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="HFPlatformData">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/HFP</jta-data-source>
<class>com.hfp.entity.Package</class>
<class>com.hfp.entity.Transaction</class>
<class>com.hfp.entity.User</class>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.MySQLInnoDBDialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/
>

<property name="hibernate.cache.use_query_cache"
value="true"/>
<!-- <property
name="hibernate.cache.use_second_level_cache" value="true"/> -->
<property name="hibernate.cache.provider_class"
value="com.googlecode.hibernate.memcached.MemcachedCacheProvider"/>

<!-- memcache server settings -->
<property name="hibernate.memcached.servers"
value="calhost:11211"/>
<property name="hibernate.memcached.cacheTimeSeconds"
value="300"/>
<property name="hibernate.memcached.keyStrategy"
value="HashCodeKeyStrategy"/>
<property name="hibernate.memcached.readBufferSize"
value="DefaultConnectionFactory.DEFAULT_READ_BUFFER_SIZE"/>
<property name="hibernate.memcached.operationQueueLength"
value="DefaultConnectionFactory.DEFAULT_OP_QUEUE_LEN"/>
<property name="hibernate.memcached.operationTimeout"
value="DefaultConnectionFactory.DEFAULT_OPERATION_TIMEOUT"/>
<property name="hibernate.memcached.hashAlgorithm"
value="HashAlgorithm.NATIVE_HASH"/>
<property name="hibernate.memcached.connectionFactory"
value="DefaultConnectionFactory"/>
<property name="hibernate.memcached.clearSupported"
value="false"/>

<property name="hibernate.jdbc.batch_size" value="20"/>
</properties>
</persistence-unit>
</persistence>

RayKrueger

unread,
Apr 26, 2012, 10:01:34 AM4/26/12
to hibernate-memcached
Looks like you have some classpath issues.
Caused by: java.lang.ClassNotFoundException:
com.googlecode.hibernate.memcached.MemcachedCacheProvider




You need to get the hibernate-memcached.jar into the right place to
make Jboss happy

On Apr 25, 11:49 pm, Dragos Luca <dragos.l...@healthfidelity.com>
wrote:
> xsi:schemaLocation="http://java.sun.com/xml/ns/persistencehttp://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
Reply all
Reply to author
Forward
0 new messages