5 Replies Latest reply on Apr 13, 2009 10:33 PM by gonorrhea

    POJO, problem with @Log

    konstt2000

      Hi,


      I've a POJO:



      @Name("processStartAction")
      public class ProcessStartActionHandler implements ActionHandler{
      
              @In
              private Log log;
                      
              private static final long serialVersionUID = -4807265632134822532L;
      
              @Override
              public void execute(ExecutionContext arg0) throws Exception {
                                      
                      log.info("Begin ProcessStartActionHandler Entra en execute");
                      



      When It execute log.info the JBOSS launch NullPointerException.
      Have I to modify some file of configuration Seam?


      Thanks.


        • 1. Re: POJO, problem with @Log
          jkronegg

          You should use @Logger instead of @In.

          • 2. Re: POJO, problem with @Log
            konstt2000

            I've used @Logger and I've same problem..

            • 3. Re: POJO, problem with @Log
              gonorrhea

              The log instance is null (note: create=true is not required for @Logger).


              try restarting JBOss with your app deployed (as EAR/WAR, packaged or exploded, doesn't matter) and watch the server.log for any stack trace during startup and deployment of your app.


              There is something very basic you're doing wrong in terms of config or elsewhere.


              And always use @Logger, not @In, for injecting the Log instance...


              also, double-check to make sure there is a log4j.jar in JBoss classpath (i.e. \server\xxx\lib)

              • 4. Re: POJO, problem with @Log
                konstt2000

                How can I inject EntityManager?
                I've same problem... I've tring with @In and @PersistenContext.

                • 5. Re: POJO, problem with @Log
                  gonorrhea

                  when you inject EntityManager instance using @In, the instance name of EntityManager must match the name attribute's value for the SMPC tag in components.xml.


                  ex:


                     <persistence:managed-persistence-context name="entityManager"
                                                       auto-create="true"
                                        persistence-unit-jndi-name="java:/boBETSEntityManagerFactory"/> 



                  then inject like this:


                  @In EntityManager entityManager;



                  not like this:


                  @In EntityManager em;



                  NOTE: you generally don't use @PersistenceContext in Seam apps.