This content has been marked as final.
Show 8 replies
-
1. Re: @Logger does not inject
waynebagguley Mar 27, 2007 11:48 AM (in response to laksu)Are there any errors in the application server logs?
-
2. Re: @Logger does not inject
laksu Mar 27, 2007 12:42 PM (in response to laksu)Nope, nothing noteworthy, no Exceptions.
If I remove log4j.xml I naturally get
log4j:WARN No appenders could be found for logger (org.hibernate.ejb.Version).
log4j:WARN Please initialize the log4j system properly. -
3. Re: @Logger does not inject
gavin.king Mar 27, 2007 12:49 PM (in response to laksu)Do you have this annotation in a Seam component, ie. a class with an @Name?
-
4. Re: @Logger does not inject
kukeltje Mar 27, 2007 4:42 PM (in response to laksu)always null, or just in the constructor?
-
5. Re: @Logger does not inject
gavin.king Mar 27, 2007 5:12 PM (in response to laksu)Good point, Seam does not do any kind of injection until the object is fully constructed.
However, if you declare a @Logger field static, it will be init'd even in the constructor ;-) -
6. Re: @Logger does not inject
laksu Mar 28, 2007 10:27 AM (in response to laksu)Not in the constructor. Here is my class:
package datassist.gop.action; import datassist.gop.domain.Istek; import java.util.ArrayList; import java.util.List; import javax.ejb.Remove; import javax.ejb.Stateful; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.persistence.PersistenceContextType; import org.jboss.seam.annotations.Create; import org.jboss.seam.annotations.Destroy; import org.jboss.seam.annotations.Logger; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.datamodel.DataModel; import org.jboss.seam.log.Log; @Stateful @Name("istekler") public class IsteklerAction implements IsteklerActionLocal { @PersistenceContext(type=PersistenceContextType.EXTENDED) private EntityManager em; public IsteklerAction() { } @Create public void init(){ System.out.println("initing istekler. logger is "+((logger==null)?"null":"not null")); // logger.debug("initing"); refresh(); } @DataModel private List<Istek> istekList=new ArrayList<Istek>(); public void refresh(){ System.out.println("refreshing istekler"); // logger.debug("refreshing"); istekList=em.createQuery("from Istek i").getResultList(); } public void logSomething(){ System.out.println("Trying to log something dummy and the logger is "+((logger==null)?"null":"not null")); // logger.debug("Logging something dummy"); } @Logger private Log logger; @Remove @Destroy public void destroy(){} }
-
7. Re: @Logger does not inject
gavin.king Mar 28, 2007 11:03 AM (in response to laksu)And how do you create an instance of this class?
-
8. Re: @Logger does not inject
laksu Mar 28, 2007 11:44 AM (in response to laksu)I have
<h:commandButton value="Log" action="#{istekler.logSomething}"/>
in my .xhtml file and click the button to invoke the logSomething method, so it is created by Seam.