spring - Error creating bean with name 'dao': Injection of persistence dependencies failed -


i dont know ahy got error

main

 ibanquemetier metier;         classpathxmlapplicationcontext context         = new classpathxmlapplicationcontext(                 new string[]{"applicationcontext.xml"});     metier = (ibanquemetier) context.getbean("metier");     metier.addclient(new client("client1","adress1"));  

banquedaoimpl

 public class banquedaoimpl implements ibanquedao {      @persistencecontext     private entitymanager em;      @override     public client addclient(client c) {         // j'enregistre le client c et je le retourne         em.persist(c);         return c;     } .... 

and 1rst error :

 info : org.springframework.context.support.classpathxmlapplicationcontext - refreshing org.springframework.context.support.classpathxmlapplicationcontext@1be847c: startup date [fri feb 05 14:22:40 cet 2016]; root of context hierarchy info : org.springframework.beans.factory.xml.xmlbeandefinitionreader - loading xml bean definitions class path resource [applicationcontext.xml] info : org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor - jsr-330 'javax.inject.inject' annotation found , supported autowiring info : org.springframework.beans.factory.support.defaultlistablebeanfactory - pre-instantiating singletons in org.springframework.beans.factory.support.defaultlistablebeanfactory@1846619: defining beans [dao,metier,datasource,persistenceunitmanager,entitymanagerfactory,transactionmanager,org.springframework.aop.config.internalautoproxycreator,org.springframework.transaction.annotation.annotationtransactionattributesource#0,org.springframework.transaction.interceptor.transactioninterceptor#0,org.springframework.transaction.config.internaltransactionadvisor,org.springframework.context.annotation.internalconfigurationannotationprocessor,org.springframework.context.annotation.internalautowiredannotationprocessor,org.springframework.context.annotation.internalrequiredannotationprocessor,org.springframework.context.annotation.internalcommonannotationprocessor,org.springframework.context.annotation.internalpersistenceannotationprocessor,org.springframework.context.annotation.configurationclasspostprocessor$importawarebeanpostprocessor#0]; root of factory hierarchy warn : org.hibernate.ejb.hibernatepersistence - hhh015016: encountered deprecated javax.persistence.spi.persistenceprovider [org.hibernate.ejb.hibernatepersistence]; use [org.hibernate.jpa.hibernatepersistenceprovider] instead. info : org.springframework.beans.factory.support.defaultlistablebeanfactory - destroying singletons in org.springframework.beans.factory.support.defaultlistablebeanfactory@1846619: defining beans [dao,metier,datasource,persistenceunitmanager,entitymanagerfactory,transactionmanager,org.springframework.aop.config.internalautoproxycreator,org.springframework.transaction.annotation.annotationtransactionattributesource#0,org.springframework.transaction.interceptor.transactioninterceptor#0,org.springframework.transaction.config.internaltransactionadvisor,org.springframework.context.annotation.internalconfigurationannotationprocessor,org.springframework.context.annotation.internalautowiredannotationprocessor,org.springframework.context.annotation.internalrequiredannotationprocessor,org.springframework.context.annotation.internalcommonannotationprocessor,org.springframework.context.annotation.internalpersistenceannotationprocessor,org.springframework.context.annotation.configurationclasspostprocessor$importawarebeanpostprocessor#0]; root of factory hierarchy exception in thread "main" org.springframework.beans.factory.beancreationexception: error creating bean name 'dao': injection of persistence dependencies failed; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'entitymanagerfactory' defined in class path resource [applicationcontext.xml]: invocation of init method failed; nested exception java.lang.nosuchmethoderror: org.hibernate.annotations.common.reflection.java.javareflectionmanager.injectclassloaderdelegate(lorg/hibernate/annotations/common/reflection/classloaderdelegate;)v     @ org.springframework.orm.jpa.support.persistenceannotationbeanpostprocessor.postprocesspropertyvalues(persistenceannotationbeanpostprocessor.java:342)     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.populatebean(abstractautowirecapablebeanfactory.java:1106)     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:517)     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:456)     @ org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:294)     @ org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:225)     @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:291)     @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:193)     @ org.springframework.beans.factory.support.defaultlistablebeanfactory.preinstantiatesingletons(defaultlistablebeanfactory.java:585)     @ org.springframework.context.support.abstractapplicationcontext.finishbeanfactoryinitialization(abstractapplicationcontext.java:913)     @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:464)     @ org.springframework.context.support.classpathxmlapplicationcontext.(classpathxmlapplicationcontext.java:139)     @ org.springframework.context.support.classpathxmlapplicationcontext.(classpathxmlapplicationcontext.java:93)     @ toto.tata.titi.test.test.main(test.java:14) caused by: org.springframework.beans.factory.beancreationexception: error creating bean name 'entitymanagerfactory' defined in class path resource [applicationcontext.xml]: invocation of init method failed; nested exception java.lang.nosuchmethoderror: org.hibernate.annotations.common.reflection.java.javareflectionmanager.injectclassloaderdelegate(lorg/hibernate/annotations/common/reflection/classloaderdelegate;)v     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory.java:1455)     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:519)     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:456)     @ org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:294)     @ org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:225)     @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:291)     @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:193)     @ org.springframework.orm.jpa.support.persistenceannotationbeanpostprocessor.finddefaultentitymanagerfactory(persistenceannotationbeanpostprocessor.java:530)     @ org.springframework.orm.jpa.support.persistenceannotationbeanpostprocessor.findentitymanagerfactory(persistenceannotationbeanpostprocessor.java:496)     @ org.springframework.orm.jpa.support.persistenceannotationbeanpostprocessor$persistenceelement.resolveentitymanager(persistenceannotationbeanpostprocessor.java:657)     @ org.springframework.orm.jpa.support.persistenceannotationbeanpostprocessor$persistenceelement.getresourcetoinject(persistenceannotationbeanpostprocessor.java:630)     @ org.springframework.beans.factory.annotation.injectionmetadata$injectedelement.inject(injectionmetadata.java:150)     @ org.springframework.beans.factory.annotation.injectionmetadata.inject(injectionmetadata.java:87)     @ org.springframework.orm.jpa.support.persistenceannotationbeanpostprocessor.postprocesspropertyvalues(persistenceannotationbeanpostprocessor.java:339)     ... 13 more caused by: java.lang.nosuchmethoderror: org.hibernate.annotations.common.reflection.java.javareflectionmanager.injectclassloaderdelegate(lorg/hibernate/annotations/common/reflection/classloaderdelegate;)v     @ org.hibernate.boot.internal.metadatabuilderimpl$metadatabuildingoptionsimpl.generatedefaultreflectionmanager(metadatabuilderimpl.java:737)     @ org.hibernate.boot.internal.metadatabuilderimpl$metadatabuildingoptionsimpl.(metadatabuilderimpl.java:709)     @ org.hibernate.boot.internal.metadatabuilderimpl.(metadatabuilderimpl.java:127)     @ org.hibernate.boot.metadatasources.getmetadatabuilder(metadatasources.java:135)     @ org.hibernate.jpa.boot.internal.entitymanagerfactorybuilderimpl.(entitymanagerfactorybuilderimpl.java:185)     @ org.hibernate.jpa.boot.spi.bootstrap.getentitymanagerfactorybuilder(bootstrap.java:34)     @ org.hibernate.jpa.hibernatepersistenceprovider.getentitymanagerfactorybuilder(hibernatepersistenceprovider.java:165)     @ org.hibernate.jpa.hibernatepersistenceprovider.getentitymanagerfactorybuilder(hibernatepersistenceprovider.java:160)     @ org.hibernate.jpa.hibernatepersistenceprovider.createcontainerentitymanagerfactory(hibernatepersistenceprovider.java:135)     @ org.hibernate.ejb.hibernatepersistence.createcontainerentitymanagerfactory(hibernatepersistence.java:50)     @ org.springframework.orm.jpa.localcontainerentitymanagerfactorybean.createnativeentitymanagerfactory(localcontainerentitymanagerfactorybean.java:268)     @ org.springframework.orm.jpa.abstractentitymanagerfactorybean.afterpropertiesset(abstractentitymanagerfactorybean.java:310)     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.invokeinitmethods(abstractautowirecapablebeanfactory.java:1514)     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory.java:1452)     ... 26 more  

applicationcontext.xml

<beans xmlns="http://www.springframework.org/schema/beans"  	xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"  	xmlns:tx="http://www.springframework.org/schema/tx"  	xmlns:context="http://www.springframework.org/schema/context"  	xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd  						http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd  						  http://www.springframework.org/schema/context         						http://www.springframework.org/schema/context/spring-context-2.5.xsd">    	  	<bean id="dao" class="toto.tata.titi.dao.banquedaoimpl" />  	<bean id="metier" class="toto.tata.titi.metier.banquemetierimpl">  		<!-- injection de dependance -->  		<!-- on associe objet dao objet metier -->  		<property name="dao" ref="dao"></property>  	</bean>    	  	<bean id="datasource"  		class="org.springframework.jdbc.datasource.drivermanagerdatasource">  		<property name="driverclassname" value="com.mysql.jdbc.driver" />  		<property name="url" value="jdbc:mysql://localhost:3306/banque5" />  		<property name="username" value="root" />  		<property name="password" value="" />  	</bean>    	<bean id="persistenceunitmanager"  		class="org.springframework.orm.jpa.persistenceunit.defaultpersistenceunitmanager">  		<property name="persistencexmllocations">  			<list>  				<value>persistence.xml</value>  			</list>  		</property>  		<property name="defaultdatasource" ref="datasource"></property>  	</bean>    	<bean id="entitymanagerfactory"  		class="org.springframework.orm.jpa.localcontainerentitymanagerfactorybean">  		<property name="persistenceunitmanager" ref="persistenceunitmanager"></property>  		<property name="persistenceunitname" value="my_p_u"></property>  	</bean>      	<bean id="transactionmanager" class="org.springframework.orm.jpa.jpatransactionmanager">  	    <property name="entitymanagerfactory" ref="entitymanagerfactory"></property>  	</bean>  	  	<tx:annotation-driven transaction-manager="transactionmanager"/>  	<context:annotation-config></context:annotation-config>  </beans>

persistence.xml

<?xml version="1.0" encoding="utf-8"?>  <persistence xmlns="http://java.sun.com/xml/ns/persistence"  	xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"  	xsi:schemalocation="http://java.sun.com/xml/  ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">  	<persistence-unit name="my_p_u" transaction-type="resource_local">          		<provider>org.hibernate.ejb.hibernatepersistence</provider>  		<properties>              			<property name="hibernate.show_sql" value="true" />  			<property name="hibernate.hbm2ddl.auto" value="update" />  		</properties>  	</persistence-unit>  </persistence>

in pom.xml change version of hibernate-jpa 2.0 2.1

    <dependency>         <groupid>org.hibernate.javax.persistence</groupid>         <artifactid>hibernate-jpa-2.1-api</artifactid>         <version>1.0.0.final-redhat-1</version>     </dependency> 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -