Error creating bean with name 'sessionFactory' (hibernate-context.xml)
S'il vous plait, je prépare mon PFE et je voudrais opter pour la solution hibernate-spring, après la préparation de ma classe et de la DAO je voudrai tester le bon fonctionnement de mes méthode mais apparament, ça ne passe pas. Le message est :
Citation:
"Error creating bean with name 'sessionFactory' defined in class path resource [hibernate-context.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]"
Le fichier hibernate-context.xml :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| <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"
xsi:schemaLocation="http://www.springframework.org/schema/beans <a href="http://www.springframework.org/schema/beans/spring-beans-2.5.xsd" target="_blank">http://www.springframework.org/schem...-beans-2.5.xsd</a> <a href="http://www.springframework.org/schema/tx" target="_blank">http://www.springframework.org/schema/tx</a> <a href="http://www.springframework.org/schema/tx/spring-tx-2.5.xsd" target="_blank">http://www.springframework.org/schem...ing-tx-2.5.xsd</a> <a href="http://www.springframework.org/schema/aop" target="_blank">http://www.springframework.org/schema/aop</a> http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
<bean id="personneDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/bijousenligne" />
<property name="username" value="root" />
<property name="password" value="1234" />
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="personneDataSource" />
<property name="annotatedClasses">
<list>
<value>POJO.Client</value>
<value>POJO.Adresse</value>
<value>POJO.Article</value>
<value>POJO.SousGamme</value>
<value>POJO.Gamme</value>
<value>POJO.Commande</value>
<value>POJO.RefLongueur</value>
<value>POJO.RefCouleur</value>
<value>POJO.RefMarque</value>
<value>POJO.RefMetal</value>
<value>POJO.RefPierre</value>
<value>POJO.LigneCommande</value>
<value>POJO.Photo</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="clientDaoImpl" class="packageClient.ClentDaoImpl">
</bean>
</beans> |
La classe ADO est :
Code:
1 2 3 4 5 6 7 8 9
| public class ClientDaoImpl implements IClientDao{
@Resource(name="sessionFactory")
private SessionFactory sessionFactory;
@Transactional(readOnly = true)
public void saveClient(Client client) {
Session session = sessionFactory.getCurrentSession(); // Save
session.save(client);
} |
Le main est :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| public static void main(String[] args) {
ApplicationContext ac= new ClassPathXmlApplicationContext("hibernate-context.xml");
IClientDao cd=(ClientDaoImpl) ac.getBean("clientDaoImpl");
//System.out.println(h.countville());
Client c = new Client();
c.setEtat("a");
c.setLogin("AAA");
c.setTel(12345);
c.setMail("AAAAAA");
c.setPwd("AAAAA");
c.setNom("aaa");
c.setPrenom("IIII");
cd.saveClient(c);
System.out.println("Operation reussi");
} |
Merci d'avance.