Hibernate4 issue, org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [hibernate-session-context.xml]: Invocation of init method failed; nested exception is java.lang.

5,051 views
Skip to first unread message

Shivam Rohilla

unread,
Apr 4, 2014, 11:01:08 AM4/4/14
to haze...@googlegroups.com
Hi,
  I am trying to use hazelcast as a 2nd level cache with hibernate4, but I am facing the issue :

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [hibernate-session-context.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cache/QueryResultsRegion

I am using HIbernate 4, Hazelcast 3.1.7, jdk7

my Hibernate-context.xml :
<?xml version="1.0" encoding="UTF-8"?>
">

<context:annotation-config />
<context:component-scan base-package="com.test.dataaccess.*, com.test.dao" />

<bean id="testDS"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
<property name="url"
value="jdbc:sqlserver://10.207.170.135:1433;databaseName=Jato_POC" />
<property name="username" value="BI_POC1" />
<property name="password" value="p@ssw0rd" />


</bean>

<bean id="instance" class="com.hazelcast.core.Hazelcast"
factory-method="newHazelcastInstance">
<constructor-arg>
<bean class="com.hazelcast.config.Config" />
</constructor-arg>
</bean>



<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="SpeedwingDS"></property>
<property name="packagesToScan" value="com.jato.*" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.hbm2ddl.auto">validate</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.current_session_context_class">thread</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<!-- <prop key="hibernate.cache.use_structured_entires">true</prop> -->
<prop key="hibernate.cache.use_minimal_puts">true</prop>
<!-- <prop key="hibernate.cache.hazelcast.use_lite_member">true</prop> -->
<prop key="hibernate.cache.region.factory_class">com.hazelcast.hibernate.HazelcastCacheRegionFactory
</prop>
</props>
</property>
</bean>

<!-- hsqqldb end -->

<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:annotation-driven />
</beans>

In hibernate4 the QueryResultsRegion class is in  org.hibernate.cache.spi.QueryResultsRegion however it's searching in org.hibernate.cache.QueryResultsRegion

Kindly have alook on it and provide the solution as soon as possible.

Thanks
Shivam

a...@hazelcast.com

unread,
Apr 4, 2014, 11:20:55 AM4/4/14
to haze...@googlegroups.com
Do you provide hazelcast-hibernate4.jar ?

Ahmet Mircik

unread,
Apr 4, 2014, 11:46:04 AM4/4/14
to haze...@googlegroups.com


--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+...@googlegroups.com.
To post to this group, send email to haze...@googlegroups.com.
Visit this group at http://groups.google.com/group/hazelcast.
To view this discussion on the web visit https://groups.google.com/d/msgid/hazelcast/ea509406-d5bc-41d9-ac96-fe7651e66d54%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Shivam Rohilla

unread,
Apr 4, 2014, 11:51:46 AM4/4/14
to haze...@googlegroups.com
I am already using hazelcast-hibernate4.jar

ali gurbuz

unread,
Apr 4, 2014, 11:53:05 AM4/4/14
to haze...@googlegroups.com
seems like there is also hazelcast-hibernate3.jar in your class-path too


--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+...@googlegroups.com.
To post to this group, send email to haze...@googlegroups.com.
Visit this group at http://groups.google.com/group/hazelcast.

Shivam Rohilla

unread,
Apr 4, 2014, 12:05:19 PM4/4/14
to haze...@googlegroups.com
I have only 1 jar of hazelcast i.e. hazelcast-hibernate4


On Friday, April 4, 2014 8:31:08 PM UTC+5:30, Shivam Rohilla wrote:

Shivam Rohilla

unread,
Apr 4, 2014, 12:21:03 PM4/4/14
to haze...@googlegroups.com
I am not understanding why anybody didn't had concerned of
" java.lang.ClassNotFoundException: org.hibernate.cache.QueryResultsRegion "
issue.


On Friday, April 4, 2014 8:31:08 PM UTC+5:30, Shivam Rohilla wrote:

rusha...@gmail.com

unread,
Feb 5, 2017, 1:57:55 AM2/5/17
to Hazelcast
I am also facing the same problem as mentioned below.

Feb 05, 2017 2:38:27 AM org.apache.catalina.core.ApplicationContext log
INFO: Set web app root system property: 'webapp.root' = [C:\Tomcat_6.0.36\webapps\codetestapp\]
Feb 05, 2017 2:38:27 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Log4J from [C:\Tomcat_6.0.36\webapps\codetestapp\WEB-INF\log4j.xml]
Feb 05, 2017 2:38:33 AM org.apache.catalina.core.ApplicationContext log
INFO: Loading Spring root WebApplicationContext
Feb 05, 2017 2:38:36 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/codetestapp-data.xml]: Invocation of init method failed; nested exception is org.springframework.beans.FatalBeanException: Could not instantiate class [org.hibernate.cfg.AnnotationConfiguration]; constructor threw exception; nested exception is java.lang.NoSuchFieldError: INSTANCE
org.springframework.beans.FatalBeanException: Could not instantiate class [org.hibernate.cfg.AnnotationConfiguration]; constructor threw exception; nested exception is java.lang.NoSuchFieldError: INSTANCE
java.lang.NoSuchFieldError: INSTANCE
at org.hibernate.type.BasicTypeRegistry.<init>(BasicTypeRegistry.java:94)
at org.hibernate.type.TypeResolver.<init>(TypeResolver.java:59)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:250)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:302)
at org.hibernate.cfg.AnnotationConfiguration.<init>(AnnotationConfiguration.java:59)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:174)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:150)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newConfiguration(LocalSessionFactoryBean.java:796)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:597)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:856)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:825)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:418)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:241)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:152)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:247)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:331)
at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:155)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

Feb 05, 2017 2:38:36 AM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
Feb 05, 2017 2:38:36 AM org.apache.catalina.core.ApplicationContext log
INFO: Shutting down Log4J
Feb 05, 2017 2:38:38 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Feb 05, 2017 2:38:38 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()


What is the solution for this?

Thanks
adi

em...@hazelcast.com

unread,
Feb 6, 2017, 2:46:31 AM2/6/17
to Hazelcast
Hi Adi,

I cannot see anything related to Hazelcast in your stacktrace. It seems like you're having a problem related to your Spring/Hibernate configuration. Can you provide more information on what you're trying to achieve? Which Hazelcast-hibernate version are you using, and which Spring/Hibernate versions?
Reply all
Reply to author
Forward
0 new messages