Bonjour,

j'ai un client (programme Main) java qui appelle un remote SLSB par un look up.

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
			int choice = 1;
			String viewClassName = LibrarySessionBeanRemote.class.getName();
			LibrarySessionBeanRemote libraryBean = (LibrarySessionBeanRemote) ctx.lookup("EJBTutorial/EJBTutorialEJB//LibrarySessionBean!"+ viewClassName);
			while (choice != 2) {
				String bookName;
				showGUI();
				String strChoice = brConsoleReader.readLine();
				choice = Integer.parseInt(strChoice);
				if (choice == 1) {
					System.out.print("Enter book name: ");
					bookName = brConsoleReader.readLine();
					libraryBean.addBook(bookName);
				} else if (choice == 2) {
					break;
				}
			}
			List<String> booksList = libraryBean.getBooks();
			System.out.println("Book(s) entered so far: " + booksList.size());
			for (int i = 0; i < booksList.size(); ++i) {
				System.out.println((i + 1) + ". " + booksList.get(i));
			}
Avant de faire mon lookup, je lance une dizaine de thread qui appelle une servlet. Chacune de ces servlet instancie mon SLSB

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
 
@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");
		//PrintWriter out = response.getWriter();
		monBean.getBooks();
		System.out.println("DEBUT ATTENTE");
		try {
			Thread.sleep(300000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("FIN ATTENTE");
		PrintWriter out = new PrintWriter (response.getOutputStream());
		try {
			out.println("<html>");
			out.println("<head>");
			out.println("<title>Servlet MaServlet</title>");
			out.println("</head>");
			out.println("<body>");
			out.println("</body>");
			out.println("</html>");
		} finally {
			out.close();
		}
 
	}
 
	@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";
	}
 
 
}
Ce SLSB a un attribut List<String> bookShelf.

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
 
@Stateless(name = "LibrarySessionBean")
@Local(LibrarySessionBeanLocal.class)
@Remote(LibrarySessionBeanRemote.class)
@LocalBean
public class LibrarySessionBean {
 
	private List<String> bookShelf;
 
	/**
         * Default constructor.
         */
	public LibrarySessionBean() {
		// TODO Auto-generated constructor stub
		System.out.println("object this.toString=" + this.toString());
		System.out.println("constructeur LibrarySessionBean  appele");
		bookShelf = new ArrayList<String>();
	}
 
 
	public void addBook(String bookname) {
		System.out.println("object this.toString=" + this.toString());
		System.out.println("addbook appele");
		bookShelf.add(bookname);
	}
 
 
	public List<String> getBooks() {
		System.out.println("object this.toString=" + this.toString());
		System.out.println("getBooks appele");
		return bookShelf;
	}
 
}
Or quand je rajoute un livre du coté client dans mon programme Main (voir ligne en rouge) et quand j'inspecte (debug) ma liste de livre après l'ajout, ou même quand j'imprime la taille de ma liste, le livre ne s'y trouve pas.

Je sais bien que c'est un SLSB, mais immédiatement après avoir rajouté un livre, le livre devrait se retrouver dans la liste. Quand je n'ai pas ma dizaine de thread, il s'y trouve bien

Avez-vous une idée ? Merci d'avance pour votre réponse.