Bonjour,

j'ai une enterprise application project sous eclipse Luna où il y a un module client et un module web.

Sur mon module client, j'ai un programme Main (Main.java) qui appelle un Thread (TestThread.java). Ce thread appel de manière programmatique une servlet qui se trouve dans mon module web (ServletCallSessionBean.java)

Voici un screenshoot de mon projet

Nom : Capture d’écran 2014-10-08 à 15.05.28.png
Affichages : 290
Taille : 78,7 Ko


Voici un extrait de ma classe Main

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
public class Main {

	BufferedReader brConsoleReader = null;

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Main ejbTester = new Main();
		ejbTester.testHttpRequest();

	}



	/*
	 * (non-Java-doc)
	 *
	 * @see java.lang.Object#Object()
	 */
	public Main() {
		super();
		brConsoleReader = new BufferedReader(new InputStreamReader(System.in));
	}

	private void showGUI() {
		System.out.println("**********************");
		System.out.println("Welcome to Book Store");
		System.out.println("**********************");
		System.out.print("Options \n1. Add Book\n2. Exit \nEnter Choice: ");
	}

	private void testHttpRequest() {
		TestThread thread = new TestThread("A");
	}
Voici un extrait de mon Thread

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
77
78
79
80
81
82
83
84
85
86
87
 
public class TestThread extends Thread {
 
 
 
	static Logger log = LogManager.getLogger(TestThread.class.getName());    //getLogger(
	//Main.class.getName());
 
 
 
	public String postURL(URL a_Url, String a_sParamsToPost)
	{
		StringBuilder o_oSb = new StringBuilder();
 
		//recup du saut de ligne
		String o_sLineSep = null;
		try
		{
			o_sLineSep = System.getProperty("line.separator");
		}
		catch (Exception e)
		{
			o_sLineSep = "\n";
		}
 
		try
		{
			HttpURLConnection o_oUrlConn = (HttpURLConnection) a_Url.openConnection();
			o_oUrlConn.setRequestMethod("POST");
			o_oUrlConn.setAllowUserInteraction(false);
			//envoyer des params
			o_oUrlConn.setDoOutput(true);
 
			//poster les params
			PrintWriter o_oParamWriter = new PrintWriter(o_oUrlConn.getOutputStream());
 
			o_oParamWriter.print(a_sParamsToPost);
			//fermer le post avant de lire le resultat ... logique
			o_oParamWriter.flush();
			o_oParamWriter.close();
 
			//Lire la reponse
			InputStream  o_oResponse = o_oUrlConn.getInputStream();
			BufferedReader o_oBufReader = new BufferedReader(new InputStreamReader(o_oResponse));
			String sLine;
 
			while ((sLine = o_oBufReader.readLine()) != null)
			{
				o_oSb.append(sLine);
				o_oSb.append(o_sLineSep);
			}
			//deconnection
			o_oUrlConn.disconnect();
		}
		catch(ConnectException ctx)
		{
			log.fatal("Connection lost : server may be down");
			ctx.printStackTrace();
		}
		catch (Exception e)
		{
			log.error("postURL : "+e.getMessage());
			e.printStackTrace();
		}
		log.debug("retour url="+o_oSb.toString());
		return o_oSb.toString();
	}
 
 
	public TestThread(String name, Context ctx){
		System.out.println("statut du thread " + name + " = " +this.getState());
		this.start();
		System.out.println("statut du thread " + name + " = " +this.getState());
	}
 
 
	@Override
	public void run(){
 
		try {
			URL urlForServletTesting = new URL("http://localhost:8080/EJBTutorialWeb/test");
			postURL(urlForServletTesting, "test");
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
Voici ma servlet

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
 
@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();
		System.out.println("DEBUT ATTENTE");
		try {
			Thread.sleep(60000);
		} 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();
		}
 
	}
J'ai les problèmes suivants:

Dans ma servlet
1) Quand je suis en mode debug, eclipse le système ne s'arrete pas sur des points d'arret mis dans ma servlet.
2) Quand j'écris des System.out.println dans ma servlet, je n'ai aucune impression dans ma console

Avez vous une idée ? Merci d'avance pour vos réponses.