IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Java EE Discussion :

Logs d'une méthode @PreDestroy et Log4J


Sujet :

Java EE

  1. #1
    Membre actif
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    728
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 728
    Points : 250
    Points
    250
    Par défaut Logs d'une méthode @PreDestroy et Log4J
    Bonjour

    je travaille avec Eclipse et ai créé un enterprise application project déployé sous JBoss

    Voici la hierarchie de mon projet

    Nom : Capture d’écran 2014-10-29 à 22.28.50.png
Affichages : 184
Taille : 130,4 Ko

    J'ai un EJB stateless LibrarySessionBean dans le module EJBTutorialEJB où il y a des logs (log4j)

    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
     
    package com.tutorialspoint.sessionbean.stateless;
     
    import java.util.ArrayList;
    import java.util.List;
     
    import javax.annotation.PostConstruct;
    import javax.annotation.PreDestroy;
    import javax.ejb.Local;
    import javax.ejb.LocalBean;
    import javax.ejb.Remote;
    import javax.ejb.Stateless;
     
    import org.apache.logging.log4j.LogManager;
    import org.apache.logging.log4j.Logger;
     
    /**
     * Session Bean implementation class LibrarySessionBean
     */
    @Stateless(name = "LibrarySessionBean")
    @Local(LibrarySessionBeanLocal.class)
    @Remote(LibrarySessionBeanRemote.class)
    @LocalBean
    public class LibrarySessionBean {
     
    	private List<String> bookShelf;
     
    	static Logger log = LogManager.getLogger(LibrarySessionBean.class.getName());
     
    	/**
             * Default constructor.
             */
    	public LibrarySessionBean() {
    		log.info("object this.toString=" + this.toString());
    		log.info("constructeur LibrarySessionBean  appele");
    		bookShelf = new ArrayList<String>();
    	}
     
     
     
    	public void addBook(String bookname) {
    		log.info("object this.toString=" + this.toString());
    		log.info("addbook appele");
    		bookShelf.add(bookname);
    	}
     
     
     
    	public List<String> getBooks() {
    		return bookShelf;
    	}
     
     
     
    	@PreDestroy
    	public void givingEndState() {
    		log.info("givingEndState object this.toString=" + this.toString());
    		for (String book : bookShelf) {
    			log.info("book found =" + book);
    		}
    	}
     
     
    	@PostConstruct
    	public void givingStartState() {
    		log.info("givingStartState object this.toString=" + this.toString());
    	}
     
     
    }

    Mon programme principal Main dans le module EJBTutorialClient instancie 15 thread qui appellent chacun une servlet ServletCallSessionBean (qui se trouvent dans le module EJBTutorialWeb). Ces servlet ont chacune un attribut @EJB LibrarySessionBean

    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
    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
     
    package com.tutorialspoint.servlet;
     
    import java.io.IOException;
    import java.io.PrintWriter;
     
    import javax.ejb.EJB;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
     
    import org.apache.logging.log4j.LogManager;
    import org.apache.logging.log4j.Logger;
     
    import com.tutorialspoint.sessionbean.stateless.LibrarySessionBeanLocal;
     
    @WebServlet(name="ServletCallSessionBean", urlPatterns={"/test"})
    public class ServletCallSessionBean extends HttpServlet {
     
    	@EJB(beanName = "LibrarySessionBean")
    	private LibrarySessionBeanLocal monBean;
     
    	static Logger log = LogManager.getLogger(ServletCallSessionBean.class.getName());
     
    	protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    			throws ServletException, IOException {
    		response.setContentType("text/html;charset=UTF-8");
    		//PrintWriter out = response.getWriter();
    		monBean.getBooks();
    		log.info("DEBUT ATTENTE");
    		try {
    			Thread.sleep(300000);
    		} catch (InterruptedException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    		log.info("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";
    	}
     
     
    }
    Voici un extrait de mon programme principal
    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
     
    	private void startThreads() {
    		for (int i = 0; i < threadCount-1; i++) {
    			thread[i] = new TestThread(""+ i, ctx);
    		}
    	}
     
    	private void stopThreads() {
    		for (int i = 0; i < threadCount-1; i++) {
    			thread[i].interrupt();
    		}
    	}
     
    	private void testStatelessEjb() {
    		startThreads();
     
    		try {
     
    			int choice = 1;
    			String viewClassName = LibrarySessionBeanRemote.class.getName();
    			LibrarySessionBeanRemote libraryBean = (LibrarySessionBeanRemote) ctx.lookup("EJBTutorial/EJBTutorialEJB//LibrarySessionBean!"+ viewClassName);
    			System.out.print("libraryBean.toString: " + libraryBean.toString());
    			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));
    			}
     
    			LibrarySessionBeanRemote libraryBean1 = (LibrarySessionBeanRemote) ctx.lookup("EJBTutorial/EJBTutorialEJB//LibrarySessionBean!"
    					+ viewClassName);
    			List<String> booksList1 = libraryBean1.getBooks();
    			System.out.println("***Using second lookup to get library stateless object***");
    			System.out.println("Book(s) entered so far: " + booksList1.size());
    			for (int i = 0; i < booksList1.size(); ++i) {
    				System.out.println((i + 1) + ". " + booksList1.get(i));
    			}
    		} catch (Exception e) {
    			System.out.println(e.getMessage());
    			e.printStackTrace();
    		} finally {
    			try {
    				stopThreads();
    				brConsoleReader.readLine();
    				if (brConsoleReader != null) {
    					brConsoleReader.close();
    				}
    			} catch (IOException ex) {
    				System.out.println(ex.getMessage());
    			}
    		}
     
    	}
    Mes logs sont de l'API log4j. Voici le fichier log4j2.xml: 2 sorties: la sortie standard et un fichier de log app.log
    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
     
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration status="WARN">
      <appenders>
        <Console name="Console" target="SYSTEM_OUT">
          <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
        </Console>
     
        <File name="MyFile" fileName="logs/app.log">
            <PatternLayout pattern="%d{yyyy-mm-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
        </File>             
      </appenders>
     
      <loggers>     
        <root level="debug">
          <appender-ref ref="Console" level="info"/>
           <appender-ref ref="MyFile" level="info"/>
        </root>    
      </loggers>
    </configuration>
    Le problème est le suivant: quand j'éxécute mon programme client Main tous les logs de mon EJB se retrouvent dans les logs de mon fichier de log app.log sauf ceux de la méthode @PreDestroy

    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
     
    2014-37-29 21:37:22.928 [http-localhost/127.0.0.1:8080-14] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@5eb83295
    2014-37-29 21:37:22.928 [http-localhost/127.0.0.1:8080-1] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@1449d578
    2014-37-29 21:37:22.927 [http-localhost/127.0.0.1:8080-4] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@5c340d7d
    2014-37-29 21:37:22.924 [http-localhost/127.0.0.1:8080-13] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@6362f371
    2014-37-29 21:37:22.962 [http-localhost/127.0.0.1:8080-14] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - constructeur LibrarySessionBean  appele
    2014-37-29 21:37:22.927 [http-localhost/127.0.0.1:8080-10] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@5e9675b9
    2014-37-29 21:37:22.927 [http-localhost/127.0.0.1:8080-11] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@1bfa50cf
    2014-37-29 21:37:22.927 [http-localhost/127.0.0.1:8080-3] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@612e2907
    2014-37-29 21:37:22.924 [http-localhost/127.0.0.1:8080-8] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@6d454ea4
    2014-37-29 21:37:22.928 [http-localhost/127.0.0.1:8080-2] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@5bde49b1
    2014-37-29 21:37:22.924 [http-localhost/127.0.0.1:8080-7] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@704ecb9a
    2014-37-29 21:37:22.924 [http-localhost/127.0.0.1:8080-6] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@45192510
    2014-37-29 21:37:22.924 [http-localhost/127.0.0.1:8080-12] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@21fabc2
    2014-37-29 21:37:22.927 [http-localhost/127.0.0.1:8080-5] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@77ddf58a
    2014-37-29 21:37:22.924 [http-localhost/127.0.0.1:8080-9] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@29dd2d9e
    2014-37-29 21:37:22.962 [http-localhost/127.0.0.1:8080-13] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - constructeur LibrarySessionBean  appele
    2014-37-29 21:37:22.962 [http-localhost/127.0.0.1:8080-1] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - constructeur LibrarySessionBean  appele
    2014-37-29 21:37:22.963 [http-localhost/127.0.0.1:8080-14] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - givingStartState object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@5eb83295
    2014-37-29 21:37:22.963 [http-localhost/127.0.0.1:8080-10] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - constructeur LibrarySessionBean  appele
    2014-37-29 21:37:22.963 [http-localhost/127.0.0.1:8080-11] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - constructeur LibrarySessionBean  appele
    2014-37-29 21:37:22.962 [http-localhost/127.0.0.1:8080-4] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - constructeur LibrarySessionBean  appele
    2014-37-29 21:37:22.963 [http-localhost/127.0.0.1:8080-8] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - constructeur LibrarySessionBean  appele
    2014-37-29 21:37:22.963 [http-localhost/127.0.0.1:8080-2] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - constructeur LibrarySessionBean  appele
    2014-37-29 21:37:22.963 [http-localhost/127.0.0.1:8080-7] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - constructeur LibrarySessionBean  appele
    2014-37-29 21:37:23.014 [http-localhost/127.0.0.1:8080-9] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - constructeur LibrarySessionBean  appele
    2014-37-29 21:37:22.963 [http-localhost/127.0.0.1:8080-6] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - constructeur LibrarySessionBean  appele
    2014-37-29 21:37:22.963 [http-localhost/127.0.0.1:8080-12] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - constructeur LibrarySessionBean  appele
    2014-37-29 21:37:22.963 [http-localhost/127.0.0.1:8080-5] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - constructeur LibrarySessionBean  appele
    2014-37-29 21:37:22.963 [http-localhost/127.0.0.1:8080-3] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - constructeur LibrarySessionBean  appele
    2014-37-29 21:37:23.015 [http-localhost/127.0.0.1:8080-8] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - givingStartState object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@6d454ea4
    2014-37-29 21:37:23.014 [http-localhost/127.0.0.1:8080-1] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - givingStartState object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@1449d578
    2014-37-29 21:37:23.014 [http-localhost/127.0.0.1:8080-13] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - givingStartState object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@6362f371
    2014-37-29 21:37:23.015 [http-localhost/127.0.0.1:8080-3] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - givingStartState object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@612e2907
    2014-37-29 21:37:23.015 [http-localhost/127.0.0.1:8080-5] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - givingStartState object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@77ddf58a
    2014-37-29 21:37:23.015 [http-localhost/127.0.0.1:8080-12] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - givingStartState object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@21fabc2
    2014-37-29 21:37:23.015 [http-localhost/127.0.0.1:8080-6] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - givingStartState object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@45192510
    2014-37-29 21:37:23.015 [http-localhost/127.0.0.1:8080-9] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - givingStartState object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@29dd2d9e
    2014-37-29 21:37:23.015 [http-localhost/127.0.0.1:8080-10] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - givingStartState object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@5e9675b9
    2014-37-29 21:37:23.015 [http-localhost/127.0.0.1:8080-11] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - givingStartState object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@1bfa50cf
    2014-37-29 21:37:23.015 [http-localhost/127.0.0.1:8080-4] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - givingStartState object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@5c340d7d
    2014-37-29 21:37:23.015 [http-localhost/127.0.0.1:8080-2] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - givingStartState object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@5bde49b1
    2014-37-29 21:37:23.015 [http-localhost/127.0.0.1:8080-7] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - givingStartState object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@704ecb9a
    2014-37-29 21:37:23.122 [http-localhost/127.0.0.1:8080-8] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - DEBUT ATTENTE
    2014-37-29 21:37:23.122 [http-localhost/127.0.0.1:8080-14] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - DEBUT ATTENTE
    2014-37-29 21:37:23.122 [http-localhost/127.0.0.1:8080-6] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - DEBUT ATTENTE
    2014-37-29 21:37:23.127 [http-localhost/127.0.0.1:8080-11] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - DEBUT ATTENTE
    2014-37-29 21:37:23.125 [http-localhost/127.0.0.1:8080-12] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - DEBUT ATTENTE
    2014-37-29 21:37:23.122 [http-localhost/127.0.0.1:8080-3] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - DEBUT ATTENTE
    2014-37-29 21:37:23.122 [http-localhost/127.0.0.1:8080-7] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - DEBUT ATTENTE
    2014-37-29 21:37:23.122 [http-localhost/127.0.0.1:8080-9] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - DEBUT ATTENTE
    2014-37-29 21:37:23.122 [http-localhost/127.0.0.1:8080-1] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - DEBUT ATTENTE
    2014-37-29 21:37:23.122 [http-localhost/127.0.0.1:8080-2] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - DEBUT ATTENTE
    2014-37-29 21:37:23.122 [http-localhost/127.0.0.1:8080-5] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - DEBUT ATTENTE
    2014-37-29 21:37:23.122 [http-localhost/127.0.0.1:8080-10] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - DEBUT ATTENTE
    2014-37-29 21:37:23.122 [http-localhost/127.0.0.1:8080-13] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - DEBUT ATTENTE
    2014-37-29 21:37:23.122 [http-localhost/127.0.0.1:8080-4] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - DEBUT ATTENTE
    2014-37-29 21:37:37.456 [EJB default - 1] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@612e2907
    2014-37-29 21:37:37.459 [EJB default - 1] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - addbook appele
    2014-37-29 21:37:45.239 [EJB default - 2] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - object this.toString=com.tutorialspoint.sessionbean.stateless.LibrarySessionBean@5c340d7d
    2014-37-29 21:37:45.240 [EJB default - 2] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - addbook appele
    2014-42-29 21:42:23.130 [http-localhost/127.0.0.1:8080-2] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - FIN ATTENTE
    2014-42-29 21:42:23.131 [http-localhost/127.0.0.1:8080-10] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - FIN ATTENTE
    2014-42-29 21:42:23.130 [http-localhost/127.0.0.1:8080-14] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - FIN ATTENTE
    2014-42-29 21:42:23.131 [http-localhost/127.0.0.1:8080-13] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - FIN ATTENTE
    2014-42-29 21:42:23.129 [http-localhost/127.0.0.1:8080-6] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - FIN ATTENTE
    2014-42-29 21:42:23.130 [http-localhost/127.0.0.1:8080-11] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - FIN ATTENTE
    2014-42-29 21:42:23.130 [http-localhost/127.0.0.1:8080-3] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - FIN ATTENTE
    2014-42-29 21:42:23.130 [http-localhost/127.0.0.1:8080-7] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - FIN ATTENTE
    2014-42-29 21:42:23.130 [http-localhost/127.0.0.1:8080-12] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - FIN ATTENTE
    2014-42-29 21:42:23.130 [http-localhost/127.0.0.1:8080-9] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - FIN ATTENTE
    2014-42-29 21:42:23.129 [http-localhost/127.0.0.1:8080-8] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - FIN ATTENTE
    2014-42-29 21:42:23.130 [http-localhost/127.0.0.1:8080-1] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - FIN ATTENTE
    2014-42-29 21:42:23.131 [http-localhost/127.0.0.1:8080-4] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - FIN ATTENTE
    2014-42-29 21:42:23.131 [http-localhost/127.0.0.1:8080-5] INFO  com.tutorialspoint.servlet.ServletCallSessionBean - FIN ATTENTE
    A croire que la méthode @PreDestroy n'est pas appelée. Pourtant quand je remplace ces logs par des System.out.println et que je stoppe JBoss ces logs apparaissent (au moment seulement où je stoppe le serveur)

    D'autre part dans mes logs du fichier server.log, il n'y a que les traces des appels à mon EJB depuis le module client. (les logs de mon EJB), comme si tous les autres logs n'existaient pas

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

  2. #2
    Modérateur
    Avatar de OButterlin
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    7 310
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 310
    Points : 9 522
    Points
    9 522
    Billets dans le blog
    1
    Par défaut
    Attention à ce que tu fais, une servlet est multi-thread.
    Tu définis ton EJB dans la servlet ce qui implique que tous les appels de tous tes clients vont partager le même EJB et qu'il ne sera détruit qu'à l'arrêt du serveur.
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  3. #3
    Membre actif
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    728
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 728
    Points : 250
    Points
    250
    Par défaut
    Bonjour OButterlin et merci pour ta réponse

    Que veut dire
    une servlet est multi-thread.
    Pour ma part j'instancie 15 threads qui chacun appelle ma servlet. Veux-tu dire que les 15 threads vont partager la même instance de servlet ?

    A ce moment je ne comprends pas car comme les logs le montre j'ai 15 EJB qui sont instancié, ce qui tend à démontrer que j'ai 15 instances de servlet.

    D'autre part
    1) les logs de log4j pour la méthode @PreDestroy ne fonctionnent pas : quand je stoppe mon serveur, aucun logs
    2) les logs de log4j tels que je les ai configuré sur STDOUT ne fonctionnent pas non plus, tous les logs que je recupère dans mon fichier app.log n'apparaissent pas ni dans ma console Eclipse, ni dans le server.log de mon JBoss. Y aurait-il une erreur dans mon fichier de configuration de log4j ?

    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
     
    <configuration status="WARN">
      <appenders>
        <Console name="Console" target="SYSTEM_OUT">
          <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
        </Console>
     
        <File name="MyFile" fileName="logs/app.log">
            <PatternLayout pattern="%d{yyyy-mm-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
        </File>             
      </appenders>
     
      <loggers>     
        <root level="debug">
          <appender-ref ref="Console" level="info"/>
           <appender-ref ref="MyFile" level="info"/>
        </root>    
      </loggers>
    </configuration>
    J'en profite pour te demander une info. Je suis en train de préparer des cours sur les EJB. Je desire acquérir une très bonne connaissance des EJB3. C'est pourquoi je m'apprête à répondre aux discussion sur les forums. Je vais le faire sur developpez.net. Connais-tu les autres forums sur les EJB, en particulier les forums americains ?

  4. #4
    Expert confirmé
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 274
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 274
    Points : 4 141
    Points
    4 141
    Par défaut
    Où fais tu l'appel à tes Servlets ?

  5. #5
    Membre actif
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    728
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 728
    Points : 250
    Points
    250
    Par défaut
    Dans une classe TestThread dont voici le code. Cette classe est appelée 15 fois dans mon programme principal

    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
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
     
    import java.io.BufferedReader;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.PrintWriter;
    import java.net.ConnectException;
    import java.net.HttpURLConnection;
    import java.net.MalformedURLException;
    import java.net.URL;
     
    import javax.naming.Context;
     
    import org.apache.logging.log4j.LogManager;
    import org.apache.logging.log4j.Logger;
     
    import com.tutorialspoint.sessionbean.stateless.LibrarySessionBeanRemote;
     
     
     
    public class TestThread extends Thread {
    	boolean interrupted = false;
     
    	Context ctx = null;
     
    	LibrarySessionBeanRemote libraryBean = null;
     
    	static Logger log = LogManager.getLogger(TestThread.class.getName());
     
     
    	/*
    	 * method to post with the url a_Url and the parameter a_sParamsToPost
    	 */
    	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){
    		super(name);
    		this.start();
    		System.out.println("thread " + name + " demarré");
    	}
     
     
    	@Override
    	public void run(){
    		try {
    			URL urlForServletTesting = new URL("http://localhost:8080/EJBTutorialWeb/test");
    			postURL(urlForServletTesting, "test");
    		} catch (MalformedURLException e) {
    			e.printStackTrace();
    		}
    	}
     
    	@Override
    	public void interrupt(){
    		log.info("Le thread " + super.getName() + " va être suspendu");
    		interrupted=true;
    	}
    }

  6. #6
    Modérateur
    Avatar de OButterlin
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    7 310
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 310
    Points : 9 522
    Points
    9 522
    Billets dans le blog
    1
    Par défaut
    Tes threads récupère une référence vers ton EJB via l'interface @Remote, c'est normal que tu ais 15 instances...
    Il n'empêche que du côté de ta servlet, l'instance est partagée.
    Il faut définir l'EJB dans ta méthode processRequest
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  7. #7
    Membre actif
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    728
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 728
    Points : 250
    Points
    250
    Par défaut
    Je ne suis pas sûr de bien comprendre. Dans ma servlet je fait appel à mon EJB avec l'interface Local


    WebServlet(name="ServletCallSessionBean", urlPatterns={"/test"})
    public class ServletCallSessionBean extends HttpServlet {

    @EJB(beanName = "LibrarySessionBean")
    private LibrarySessionBeanLocal monBean;
    De toute manière pour les besoin de mon tutoriel, j'ai besoin d'instancier 15 instances de mon EJB. Comment faire ?

  8. #8
    Modérateur
    Avatar de OButterlin
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    7 310
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 310
    Points : 9 522
    Points
    9 522
    Billets dans le blog
    1
    Par défaut
    Ce qu'il faut bien comprendre, c'est qu'une servlet est multi-thread. Ça veut dire que tu as une seule instance de ta servlet et que les méthodes appelées sont dans un thread spécifique lié à chaque appel.

    Donc, toute propriété déclarée au niveau de ta classe de servlet sera partagée par tout les "appels" (thread)...

    Ensuite, un EJB stateless ne conservant pas son état, entre 2 appels, tu n'as pas la même instance de l'EJB.
    En pratique, il y a un pool d'ejb stateless, tu en prends un, tu l'utilises, tu le libères... (ce qui ce passe après... on ne sait pas et ça pourrait dépendre de l'implémentation du serveur)

    Quel est ton besoin en fait, que cherches-tu à faire ?
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  9. #9
    Membre actif
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    728
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 728
    Points : 250
    Points
    250
    Par défaut
    J'ai bien compris le fait qu'une servlet est multithreading et qu'il faudrais que j'apelle mon EJB dans la méthode.

    D'une manière plus générale je veux démontrer le comportement du pool de stateless session bean. Mais mon vrai problème est ailleurs :

    En fait ce que je n'arrive pas à faire c'est de demontrer dans mes fichiers de log log4j que ma méthode @PreDestroy de mon EJB est appelée lorsque je stoppe mon serveur. Cette méthode est bien appelée, je l'ai vérifié en mettant des System.out.println qui marchent. Mes avec log4j je n'arrive pas à avoir ces logs dans mon fichier app.log (voir le fichier de configuration de log4j)

    Mon deuxième probléme est que j'ai défini aussi au niveau de log4j des logs vers la sortie standard et sur cette sortie standard (mes logs server.log de JBoss) je ne voie aucun des logs log4j que j'ai plassé dans mon EJB

  10. #10
    Modérateur
    Avatar de OButterlin
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    7 310
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 310
    Points : 9 522
    Points
    9 522
    Billets dans le blog
    1
    Par défaut
    Pour ce qui est de la trace (log4j), tu as paramétré le niveau de consignation à WARN et tu traces avec logger.info(...), c'est normal qu'il ne s'affiche pas.
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  11. #11
    Membre actif
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    728
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 728
    Points : 250
    Points
    250
    Par défaut
    RE-bonjour,

    même si je le mets au niveau TRACE je n'ai pas les logs. J'ai l'impression que JBoss desenregistre log4j avant de supprimer les stateless session bean et stopper comme le signale les logs suivants. Je vais creuser du coté de JBoss

    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
    14:04:39,997 INFO  [stdout] (EJB default - 2) 14:04:39.997 [EJB default - 2] INFO  com.tutorialspoint.sessionbean.stateless.LibrarySessionBean - addbook appele
    14:06:17,584 INFO  [org.jboss.as.naming] (Remoting "mbp-de-xflamant" task-1) JBAS011806: Notification de fin de canal reçue, fermeture du canal Channel ID 0054804e (inbound) of Remoting connection 7d8b97ec to /127.0.0.1:57636
    14:12:48,766 INFO  [stdout] (log4j-shutdown) 2014-10-30 14:12:48,764 DEBUG ShutdownThread stopping LoggerContext[name=ModuleClassLoader for Module "deployment.EJBTutorial.ear.EJBTutorialEJB.jar:main" from Service Module Loader, org.apache.logging.log4j.core.LoggerContext@478ea812]...
    14:12:48,797 INFO  [stdout] (log4j-shutdown) 2014-10-30 14:12:48,797 DEBUG Stopping LoggerContext[name=ModuleClassLoader for Module "deployment.EJBTutorial.ear.EJBTutorialEJB.jar:main" from Service Module Loader, org.apache.logging.log4j.core.LoggerContext@478ea812]...
    14:12:48,798 INFO  [stdout] (log4j-shutdown) 2014-10-30 14:12:48,797 DEBUG Enqueue shutdown hook for garbage collection.
    14:12:48,799 INFO  [stdout] (log4j-shutdown) 2014-10-30 14:12:48,798 TRACE Stopping XmlConfiguration[location=vfs:/Users/xflamant/Documents/JBOSS/jboss-eap-6.2/standalone/deployments/EJBTutorial.ear/EJBTutorialEJB.jar/log4j2.xml]...
    14:12:48,799 INFO  [stdout] (log4j-shutdown) 2014-10-30 14:12:48,799 TRACE AbstractConfiguration stopped 0 AsyncLoggerConfigs.
    14:12:48,800 INFO  [stdout] (log4j-shutdown) 2014-10-30 14:12:48,800 TRACE AbstractConfiguration stopped 0 AsyncAppenders.
    14:12:48,801 INFO  [stdout] (log4j-shutdown) 2014-10-30 14:12:48,800 DEBUG Shutting down FileManager logs/app.log
    14:12:48,890 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-6) JBAS010409: Source de données non liée [java:jboss/datasources/ExampleDS]
    14:12:48,928 INFO  [stdout] (log4j-shutdown) 2014-10-30 14:12:48,928 DEBUG Shutting down OutputStreamManager SYSTEM_OUT
    14:12:48,929 INFO  [stdout] (log4j-shutdown) 2014-10-30 14:12:48,928 TRACE AbstractConfiguration stopped 2 Appenders.
    14:12:48,930 INFO  [stdout] (log4j-shutdown) 2014-10-30 14:12:48,929 TRACE AbstractConfiguration stopped 1 Loggers.
    14:12:48,929 INFO  [org.jboss.web] (ServerService Thread Pool -- 57) JBAS018224: Désenregistrement du contexte web /EJBTutorialWeb
    14:12:48,930 INFO  [stdout] (log4j-shutdown) 2014-10-30 14:12:48,930 DEBUG Stopped XmlConfiguration[location=vfs:/Users/xflamant/Documents/JBOSS/jboss-eap-6.2/standalone/deployments/EJBTutorial.ear/EJBTutorialEJB.jar/log4j2.xml] OK
    14:12:48,935 INFO  [stdout] (log4j-shutdown) 2014-10-30 14:12:48,934 DEBUG Unregistering MBean org.apache.logging.log4j2:type="ModuleClassLoader for Module \"deployment.EJBTutorial.ear.EJBTutorialEJB.jar:main\" from Service Module Loader"
    14:12:48,936 INFO  [stdout] (log4j-shutdown) 2014-10-30 14:12:48,935 DEBUG Unregistering MBean org.apache.logging.log4j2:type="ModuleClassLoader for Module \"deployment.EJBTutorial.ear.EJBTutorialEJB.jar:main\" from Service Module Loader",component=StatusLogger
    14:12:48,938 INFO  [stdout] (log4j-shutdown) 2014-10-30 14:12:48,937 DEBUG Unregistering MBean org.apache.logging.log4j2:type="ModuleClassLoader for Module \"deployment.EJBTutorial.ear.EJBTutorialEJB.jar:main\" from Service Module Loader",component=ContextSelector
    14:12:48,939 INFO  [stdout] (log4j-shutdown) 2014-10-30 14:12:48,939 DEBUG Unregistering MBean org.apache.logging.log4j2:type="ModuleClassLoader for Module \"deployment.EJBTutorial.ear.EJBTutorialEJB.jar:main\" from Service Module Loader",component=Loggers,name=
    14:12:48,939 INFO  [org.apache.catalina.core] (MSC service thread 1-4) JBWEB001079: Container org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/] has not been started
    14:12:48,942 INFO  [stdout] (log4j-shutdown) 2014-10-30 14:12:48,942 DEBUG Unregistering MBean org.apache.logging.log4j2:type="ModuleClassLoader for Module \"deployment.EJBTutorial.ear.EJBTutorialEJB.jar:main\" from Service Module Loader",component=Appenders,name=MyFile
    14:12:48,983 INFO  [stdout] (log4j-shutdown) 2014-10-30 14:12:48,981 DEBUG Unregistering MBean org.apache.logging.log4j2:type="ModuleClassLoader for Module \"deployment.EJBTutorial.ear.EJBTutorialEJB.jar:main\" from Service Module Loader",component=Appenders,name=Console
    14:12:48,984 INFO  [org.apache.coyote.http11] (MSC service thread 1-8) JBWEB003075: Coyote HTTP/1.1 pausing on: http-localhost/127.0.0.1:8080
    14:12:48,985 INFO  [org.apache.coyote.http11] (MSC service thread 1-8) JBWEB003077: Coyote HTTP/1.1 stopping on : http-localhost/127.0.0.1:8080
    14:12:48,985 INFO  [stdout] (log4j-shutdown) 2014-10-30 14:12:48,985 DEBUG Stopped LoggerContext[name=ModuleClassLoader for Module "deployment.EJBTutorial.ear.EJBTutorialEJB.jar:main" from Service Module Loader, org.apache.logging.log4j.core.LoggerContext@478ea812]...
    14:12:48,986 INFO  [stdout] (log4j-shutdown) 2014-10-30 14:12:48,986 DEBUG ShutdownThread stopped LoggerContext[name=ModuleClassLoader for Module "deployment.EJBTutorial.ear.EJBTutorialEJB.jar:main" from Service Module Loader, org.apache.logging.log4j.core.LoggerContext@478ea812].
    14:12:49,457 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-7) JBAS015877: Arrêt du déploiement de null (runtime-name: "EJBTutorialConnector.rar") en 634ms
    14:12:49,457 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) JBAS015877: Arrêt du déploiement de null (runtime-name: "EJBTutorialEJB.jar") en 624ms
    14:12:49,542 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015877: Arrêt du déploiement de null (runtime-name: "EJBTutorialWeb.war") en 706ms
    14:12:49,546 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015877: Arrêt du déploiement de EJBTutorial.ear (runtime-name: "EJBTutorial.ear") en 698ms
    14:12:49,592 INFO  [org.jboss.as] (MSC service thread 1-7) JBAS015950: JBoss EAP 6.2.0.GA (AS 7.3.0.Final-redhat-14) arrêté en 733ms

  12. #12
    Modérateur
    Avatar de OButterlin
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    7 310
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 310
    Points : 9 522
    Points
    9 522
    Billets dans le blog
    1
    Par défaut
    J'ai fait le test sur un de mes EJB stateless et ça fonctionne parfaitement.
    J'utilise un logger java.util.logging.Logger mais ça devrait fonctionner de la même manière avec log4j
    Tu n'aurais pas un fichier de configuration sur ton serveur et un dans ton projet qui ne sont pas au même niveau ?
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  13. #13
    Membre actif
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    728
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 728
    Points : 250
    Points
    250
    Par défaut
    Voici la structure de mon projet

    Nom : Capture d’écran 2014-10-30 à 15.25.23.png
