users@glassfish.java.net

Re: Same JSF request seems to execute page twice w/ diff backing bean insta

From: <glassfish_at_javadesktop.org>
Date: Mon, 21 Apr 2008 20:42:34 PDT

You won't beleive me but I struggled with this three days, googled through all possible forums and finally resolved this in the weirdest way you can imagine - just slightly change the logger initialization. I'm not sure if this is universal solution or just private case, but in my case the wrong code looked like this:

-----------------------
public class SimpleTestBean {
        protected final Log log = LogFactory.getLog("mywebapp");
 
        String count;
 
        public SimpleTestBean() {
                log.info("SimpleTestBean() - ENTER");
        }
 
}
------------------------


where 'Log' is apache common logger configured to use log4j as its backend. The bean constructor was called twice - always. After I changed slightly logger initiation my problem of double backing bean initialization has gone:

----------------------
public class SimpleTestBean {
        protected final Log log = LogFactory.getLog(SimpleTestBean.class);
 
        String count;
 
        public SimpleTestBean() {
                log.info("SimpleTestBean() - ENTER");
        }
 
}
------------------------

It looks like some logger configuration details caused a conflict. I still trying to figure out what was the problem root cause, but least I found a cure :)
[Message sent by forum member 'vkroz' (vkroz)]

http://forums.java.net/jive/thread.jspa?messageID=270506