4 Replies Latest reply on Oct 9, 2008 11:15 AM by Jan Groth


    Bart DP Newbie


      I have a question about the logging.
      I want to know the flow of the application so I put some logger information in the code, first the class name and then the method name.


           public void setUsername(String username) {
                this.username = username;

      When I run the application I get an error on this log.info, a nullpointerexception. Why?

        • 1. Re: log.info
          Olivier Thierry Apprentice

          How do you inject log in your component ?
          What did you write in log config file ?
          It would be nice to post the entire class, not only the line where you have the NPE ;)

          • 2. Re: log.info
            Jan Groth Novice

            why? because the variable log is null...

            a rough guess: the logger has not been injected by Seam.
            - do you use the logger in the constructor? this is called before @In is executed

            you call always fall back to conventional logging

            private static final Logger LOGGER = Logger.getLogger(MyClass.class);

            class and method-name are in the standard logging output of the appender, no need to log that...

            hope that helps,
            pls post more code otherwise,


            • 3. Re: log.info
              Bart DP Newbie

              Ok, more information sounds logical.

              I used the annotation @Logger in my class, so the code is:

              @Table(name = "users")
              public class User implements Serializable {
                   private Log log;
                   private static final long serialVersionUID = 1L;
                   private int id;
                   private String username;
                   @Column(name = "userid")
                   public int getId() {
                        return id;
                   public void setId(int id) {
                        this.id = id;
                   @Column(name = "username")
                   public String getUsername() {
                        return username;
                   public void setUsername(String username) {
                        this.username = username;

              And regarding the book, Seam in action, injecting a @Logger instance, seam can automatically create an instance of a logger that is configured exclusively for the component into which it is injected.

              • 4. Re: log.info
                Jan Groth Novice

                code looks good :-)

                one possible explanation is that the seam interceptor is not registered at all.

                •   do you have ejb-jar.xml in the META-INF directory of your EAR-Project?

                •   do other @In-annotations of EJB-components work?