Affichages : 188
Taille : 127,2 Ko

    Nom : Capture d’écran 2014-10-30 à 15.26.18.png
Affichages : 178
Taille : 73,5 Ko

  14. #14
    Membre actif
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    728
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 728
    Points : 250
    Points
    250
    Par défaut
    J'ai oublié de montrer les librairies log4j

    Nom : Capture d’écran 2014-10-30 à 15.30.28.png
Affichages : 183
Taille : 93,2 Ko

  15. #15
    Modérateur
    Avatar de OButterlin
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    7 310
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 310
    Points : 9 522
    Points
    9 522
    Billets dans le blog
    1
    Par défaut
    Ben là, ça ne me parle pas trop... je vois juste qu'il y a du monde et pas mal de fichier de configuration de log4j...
    Dans le tas, je vérifierais que tous sont au même niveau de consignation et je regarderais également le paramétrage du serveur.

    A part ça, pourquoi ne pas mettre les bibliothèques directement sur le serveur, ça éviterait de les ajouter à chaque application.
    Autre question, c'est quelle version de JBoss ?
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  16. #16
    Membre actif
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    728
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 728
    Points : 250
    Points
    250
    Par défaut
    j'utilise JBoss eap 6.2.

    Je vais regarder le perametrage du serveur

Discussions similaires

  1. Réponses: 2
    Dernier message: 10/02/2010, 14h40
  2. Log4j.properties : désactiver les logs d'une seule classe
    Par zomurn dans le forum API standards et tierces
    Réponses: 1
    Dernier message: 04/01/2010, 12h50
  3. LOG4J Voir les logs d'une librairie
    Par *alexandre* dans le forum Logging
    Réponses: 1
    Dernier message: 01/07/2009, 13h33
  4. Réponses: 20
    Dernier message: 18/10/2006, 16h09
  5. une méthode qui écrit dans la sortie html ?
    Par iubito dans le forum Servlets/JSP
    Réponses: 2
    Dernier message: 03/12/2003, 15h34

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo