JEE avec JPA, JSF et Web Service
Bonjour les gars,
merci de votre soutien.
En fait je débute avec les web Services et je me bloque à une message d'erreur que je n'arrive pas résoudre alors que tous les fichiers sont ok:
Merci de voir mes fichiers:
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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
| /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.drake.gespro.entities;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
/**
*
* @author Khalifa NDIAYE
*/
@Entity
@Table(name = "type", catalog = "gespro", schema = "")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Type.findAll", query = "SELECT t FROM Type t"),
@NamedQuery(name = "Type.findByIdType", query = "SELECT t FROM Type t WHERE t.idType = :idType"),
@NamedQuery(name = "Type.findByNom", query = "SELECT t FROM Type t WHERE t.nom = :nom"),
@NamedQuery(name = "Type.findByActive", query = "SELECT t FROM Type t WHERE t.active = :active")})
public class Type implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "idType")
private Integer idType;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 255)
@Column(name = "nom")
private String nom;
@Basic(optional = false)
@NotNull
@Lob
@Size(min = 1, max = 65535)
@Column(name = "description")
private String description;
@Basic(optional = false)
@NotNull
@Column(name = "active")
private char active;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "idType", fetch = FetchType.EAGER)
private List<Projet> projetList;
public Type() {
}
public Type(Integer idType) {
this.idType = idType;
}
public Type(Integer idType, String nom, String description, char active) {
this.idType = idType;
this.nom = nom;
this.description = description;
this.active = active;
}
public Type(String nom, String description, char active) {
this.nom = nom;
this.description = description;
this.active = active;
}
public Integer getIdType() {
return idType;
}
public void setIdType(Integer idType) {
this.idType = idType;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public char getActive() {
return active;
}
public void setActive(char active) {
this.active = active;
}
@XmlTransient
public List<Projet> getProjetList() {
return projetList;
}
public void setProjetList(List<Projet> projetList) {
this.projetList = projetList;
}
@Override
public int hashCode() {
int hash = 0;
hash += (idType != null ? idType.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Type)) {
return false;
}
Type other = (Type) object;
if ((this.idType == null && other.idType != null) || (this.idType != null && !this.idType.equals(other.idType))) {
return false;
}
return true;
}
@Override
public String toString() {
return "com.drake.gespro.entities.Type[ idType=" + idType + " ]";
}
} |
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
| /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.drake.gespro.dao;
import com.drake.gespro.entities.Type;
import java.util.List;
import javax.ejb.Local;
/**
*
* @author Khalifa NDIAYE
*/
@Local
public interface ITypeLocal {
public void add(Type t);
public void edit(Type t);
public void delete(int id);
public List<Type> findAlls();
public Type findType(int id);
} |
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
| /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.drake.gespro.dao;
import com.drake.gespro.entities.Type;
import java.util.List;
import javax.ejb.Remote;
/**
*
* @author Khalifa NDIAYE
*/
@Remote
public interface ITypeRemote {
public void add(Type t);
public void edit(Type t);
public void delete(int id);
public List<Type> findAlls();
public Type findType(int id);
} |
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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.drake.gespro.dao.impl;
import com.drake.gespro.dao.ITypeLocal;
import com.drake.gespro.dao.ITypeRemote;
import com.drake.gespro.entities.Type;
import java.util.List;
import javax.annotation.PreDestroy;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
/**
*
* @author Khalifa NDIAYE
*/
@Stateless(name="TP")
public class TypeDaoImpl implements ITypeLocal,ITypeRemote{
@PersistenceContext(unitName = "GesPro-ejbPU")
private EntityManager em;
@Override
public void add(Type t) {
em.persist(t);
}
@Override
public void edit(Type t) {
em.merge(t);
}
@Override
public void delete(int id) {
em.remove(findType(id));
}
@Override
public List<Type> findAlls() {
Query q = em.createQuery("Type.findAll");
List l = q.getResultList();
return l;
}
@Override
public Type findType(int id) {
Type t = em.find(Type.class, id);
if(t==null) throw new RuntimeException("Type introuvable");
return t;
}
public void persist(Object object) {
em.persist(object);
}
@PreDestroy
public void destruct(){
em.close();
}
} |
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
| /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.drake.gespro.service;
import com.drake.gespro.dao.ITypeLocal;
import com.drake.gespro.entities.Type;
import java.io.Serializable;
import java.util.List;
import javax.annotation.PreDestroy;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
/**
*
* @author Khalifa NDIAYE
*/
@Stateless
@WebService
public class TypeService {
@EJB
private ITypeLocal itl;
@WebMethod
public void addType(@WebParam(name = "nom")String nom, @WebParam(name = "description")String description){
Type t = new Type(nom, description,'0');
itl.add(t);
}
@WebMethod
public List<Type> listTypes(){
return itl.findAlls();
}
} |
Code:
1 2 3 4 5 6 7 8 9
| <?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="GesPro-ejbPU" transaction-type="JTA">
<jta-data-source>gestion</jta-data-source>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
</properties>
</persistence-unit>
</persistence> |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>
<jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="mysql_gespro_rootPool_1" non-transactional-connections="false" pool-resize-quantity="2" res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
<property name="serverName" value="localhost"/>
<property name="portNumber" value="3306"/>
<property name="databaseName" value="gespro"/>
<property name="User" value="root"/>
<property name="Password" value="passer"/>
<property name="URL" value="jdbc:mysql://localhost:3306/gespro"/>
<property name="driverClass" value="com.mysql.jdbc.Driver"/>
</jdbc-connection-pool>
<jdbc-resource enabled="true" jndi-name="gestion" object-type="user" pool-name="mysql_gespro_rootPool_1"/>
</resources> |