Bonjour
J'ai GlassFish 3.1 et Struts 2. J'essaye, à partir de la couche action, de faire appel à un EJB mais ça ne fonctionne pas.
Voici le code couche action tout simple :
J'ai trois classes voici la structure :
projet :
| src
|--action
|----Action.java
|--Service
|----BookEJB.java
|----BookEJBRemote.java
Classe action
BookEJBRemote :
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 package action; import javax.naming.InitialContext; import service.BookEJBInterface; import com.opensymphony.xwork2.ActionSupport; public class Action extends ActionSupport { public String execute() throws Exception { InitialContext context = new InitialContext(); BookEJBRemote book = (BookEJBRemote ) context.lookup("BookEJBRemote"); book.sayHello(); return "SUCCESS"; } }
BookEJB.java :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 package service; import javax.ejb.Remote; @Remote public interface BookEJBRemote { public abstract void sayHello(); }
Quelqu'un saurait-il m'indiquer comment faire ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 package service; import javax.ejb.Stateless; import javax.naming.InitialContext; import javax.naming.NamingException; @Stateless public class BookEJB implements BookEJBRemote { @Override public void sayHello() { System.out.println("Salut !!!!"); } }
Merci d'avance pour votre aide.
Partager