Author |
Message |
01/25/2012 05:14:13
|
dominus
neo
Joined: 01/25/2012 05:09:22
Messages: 9
Offline
|
Hi,
I am intrested in using Terracotta but it seems that in our application we are using Hibernate 4.0.0.Final which i suspect is not (yet) working with newest Terracotta.
Is there any way of integrating Hibernate 4.0.0.Final and Terracotta distributed cache?
Now when starting application I get an exception which tells me that terracotta would like to use class from Hibernate which does not exist anymore. I hope someone can help me with this problem.
_______________________________________
Caused by: java.lang.NoClassDefFoundError: org/hibernate/cache/CacheProvider
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:138)
at org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:386)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:251)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2270)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2266)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1735)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84)
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)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:257)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
... 51 more
_______________________________________
Regards
Marek Dominiak
|
|
|
01/25/2012 10:55:34
|
alexsnaps
consul
Joined: 06/19/2009 09:06:00
Messages: 484
Offline
|
You should use the new (as of 3.3) CacheRegionFactory with Hibernate 4.0. CacheProvider aren't supported anymore iirc. Simply use:
org.hibernate.cache.ehcache.EhCacheRegionFactory
|
Alex Snaps (Terracotta engineer) |
|
|
01/26/2012 01:54:48
|
dominus
neo
Joined: 01/25/2012 05:09:22
Messages: 9
Offline
|
Thank you very much for your prompt response!
Your suggestion helped me to get up and run my server.
I still have a minor issues though: In server logs I see a NPE every second (the application is working though):
This is a stacktrace:
ERROR ProviderMBeanRegistrationHelper - Error locating Hibernate Session Factory
java.lang.NullPointerException
at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:36)
at sun.reflect.UnsafeQualifiedObjectFieldAccessorImpl.get(UnsafeQualifiedObjectFieldAccessorImpl.java:20)
at java.lang.reflect.Field.get(Field.java:358)
at org.hibernate.cache.ehcache.management.impl.ProviderMBeanRegistrationHelper$RegisterMBeansTask.locateSessionFactory(ProviderMBeanRegistrationHelper.java:152)
at org.hibernate.cache.ehcache.management.impl.ProviderMBeanRegistrationHelper$RegisterMBeansTask.run(ProviderMBeanRegistrationHelper.java:117)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
It looks like the MBean for Hibernate cannot be created , so I probably can't look at statistics in Terracotta Developer Console for Hibernate.
- Could it be because of my Hibernate/Ehcache/JPA2.0/Terracotta config?
- Is it ok to use ehcache 2.5.0 with Hibernate 4.0.1.Final
- Is it ok to use Terracotta 3.6 with ehcache 2.5.0 and Hibernate 4.0.1.Final
- Can I ignore the MBean registration failure and expects that everything else is working?
My config is here:
pom.xml:
...
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.2.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<exclusions>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>ejb3-persistence</artifactId>
</exclusion>
</exclusions>
<version>4.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>4.0.1.Final</version>
<exclusions>
<exclusion>
<artifactId>ehcache-core</artifactId>
<groupId>net.sf.ehcache</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<artifactId>ehcache-core</artifactId>
<groupId>net.sf.ehcache</groupId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-terracotta</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.terracotta</groupId>
<artifactId>terracotta-toolkit-1.4-runtime</artifactId>
<version>4.0.0</version>
</dependency>
...
persistence.xml:
...
<property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.ehcache.EhCacheRegionFactory"/>
<property name="hibernate.cache.use_second_level_cache" value="true" />
<property name="hibernate.cache.use_structured_entries" value="true" />
<property name="hibernate.cache.use_query_cache" value="true" />
....
I hope you can help me.
Regards
Marek Dominiak
|
|
|
01/26/2012 06:21:56
|
alexsnaps
consul
Joined: 06/19/2009 09:06:00
Messages: 484
Offline
|
Looks like there is an issue here.
I'll have a closer look and a reproducible test case. I'll keep the thread here updated, probably with link to a Hibernate's jira ticket at some point.
Thanks a lot for reporting!
|
Alex Snaps (Terracotta engineer) |
|
|
03/05/2012 04:04:57
|
rbkaer
neo
Joined: 03/05/2012 03:46:00
Messages: 6
Offline
|
Hi there,
I was just wondering of there is an update on this issue - I seem to be having exactly the same issue using Hibernate 4.1, ehcache terracotta 2.5.1 and terracotta toolkit 4.1.
It's a shame, because it seems to be the only thing holding back a release right now.
Sorry to be a nuisance and let me know if any further detail is needed.
rich.
|
|
|
03/05/2012 06:46:01
|
alexsnaps
consul
Joined: 06/19/2009 09:06:00
Messages: 484
Offline
|
I'm afraid this isn't yet fixed indeed.
I'm doing work on Hibernate today, will create a jira entry on Hibernate's bug tracker and will update you here end of the day (EST).
|
Alex Snaps (Terracotta engineer) |
|
|
03/05/2012 07:01:24
|
rbkaer
neo
Joined: 03/05/2012 03:46:00
Messages: 6
Offline
|
Many thanks for your quick reply. I can tell you that when this gets fixed our team will be MASSIVELY grateful.
|
|
|
03/09/2012 09:06:02
|
rbkaer
neo
Joined: 03/05/2012 03:46:00
Messages: 6
Offline
|
Hi again - I apologize for being annoying here, but are there any more updates on this?
|
|
|
03/09/2012 09:22:19
|
alexsnaps
consul
Joined: 06/19/2009 09:06:00
Messages: 484
Offline
|
Hey Rich,
We're working on this. Basically the fix is in Hibernate itself (the ehcache code lives there). With the repo being on github, 4.0 moving to Gradle and the like, we're currently in the process of formalizing how this will be QA'ed on our side.
If you'd be interest I could send you a patch for the Hibernate version you plan on using ? You can mail me at <forum login> at terracotta.org.
But you'd be required to use a custom build of Hibernate (or more specifically it's ehcache module), or wait for a new release of Hibernate with the fix to happen. I can't really give you more information of how this would happen...
|
Alex Snaps (Terracotta engineer) |
|
|
03/09/2012 11:02:36
|
rbkaer
neo
Joined: 03/05/2012 03:46:00
Messages: 6
Offline
|
Thank you again for your fast reply. I have sent you a message.
|
|
|
06/02/2012 04:20:51
|
torosyan
neo
Joined: 06/02/2012 04:15:39
Messages: 1
Offline
|
Hi all
Has this issue been fixed already?
I have the same problem with Hibernate 4.1.4
ERROR ProviderMBeanRegistrationHelper - Error locating Hibernate Session Factory
java.lang.NullPointerException
thanks in advance
|
|
|
06/18/2013 00:30:44
|
pomelko
journeyman
Joined: 03/15/2012 12:17:17
Messages: 13
Offline
|
Hi,
It's looks like there is still problem with mbean registration:
Code:
Exception in thread "cacheManager" java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:922)
at org.hibernate.internal.SessionFactoryRegistry.getSessionFactory(SessionFactoryRegistry.java:140)
at org.hibernate.internal.SessionFactoryRegistry.getNamedSessionFactory(SessionFactoryRegistry.java:135)
at org.hibernate.cache.ehcache.management.impl.ProviderMBeanRegistrationHelper$RegisterMBeansTask.locateSessionFactory(ProviderMBeanRegistrationHelper.java:143)
at org.hibernate.cache.ehcache.management.impl.ProviderMBeanRegistrationHelper$RegisterMBeansTask.run(ProviderMBeanRegistrationHelper.java:117)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
The issue you reported as https://hibernate.atlassian.net/browse/HHH-7562 is already fixed in Hibernate 4.1.7.
I'm using Hibernate 4.1.10 and the problem still occur.
It seems like registration is invoked too soon, and there is no sessionFactory in SessionFactoryRegistry map.
Comment added in https://hibernate.atlassian.net/browse/HHH-7518
|
|
|
|