Target Unreachable, identifier '' resolved to null
Résolu
montisero
Messages postés
115
Statut
Membre
-
montisero Messages postés 115 Statut Membre -
montisero Messages postés 115 Statut Membre -
Bonjour ,
j'utlise jsf2.1 hibernate 4 : mon class User est généré automatiquement puisque j'utilise hibernate reverse engineering mais j'obtient toujours cette erreur :

Class User :
hibernateUtil
hibernatecfg.xml
Faces-config
web.xml
UserDao
UserBean
page.xhtml
j'utlise jsf2.1 hibernate 4 : mon class User est généré automatiquement puisque j'utilise hibernate reverse engineering mais j'obtient toujours cette erreur :

Class User :
package entities; // Generated Feb 19, 2015 5:19:15 PM by Hibernate Tools 3.4.0.CR1 import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; /** * User generated by hbm2java */ @Entity @Table(name = "user", catalog = "ocs") public class User implements java.io.Serializable { /** * */ private static final long serialVersionUID = 1L; private String matricule; private String nom; private String prenom; private String equipe; private Integer numTel; private String role; private String photo; private String mail; private String password; public User() { } public User(String matricule) { this.matricule = matricule; } public User(String matricule, String nom, String prenom, String equipe, Integer numTel, String role, String photo, String mail, String password) { this.matricule = matricule; this.nom = nom; this.prenom = prenom; this.equipe = equipe; this.numTel = numTel; this.role = role; this.photo = photo; this.mail = mail; this.password = password; } @Id @Column(name = "matricule", unique = true, nullable = false, length = 45) public String getMatricule() { return this.matricule; } public void setMatricule(String matricule) { this.matricule = matricule; } @Column(name = "nom", length = 250) public String getNom() { return this.nom; } public void setNom(String nom) { this.nom = nom; } @Column(name = "prenom", length = 250) public String getPrenom() { return this.prenom; } public void setPrenom(String prenom) { this.prenom = prenom; } @Column(name = "equipe", length = 250) public String getEquipe() { return this.equipe; } public void setEquipe(String equipe) { this.equipe = equipe; } @Column(name = "num_tel") public Integer getNumTel() { return this.numTel; } public void setNumTel(Integer numTel) { this.numTel = numTel; } @Column(name = "role", length = 250) public String getRole() { return this.role; } public void setRole(String role) { this.role = role; } @Column(name = "photo", length = 250) public String getPhoto() { return this.photo; } public void setPhoto(String photo) { this.photo = photo; } @Column(name = "mail", length = 250) public String getMail() { return this.mail; } public void setMail(String mail) { this.mail = mail; } @Column(name = "password", length = 250) public String getPassword() { return this.password; } public void setPassword(String password) { this.password = password; } }
hibernateUtil
package sungardUtil ; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; public class HibernateUtil { private static final SessionFactory sessionFactory=buildSessionFactory(); public static SessionFactory buildSessionFactory(){ try { return new Configuration().configure().buildSessionFactory(); } catch (Throwable ex) { System.err.println("Initial SessionFactory creation failed." + ex); throw new ExceptionInInitializerError(ex); } } public static SessionFactory getSessionFactory() { return sessionFactory; } }
hibernatecfg.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory name="SessionFactory"> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/ocs</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <property name="hibernate.current_session_context_class">thread</property> <mapping class="entities.User"/> </session-factory> </hibernate-configuration>
Faces-config
<?xml version="1.0" encoding="UTF-8"?> <faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd" version="2.2"> </faces-config>
web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>Sungard.cmdb.imp</display-name> <session-config> <session-timeout>30</session-timeout> </session-config> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.sungard</url-pattern> </servlet-mapping> </web-app>
UserDao
package model; import org.hibernate.Query; import org.hibernate.Session; import sungardUtil.HibernateUtil; import entities.User; public class UserDAO { private Session session ; public User authenticate (User user) throws Exception { User us = null; try { session = HibernateUtil.getSessionFactory().openSession(); String hql = "FROM User WHERE mail = '" + user.getMail() + "' and password = '" + user.getPassword() + "'"; Query query = session.createQuery(hql); if(!query.list().isEmpty()){ us = (User) query.list().get(0); } } catch(Exception e) { throw e ; } return us ; } }
UserBean
package controller; import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; import javax.faces.context.FacesContext; import model.UserDAO; import entities.User; @ManagedBean (name="monta") @SessionScoped public class UserController { public UserController() { // TODO Auto-generated constructor stub } private User user = new User(); public User getUser() { return user; } public void setUser(User user) { this.user = user; } public String authenticate () throws Exception { UserDAO userDAO = new UserDAO(); User us ; String resultat ; try { us=userDAO.authenticate(this.user); if (us != null){ FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("user", us); resultat = "exist"; } else { resultat = "error"; } } catch (Exception e) { throw e; } return resultat; } }
page.xhtml
<!DOCTYPE HTML> <html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" > <h:head> </h:head> <body> <h:form> <h1>bbbbbb</h1> <h:message/> <h:panelGrid columns ="2"> <h:outputLabel value ="xxx"/> <h:inputText value ="#{monta.user.mail}"/> <h:outputLabel value ="xvvx"/> <h:inputText value ="#{monta.user.password}"/> <h:commandButton value ="log" action="#{monta.authenticate()}"/> </h:panelGrid> </h:form> </body> </html>
A voir également:
- Bus number 0, target id 0, lun 0
- Remettre a 0 un pc - Guide
- Numéro de téléphone excel 0 - Guide
- Différent de 0 excel ✓ - Forum Excel
- Comment faire un 0 barré sur téléphone - Forum iPhone
- Tous les code possible de 0 à 9 (4 chiffres ) liste - Forum Jeux vidéo
1 réponse
Bonjour,
Comme indiqué dans ta précédente discussion, JSF 2.1 est une spécification de Java EE 6 et JPA 2.1 une spécification de Java EE 7, je te conseillerais de passer sur du Java SE 7 (ou 8 si ton serveur le supporte).
Comme indiqué dans ta précédente discussion, JSF 2.1 est une spécification de Java EE 6 et JPA 2.1 une spécification de Java EE 7, je te conseillerais de passer sur du Java SE 7 (ou 8 si ton serveur le supporte).
java1.6 ; jsf 2.1 et jpa 2.0 ( sachant que jpa n'est pas cocher )