TransactionManager cannot initialize
Asked Answered
C

5

6

NEW CONF: i made some change to match with what you are saying. now i deleted hibernate-cfg.xml and did all conf in spring-servlet.xml :

<jee:jndi-lookup id="ReferentielWebDevDataSource"
    jndi-name="ReferentielWebDevDataSource" />

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource" ref="ReferentielWebDevDataSource" />
    <property name="transaction.factory_class">
        <value>org.hibernate.transaction.JDBCTransactionFactory</value>
    </property>
    <!-- Disable the second-level cache -->
    <property name="cache.provider_class">
        <value>org.hibernate.cache.NoCacheProvider</value>
    </property>
    <property name="hibernate.show_sql">
        <value>true</value>
    </property>
    <property name="dialect">
        <value>${jdbc.dialect}</value>
    </property>
    <property name="connection.driver_class">
        <value>${jdbc.driverClassName}</value>
    </property>
    <property name="connection.url">
        <value>${jdbc.databaseurl}</value>
    </property>
    <property name="connection.username">
        <value>${jdbc.username}</value>
    </property>
    <property name="connection.password">
        <value>${jdbc.password}</value>
    </property>

    <property name="current_session_context_class">
        <value>thread</value>
    </property>
</bean>

<tx:annotation-driven transaction-manager="transactionManager" />

<bean id="transactionManager"
    class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>

May it come from my java file ?

the error is :

Invalid property 'transaction' of bean class [org.springframework.orm.hibernate4.LocalSessionFactoryBean]: Bean property 'transaction' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?

OLD CONF : Here is my problem : org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in ServletContext resource [/WEB-INF/spring-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getConnectionProvider()Lorg/hibernate/service/jdbc/connections/spi/ConnectionProvider

it seems Transaction manager can't initialize properly, don't know if it's relevant to my configuration

spring-servlet.xml :

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"
    p:packagesToScan="com.it" 
    p:dataSource-ref="ReferentielWebDevDataSource"
    />
<bean id="transactionManager"
    class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>

Dunno if it's come from my dataSource or something else. Thanks,

EDIT :

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="packagesToScan" value="net.form" />
    <property name="dataSource" ref="ReferentielWebDevDataSource"></property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.GenericDialect
            </prop>
            <prop key="hibernate.show_sql">true</prop>
        </props>
    </property>
    <property name="annotatedClasses">
        <list>
            <value>com.it.model.application</value>
        </list>
    </property>
</bean>

<bean id="transactionManager"
    class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>

and my data source :

<jee:jndi-lookup id="ReferentielWebDevDataSource" jndi-name="ReferentielWebDevDataSource" />

In my hibernate-cfg.xml i have this :

<hibernate-configuration>
<session-factory>
    <property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>
    <property name="connection.driver_class">oracle.jdbc.OracleDriver</property>
    <property name="connection.url">MYURL</property>
    <property name="connection.username">USERNAME</property>
    <property name="connection.password">PASSWORD</property>
    <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
    <property name="current_session_context_class">thread</property>
    <!-- Disable the second-level cache  -->
    <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
    <property name="hibernate.show_sql">true</property>

    <mapping class="com.it.model.application"/>
</session-factory>

</hibernate-configuration>

(with real url, username and password) I think it's all i got related to hibernate configuration and dataSource.

EDIT 2 Stack trace :

HTTP ERROR 503
Problem accessing /it-project/. Reason:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in ServletContext resource [/WEB-INF/spring-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getConnectionProvider()Lorg/hibernate/service/jdbc/connections/spi/ConnectionProvider;

Caused by:

org.eclipse.jetty.servlet.ServletHolder$1: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in ServletContext resource [/WEB-INF/spring-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getConnectionProvider()Lorg/hibernate/service/jdbc/connections/spi/ConnectionProvider;
    at org.eclipse.jetty.servlet.ServletHolder.makeUnavailable(ServletHolder.java:445)
    at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:498)
    at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:293)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:739)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:254)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1238)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:683)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:480)
    at org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:256)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:172)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
    at org.eclipse.jetty.server.Server.doStart(Server.java:275)
    at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:65)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:511)
    at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:364)
    at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:521)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in ServletContext resource [/WEB-INF/spring-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getConnectionProvider()Lorg/hibernate/service/jdbc/connections/spi/ConnectionProvider;
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1486)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
    at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:647)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:598)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:661)
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:517)
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:458)
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:138)
    at javax.servlet.GenericServlet.init(GenericServlet.java:241)
    at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:477)
    ... 42 more
