简体   繁体   中英

how to package hibernate-memcached to use it in JBoss 7

I have been trying to set up a Java EE Application on JBOSS AS 7 to use hibernate-memcached as a second level cache. The goal is to be able to scale at JPA level and to use a clustered cache. I've tried to manually put the jar in jboss modules but I am getting this errors. here are some of those errors:

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)
    ... 24 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)
    ... 24 more

How can I fix these errors?

A couple of ways come to mind:

  • Define a new hibernate-memcached module, and add a dependency to it in the main hibernate module; or

  • just add the hibernate-memcached JARs to the main hibernate module and add them as resource-roots in module.xml .

For details on how to create and modify modules see the documentation on class loading and modules in AS7 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM