Problème d'injection d'EJB
Bonjour,
je fais un tutoriel EJB
J'ai un stateless session bean dans un module EJBTutorielEJB que je declate remote et local en même temps
Code:
1 2 3 4 5 6 7 8
|
@Local
public interface LibrarySessionBeanLocal {
void addBook(String bookname);
List<String> getBooks();
} |
Code:
1 2 3 4 5
|
@Remote
public interface LibrarySessionBeanRemote extends LibrarySessionBeanLocal{
} |
Code:
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
|
@Stateless
public class LibrarySessionBean implements LibrarySessionBeanRemote {
private List<String> bookShelf;
/**
* Default constructor.
*/
public LibrarySessionBean() {
// TODO Auto-generated constructor stub
bookShelf = new ArrayList<String>();
//this.getClass().getAnnotation(PoolClass.class)
}
@Override
public void addBook(String bookname) {
bookShelf.add(bookname);
}
@Override
public List<String> getBooks() {
return bookShelf;
}
} |
J'ai un module web avec une servlet dans un module web EJBTutorialWeb (j'ai ajouté le module EJBTutorialEJB dans le classpath de EJBTutorialWeb)
Code:
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
|
@WebServlet(name="ServletCallSessionBean", urlPatterns={"/test"})
public class ServletCallSessionBean extends HttpServlet {
@EJB(beanName = "LibrarySessionBean")
private LibrarySessionBeanLocal monBean;
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try {
Thread.sleep(120000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
public String getServletInfo() {
return "Ma servlet de test";
}
} |
Or quand je lance JBoss, j'ai l'erreur suivante
Code:
1 2
|
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS014543: Aucun EJB trouvé dans l'interface de type 'com.tutorialspoint.sessionbean.stateless.LibrarySessionBeanLocal' ayant pour nom 'LibrarySessionBean' pour la liaison com.tutorialspoint.servlet.ServletCallSessionBean/monBean |
Auriez-vous une idée ? Merci d'avance pour vos réponse