Caused by: java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getConnectionProvider()Lorg/hibernate/service/jdbc/connections/spi/ConnectionProvider;
    at org.springframework.orm.hibernate4.SessionFactoryUtils.getDataSource(SessionFactoryUtils.java:90)
    at org.springframework.orm.hibernate4.HibernateTransactionManager.afterPropertiesSet(HibernateTransactionManager.java:252)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1545)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483)
    ... 59 more

Caused by:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in ServletContext resource [/WEB-INF/spring-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getConnectionProvider()Lorg/hibernate/service/jdbc/connections/spi/ConnectionProvider;
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1486)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
    at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:647)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:598)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:661)
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:517)
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:458)
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:138)
    at javax.servlet.GenericServlet.init(GenericServlet.java:241)
    at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:477)
    at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:293)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:739)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:254)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1238)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:683)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:480)
    at org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:256)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:172)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
    at org.eclipse.jetty.server.Server.doStart(Server.java:275)
    at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:65)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:511)
    at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:364)
    at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:521)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getConnectionProvider()Lorg/hibernate/service/jdbc/connections/spi/ConnectionProvider;
    at org.springframework.orm.hibernate4.SessionFactoryUtils.getDataSource(SessionFactoryUtils.java:90)
    at org.springframework.orm.hibernate4.HibernateTransactionManager.afterPropertiesSet(HibernateTransactionManager.java:252)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1545)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483)
    ... 59 more

Caused by:

java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getConnectionProvider()Lorg/hibernate/service/jdbc/connections/spi/ConnectionProvider;
    at org.springframework.orm.hibernate4.SessionFactoryUtils.getDataSource(SessionFactoryUtils.java:90)
    at org.springframework.orm.hibernate4.HibernateTransactionManager.afterPropertiesSet(HibernateTransactionManager.java:252)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1545)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
    at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:647)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:598)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:661)
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:517)
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:458)
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:138)
    at javax.servlet.GenericServlet.init(GenericServlet.java:241)
    at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:477)
    at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:293)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:739)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:254)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1238)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:683)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:480)
    at org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:256)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:172)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
    at org.eclipse.jetty.server.Server.doStart(Server.java:275)
    at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:65)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:511)
    at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:364)
    at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:521)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Coconut answered 7/5, 2013 at 10:52 Comment(1)
You don't need hibernate-cfg.xml configuration since you are declaring a bean. Move everything everything from that config to the spring config.Opine
M
12

You already noticed that your original problem (java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getConnectionProvider()Lorg/hibernate/service/jdbc/connections/spi/ConnectionProvider) disappears when you downgrade Hibernate to 4.1.7.Final.

This is due to compatibility issues in Spring with Hibernate versions 4.3.0.Beta1 that is reported under https://jira.springsource.org/browse/SPR-10839.

If you want to, you can create your own patch for this problem as follows:

  1. In your project, put the Hibernate version you want to use on your project's classpath (version 4.3.0.Beta1 or newer).

  2. From the package org.springframework.orm.hibernate4 in the spring-orm sources, copy the contents of the following source files to your project in their own package, E.g. to the package com.my.hibernate4.spring.fix: HibernateTransactionManager, SessionFactoryUtils, SpringFlushSynchronization, SpringSessionContext and SpringSessionSynchronization.

  3. Change the import in SpringSessionContext for class JtaPlatform from org.hibernate.service.jta.platform.spi.JtaPlatform to org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform

  4. Change the import in SessionFactoryUtils for class ConnectionProvider from org.hibernate.service.jdbc.connections.spi.ConnectionProvider to org.hibernate.engine.jdbc.connections.spi.ConnectionProvider

  5. Resolve all other import problems in your package com.my.hibernate4.spring.fix; refer to your own fixed versions in these five classes.

  6. In your hibernate configuration, add the hibernate property hibernate.current_session_context_class with the value of your fixed version of SpringSessionContext, E.g. com.my.hibernate4.spring.fix.SpringSessionContext

  7. In your spring configuration, configure your fixed HibernateTransactionManager as the transaction manager to use, E.g.:

    <bean id="transactionManager" class="com.my.hibernate4.spring.fix.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
    

This patch works for me, but I don't know if it solves all compatibility issues that my use case does not reveal.

Mugger answered 15/8, 2013 at 14:47 Comment(1)
With Spring 3.x you can use Hibernate all the way up to 4.2.xInteractive
S
2

I get this error with Hibernate 4.3.0.Beta1. A downgrade to 4.1.7.Final fixes the problem, although this is nothing but a workaround.

Saipan answered 9/5, 2013 at 15:31 Comment(0)
C
2

Spring context 4.0.6.RELEASE, released last july, solved my problem.

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-context</artifactId>
<version>4.0.6.RELEASE</version>

