Reputation: 93
Can any one help me why below error message could appear on application server. I am trying to setup EHCache with Terracotta. Please suggest any clue why this message could appear.
[DEBUG][08/05/12 13:50:19.648][CacheByAmitNode8081] Running mbean initializer task for ehcache hibernate...
[DEBUG][08/05/12 13:50:19.766][CacheByAmitNode8081] Successfully registered bean
[ERROR][08/05/12 13:50:19.805][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][08/05/12 13:50:19.815][CacheByAmitNode8081] SessionFactory is probably still being initialized... waiting for it to complete before enabling hibernate statistics monitoring via JMX
Upvotes: 0
Views: 309
Reputation: 41
I had this exact same problem today. This seems to be caused by a bug in the class ProviderMBeanRegistrationHelper at line 152
Map map = (Map) instancesField.get( null );
where in lines 146 and 147 we have
Class factoryType = SessionFactoryRegistry.class;
Field instancesField = getField( factoryType, "sessionFactoryMap" );
so we know that instanceField is a field from an instance of class SessionFactoryRegistry which just so happens to have a single instance that can be obtained statically from the class as
SessionFactoryRegistry.INSTANCE
In conclusion, i modified line 152 as follows
Map map = (Map) instancesField.get( SessionFactoryRegistry.INSTANCE );
Compiled and replaced the class in the hibernate-ehcache jar file and the exception went away. I will file an issue about this.
Upvotes: 2