IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Java Discussion :

javax.ejb.EJBException: java.lang.IllegalArgumentException Exception


Sujet :

Java

Vue hybride

he lene javax.ejb.EJBException:... 24/11/2016, 22h08
tchize_ tu peux mettre ta stacktrace... 25/11/2016, 00h28
Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Femme Profil pro
    Administrateur de base de données
    Inscrit en
    Août 2016
    Messages
    22
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Haute Vienne (Limousin)

    Informations professionnelles :
    Activité : Administrateur de base de données
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Août 2016
    Messages : 22
    Par défaut javax.ejb.EJBException: java.lang.IllegalArgumentException Exception
    Bonjour,
    je suis entrain d'ecrire deux ejb, l'un pour stocker le produit et l'autre pour stocker l'entreprise.
    L'objectif est de relier Entity entreprise et Entity Produit.
    Le principe de fonctionnement est décrit comme suit :
    inserer dans produit si seulement s'il existe deja dans entreprise(une sorte de clé etrangère)
    mais j'ai cette exception :javax.ejb.EJBException: java.lang.IllegalArgumentException: Unknown entity: entreprise.Entreprise2

    Je ne comprends pas le probleme, pourtant j'ai importe l'ejb entreprise dans l'ejb entity
    J'ai utilise eclipse kelper, jboss 4.2 et jre1.7.
    Merci pour toute aide.
    Voici le code
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    package entity;
     
    import javax.ejb.Remote;
     
    @Remote
    public interface IProduit4 {
    	void ajouter(Produit4 p);
     
    }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    package entity;
     
    import java.io.Serializable;
     
    import javax.persistence.Entity;
    import javax.persistence.Id;
     
    @Entity
    public class Produit4 implements Serializable{
    @Id
    String id;
    String lib;
    int quantite;
    String ref;
    public String getId() {
    	return id;
    }
    public void setId(String id) {
    	this.id = id;
    }
    public String getLib() {
    	return lib;
    }
    public void setLib(String lib) {
    	this.lib = lib;
    }
    public int getQuantite() {
    	return quantite;
    }
    public void setQuantite(int quantite) {
    	this.quantite = quantite;
    }
    public String getRef() {
    	return ref;
    }
    public void setRef(String ref) {
    	this.ref = ref;
    }
    @Override
    public String toString() {
    	return "Produit [id=" + id + ", lib=" + lib + ", quantite=" + quantite
    			+ ", ref=" + ref + "]";
    }
    public Produit4(String id, String lib, int quantite, String ref) {
    	super();
    	this.id = id;
    	this.lib = lib;
    	this.quantite = quantite;
    	this.ref = ref;
    }
     
    }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
     
    package entity;
     
    import javax.ejb.Stateless;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
     
    import entreprise.Entreprise2;
     
    @Stateless
    public class ProduitBean implements IProduit4 {
    @PersistenceContext
    EntityManager em;
    	@Override
    	public void ajouter(Produit4 p) {
    		// TODO Auto-generated method stub
    		if(em.find(Entreprise2.class,p.getRef())!=null)
    	em.persist(p);	
    	}
     
    }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    package entreprise;
     
    import javax.ejb.Remote;
     
    @Remote
    public interface IEntreprise {
    	void ajouter(Entreprise2 entreprise);
     
    }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
     
    package entreprise;
     
    import javax.ejb.Stateless;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
     
    @Stateless
    public class EntrepriseBean implements IEntreprise {
    	@PersistenceContext
    	EntityManager em;
     
    	@Override
    	public void ajouter(Entreprise2 entreprise) {
    		em.persist(entreprise);
     
     
    	}
     
    }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    package entreprise;
     
    import java.io.Serializable;
     
    import javax.persistence.Entity;
    import javax.persistence.Id;
     
    @Entity
    public class Entreprise2 implements Serializable {
    	@Id
    	private String id;
    	private String nom;
    	@Override
    	public String toString() {
    		return "Entreprise [id=" + id + ", nom=" + nom + "]";
    	}
    	public String getId() {
    		return id;
    	}
    	public void setId(String id) {
    		this.id = id;
    	}
    	public String getNom() {
    		return nom;
    	}
    	public void setNom(String nom) {
    		this.nom = nom;
    	}
    	public Entreprise2(String id, String nom) {
    		super();
    		this.id = id;
    		this.nom = nom;
    	}
     
     
     
    }

  2. #2
    Expert éminent
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    tu peux mettre ta stacktrace complète, tes logs ainsi que décrire comment Entreprise2 et Produit4 sont référencé dans ton persistence context? Sont-ils dans WEB-INF/classes? Où est le persistence.xml et que contient-il?

Discussions similaires

  1. Réponses: 2
    Dernier message: 01/01/2015, 17h15
  2. Réponses: 1
    Dernier message: 06/06/2014, 12h12
  3. Réponses: 4
    Dernier message: 21/01/2013, 11h42
  4. Exception : javax.ejb.EJBException
    Par abdoulfall dans le forum Java EE
    Réponses: 5
    Dernier message: 07/03/2012, 16h35
  5. Réponses: 1
    Dernier message: 29/01/2010, 20h23

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo