Bonjour, je débute en java EE et je tente de réaliser un simple EJB stateful sans IDE.
j'ai deux modules : un EJB et un client.
mon module EJB contient les fichiers CalculRemote (interface) et CalculBean (implem) dont voici les codes :
CalculRemote.java
CalculBean.java
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12package calcul; import javax.ejb.Remote; @Remote public interface CalculRemote { void addNombre(int a); int getSomme(); int getMoyenne(); int getMinimum(); int getMaximum(); }
et du coté du module client j'ai :
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77package calcul; import javax.ejb.Stateful; import java.util.*; @Stateful public class CalculBean implements CalculRemote { private Vector v = new Vector(); public void addNombre(int a) { v.add(a); } public int getSomme() { int sum=0; for (int i=0;i<v.size();i++) { if (v.elementAt(i)!=null) sum=sum+Integer.parseInt((String)(v.elementAt(i))); } return sum; } public int getMoyenne() { int sum=0, cpt=0, avg=0; for (int i=0;i<v.size();i++) { if (v.elementAt(i)!=null) { cpt++; sum=sum+Integer.parseInt((String)(v.elementAt(i))); } } avg=sum/cpt; return avg; } public int getMinimum() { int j=0; //on recup le premier elem du vec non nul while (v.elementAt(j)==null) { j++; } int min=Integer.parseInt((String)(v.elementAt(j))); //on passe tous elem suivants non nuls en revue for (int i=j;i<v.size();i++) { if (v.elementAt(i)!=null) { if (Integer.parseInt((String)(v.elementAt(i)))<min) min=Integer.parseInt((String)(v.elementAt(i))); } } return min; } public int getMaximum() { int j=0; //on recup le premier elem du vec non nul while (v.elementAt(j)==null) { j++; } int max=Integer.parseInt((String)(v.elementAt(j))); //on passe tous elem suivants non nuls en revue for (int i=j;i<v.size();i++) { if (v.elementAt(i)!=null) { if (Integer.parseInt((String)(v.elementAt(i)))>max) max=Integer.parseInt((String)(v.elementAt(i))); } } return max; } }
Main.java
j'ai compilé et empaqueté le module EJB et le module client et créé une archive .ear contenant ces deux modules et je veux donc déployer avec glassfish v2 UR2 et lors du déployement j'obtiens l'erreur suivante :
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
53package calcul; import javax.ejb.EJB; public class Main { @EJB private static calcul.CalculRemote calculRemote; public Main() { } public static void main(String[] args) { // test de addnombre au vecteur try { calculRemote.addNombre(3); calculRemote.addNombre(21); calculRemote.addNombre(111); } catch(Exception e) { e.printStackTrace(); } // test getsomme (3+21+111 = 135!!!) try { int res=0; res=calculRemote.getSomme(); System.out.println("somme : " +res); //test getmoyenne = 45!! res=0; res=calculRemote.getMoyenne(); System.out.println("moyenne : " +res); //test getmin() = 3!! res=0; res=calculRemote.getMinimum(); System.out.println("minimum: " +res); //test getmax() = 111!! res=0; res=calculRemote.getMaximum(); System.out.println("maximum : " +res); System.out.println("fin des tests - ok"); } catch(Exception e) { e.printStackTrace(); System.out.println("arret des tests - erreur"); } } }
"Deploying application in domain failed; Error loading deployment descriptors for module [applictest2part2] -- No matching injection setter method or injection field found for injection property CalculRemote on class calcul.Main for component dependency Unresolved Ejb-Ref calcul.Main/CalculBean@jndi: @null@calcul.CalculRemote@Session@ejb-labo1.jar#CalculBean"
Voila je ne vois pas d'ou peut venir mon erreur, si quelqu'un à une idée?
Merci d'avance![]()



Répondre avec citation











Partager