2

我正在尝试使用 Terracotta 在分布式环境中设置 EHCache。在这里,我可以连接应用程序服务器和 Terracotta 服务器,在 terracotta Developer Console 中,我可以看到复制的对象。

但是在应用程序服务器中不断出现以下异常消息,尽管应用程序的其余部分运行正常:

大家好,如果有任何机构可以指导为什么会出现此异常消息以及我们如何解决它。此外,如果有任何关于为休眠应用程序设置兵马俑的综合教程,这对我也会有所帮助。

这里 [CacheByAmitNode8081] 是我在应用服务器中定义的缓存节点的名称。

[DEBUG][04/05/12 12:49:07.973][CacheByAmitNode8081] Running mbean initializer task for ehcache hibernate...
[DEBUG][04/05/12 12:49:07.995][CacheByAmitNode8081] Successfully registered bean
[ERROR][04/05/12 12:49:08.000][CacheByAmitNode8081] 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)
[DEBUG][04/05/12 12:49:08.001][CacheByAmitNode8081] SessionFactory is probably still being initialized... waiting for it to complete before enabling hibernate statistics monitoring via JMX
[DEBUG][04/05/12 12:49:08.001][CacheByAmitNode8081] Running mbean initializer task for ehcache hibernate...
[ERROR][04/05/12 12:49:08.001][CacheByAmitNode8081] 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)*
4

1 回答 1

0

当你使用 Terracotta 时,你需要在你的类路径中添加特定的 terracotta jars 来替换 ehcache 实现。在您的异常堆栈中,我没有看到任何兵马俑类输出...

在我的 Maven 依赖项中,我有:

<dependency>
  <groupId>net.sf.ehcache</groupId>
  <artifactId>ehcache-core-ee</artifactId>
  <version>2.5.2</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>net.sf.ehcache</groupId>
  <artifactId>ehcache-terracotta-ee</artifactId>
  <version>2.5.2</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>org.terracotta</groupId>
  <artifactId>terracotta-toolkit-1.5-runtime-ee</artifactId>
  <version>4.2.0</version>
  <scope>compile</scope>
</dependency>

您还可以查看关于如何插入 Hibernate 的 Terracotta 教程:http : //terracotta.org/documentation/enterprise-ehcache/get-started-hibernate

于 2012-09-27T16:18:36.613 回答