uhrand
Messages postés491Date d'inscriptionsamedi 20 mai 2006StatutMembreDernière intervention15 juillet 20129 12 juil. 2009 à 11:43
Tu peus essayer ceci:
décomprime le zip et ajoute le fichier jdom-1.1/build/jdom.jar au projet:
File | Project Properties ... | Categories: Libraries | onglet Compile | Add JAR/Folder | choisir le fichier jdom-1.1/build/jdom.jar
seeif
Messages postés22Date d'inscriptionjeudi 9 juillet 2009StatutMembreDernière intervention19 août 2009 15 juil. 2009 à 19:39
bjr uhrand j'ai rencontré un probleme le voici :
j'utilise la technologie ejb3 pour pour creer une application dont le role d'inserer des données dans une base de données (mysql)
j'ai crée une entity bean qui s'appelle Vol pour la table VOL:
/**
*
* @author Administrateur
*/
@Entity
@Table(name = "vol")
@NamedQueries({@NamedQuery(name "Vol.findAll", query "SELECT v FROM Vol v"), @NamedQuery(name = "Vol.findById", query = "SELECT v FROM Vol v WHERE v.id = :id"), @NamedQuery(name = "Vol.findByDepart", query = "SELECT v FROM Vol v WHERE v.depart = :depart"), @NamedQuery(name = "Vol.findByDestination", query = "SELECT v FROM Vol v WHERE v.destination = :destination"), @NamedQuery(name = "Vol.findByHeure", query = "SELECT v FROM Vol v WHERE v.heure = :heure"), @NamedQuery(name = "Vol.findByDatevol", query = "SELECT v FROM Vol v WHERE v.datevol = :datevol"), @NamedQuery(name = "Vol.findByCompagnie", query = "SELECT v FROM Vol v WHERE v.compagnie = :compagnie"), @NamedQuery(name = "Vol.findByNVol", query = "SELECT v FROM Vol v WHERE v.nVol = :nVol"), @NamedQuery(name = "Vol.findByCommentaire", query = "SELECT v FROM Vol v WHERE v.commentaire = :commentaire")})
public class Vol implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "id")
private Short id;
@Column(name = "depart")
private String depart;
@Column(name = "destination")
private String destination;
@Column(name = "heure")
private String heure;
@Column(name = "datevol")
private String datevol;
@Column(name = "compagnie")
private String compagnie;
@Column(name = "n°vol")
private Integer nVol;
@Column(name = "commentaire")
private String commentaire;
public Vol() {
}
public Vol(Short id) {
this.id = id;
}
public Short getId() {
return id;
}
public void setId(Short id) {
this.id = id;
}
public String getDepart() {
return depart;
}
public void setDepart(String depart) {
this.depart = depart;
}
public String getDestination() {
return destination;
}
public void setDestination(String destination) {
this.destination = destination;
}
public String getHeure() {
return heure;
}
public void setHeure(String heure) {
this.heure = heure;
}
public String getDatevol() {
return datevol;
}
public void setDatevol(String datevol) {
this.datevol = datevol;
}
public String getCompagnie() {
return compagnie;
}
public void setCompagnie(String compagnie) {
this.compagnie = compagnie;
}
public Integer getNVol() {
return nVol;
}
public void setNVol(Integer nVol) {
this.nVol = nVol;
}
public String getCommentaire() {
return commentaire;
}
public void setCommentaire(String commentaire) {
this.commentaire = commentaire;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.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 Vol)) {
return false;
}
Vol other = (Vol) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "ejb.Vol[id=" + id + "]";
}
}
puis j'ai créer un bean qui s'apelle facadeVol qui sert à realiser les actions de persistences voici le code :
@Stateless
public class VolFacade implements VolFacadeLocal {
@PersistenceContext
private static EntityManager em;
@EJB
public Vol vol;
public void create(Vol vol) {
em.getTransaction().begin();
em.persist(vol);
em.getTransaction().commit();
}
public void edit(Vol vol) {
em.getTransaction().begin();
em.merge(vol);
em.getTransaction().commit();
}
public void remove(Vol vol) {
em.getTransaction().begin();
em.remove(em.merge(vol));
em.getTransaction().commit();
}
public Vol find(Object id) {
return em.find(Vol.class, id);
}
public List<Vol> findAll() {
return em.createQuery("select object(o) from Vol as o").getResultList();
}
public static void main(String[] args){
Vol voll = new Vol();
voll.setDepart("dddddd");
voll.setDestination("fgfdd");
VolFacade vf =new VolFacade();
vf.create(voll);
}
}
mais le probleme il ya une erreur d'execution de cette classe : Exception in thread "main" java.lang.NullPointerException
au niveau de la methode create()
svp aidez moi je suis coincé il ya 3 jours et j'ai plus de temps pour terminer l'application
merci d'avance
seeif
Messages postés22Date d'inscriptionjeudi 9 juillet 2009StatutMembreDernière intervention19 août 2009 15 juil. 2009 à 21:31
salut,
je suis entrain de développer une application jee (ejb3) pour inserer quelque données dans une base de données
voici la classe VolFacade responsable d'insertion de données et qui utilise l'entity bean Vol
sachant que j'ai crée une unité de persistence "OACA-ejbPU" dont le provider est toplink voici le fichier de configuration persistence.xml:
-
-
oracle.toplink.essentials.PersistenceProvider
voldb
false
-
mais il ya une erreur d'execution de la classe VolFacade voici le code de l'erreur:
run-main:
15 juil. 2009 20:27:44 ejb.VolFacade main
GRAVE: null
javax.persistence.PersistenceException: No resource files named META-INF/services/javax.persistence.spi.PersistenceProvider were found. Please make sure that the persistence provider jar file is in your classpath.
at javax.persistence.Persistence.findAllProviders(Persistence.java:167)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:103)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
at ejb.VolFacade.getEntityManager(VolFacade.java:33)
at ejb.VolFacade.create(VolFacade.java:42)
at ejb.VolFacade.main(VolFacade.java:59)
BUILD SUCCESSFUL (total time: 0 seconds)