Cahilly answered 26/8, 2014 at 19:11 Comment(0)
H
1

Ok, here is a more in depth look at your config. Thanks for compiling it inot one bean so far. This makes it easier to analyze. ^^

There are a view thigns amiss:

For once you give the sessionFactory two configurations for the JDBC connection. Once in with the dataSource.

<property name="dataSource" ref="ReferentielWebDevDataSource" />

And once by setting the properties in the sessionFactory:

<property name="connection.driver_class">
        <value>${jdbc.driverClassName}</value>
    </property>
    <property name="connection.url">
        <value>${jdbc.databaseurl}</value>
    </property>
    <property name="connection.username">
        <value>${jdbc.username}</value>
    </property>
    <property name="connection.password">
        <value>${jdbc.password}</value>
    </property>

Only one of this is needed, since each will trigger a different ConnectionProvider to be used by Hibernate. (I don't know if this is necessarily a problem or how it is prioritized, but still it is a possible point of failure)

Then there is the disabling of the second cache and the setting of the current context, though this might have its reasons, for getting it started I would keep it as simple as possible and leave them out.

And finally the Transaction Manager set in the properties is not necessary in this setup:

<property name="transaction.factory_class">
            <value>org.hibernate.transaction.JDBCTransactionFactory</value>
        </property>

Since you have the HibernatTransactionManager bean:

<bean id="transactionManager"
        class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>

So again we have two configurations fighting. The way the Spring Hibernate Configuration works is the DataSource is injected into the sessionFactory and the sessionFactory into the TransactionManager. (I might try to look up the reference on this one if necessary)

Ok and to end it all here is my take on simplifying the config:

    <bean id="sessionFactory"
            class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
            <property name="dataSource" ref="ReferentielWebDevDataSource" />

            <property name="hibernate.show_sql">
                <value>true</value>
            </property>
            <property name="dialect">
                <value>${jdbc.dialect}</value>
            </property>
    <property name="annotatedClasses">
        <list>
            <value>com.it.model.application</value>
        </list>
    </property>
        </bean>

    <tx:annotation-driven transaction-manager="transactionManager" />
   <bean id="transactionManager"
        class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>
Hialeah answered 7/5, 2013 at 18:36 Comment(0)
H
0

Moving this answer over from the other post:

Where do you hand the hibernate.dialect to the sessionFactory? For a more complete view it would be helpful to see all parts of the configuration going into hibernate. So can you post your DataSource. But what I can say so far that the hibernate.dialect is a property that is mandatory to set. Besides the DataSource it is pretty much the only really essential configuration:

<property name="hibernate.dialect">org.hibernate.dialect.GenericDialect</property>

Try adding this to your sessionFactory Bean.

Hialeah answered 7/5, 2013 at 11:12 Comment(11)
With the genericDialect, the problem stay unchanged. SadlyCoconut
even worst, it seems genericDialect is unknown : Unable to resolve name [org.hibernate.dialect.GenericDialect] as strategy [org.hibernate.dialect.Dialect]Coconut
No idea ? i tried to use oracle10gDialect but its not workingCoconut
You have to look up the dialect corresponding to the DB you use. This link provides a list with maping DB to dialect: javabeat.net/2013/02/list-of-hibernate-sql-dialectsHialeah
Assuming from your last comment that you use Oracle 10g it would be org.hibernate.dialect.Oracle9DialectHialeah
i thought oracle9Dialect was deprecated. i saw somewhere Oracle9iDialect or Oracle10gDialect should be used. but i tried, oracle9D, it's still fail. i added full stack trace to my postCoconut
Ok, this is starting to look a bit more tricky. Right now I don't have enough time to look at this in more detail, will try to elaborate on this later this evening. Got two things right of the bat: 1. Please post your "ReferentielWebDevDataSource" bean. 2. You could try looking into the fact that you currently are setting up two different sessionFactories (one under Spring control and one pure hibernate). You should start looking in this direction since this might confuse Hibernate.Hialeah
its ok, i will kill myself :/ getting mad :) thanks you for watching.Coconut
i pretty sure my datasource is correct, i picked it from an old project (not mine). <jee:jndi-lookup id="ReferentielWebDevDataSource" jndi-name="ReferentielWebDevDataSource" /> Should i delete hibernate-cfg.xml and put all config into the bean declaration in the spring-servlet.xml ?Coconut
Yes, that is probably the way to go since you most likely are going to autowire the sessionFactory into your DAOs?Hialeah
@Coconut Have you been able to resolve this issue? If yes you should document the solution to help people which are having this issue in the future.Hialeah

© 2022 - 2024 — McMap. All rights reserved.