j'ai creé un entity Beans Produit (id, title, description).
j'ai creé ma session beans :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 package my; import javax.ejb.Remote; /** * * @author Abdelghani */ @Remote public interface ProduitRemote { public void addProduit(Produit produit); }mon client :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 @Stateless public class ProduitBean implements ProduitRemote { @PersistenceContext(unitName = "objectExchangeUP") private EntityManager objectExchangeEM; public void addProduit(Produit produit) { objectExchangeEM.persist(produit); } }
a l'exécution j'ai ce probleme :
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 product; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.xml.bind.ValidationException; import my.Produit; import my.ProduitRemote; /** * * @author Abdelghani */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) throws NamingException { Context ctx = new InitialContext(); ProduitRemote produits = (ProduitRemote) ctx.lookup(ProduitRemote.class.getName()); Produit produit = new Produit(); produit.setId("1"); produit.setTitle("ssssss"); produit.setTitle("ddddddddddddddddd"); try { produits.addProduit(produit); } catch(Exception e) { System.out.println("impossible ... " + e); System.exit(-1); } } }
Deploying application in domain failed; Could not resolve a persistence unit corresponding to the persistence-context-ref-name [my.ProduitBean/objectExchangeEM] in the scope of the module called [gfdeploy#C:\Users\Abdelghani\Desktop\TP\Product\dist\gfdeploy\Product-ejb_jar]. Please verify your application.
Deployment error: ...
Partager