5 Replies Latest reply on Apr 5, 2008 5:16 PM by pmuir

    Component called twice

    hicham

      I have a class that checks the default timezone:



      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.annotations.Startup;
      import org.jboss.seam.log.Log;
      import org.jboss.seam.log.Logging;
      
      @Name("environmentCheck")
      @Scope(ScopeType.APPLICATION)
      @Startup
      public class EnvironmentCheck {
           private static final Log log = Logging.getLog(EnvironmentCheck.class);
           public EnvironmentCheck() {
                log.info("Starting Environment Check...");
                      ...
                log.info("Environment looks good.");
           }
      }
      



      When I run my tests using TestNg, everything works fine. However, the environmentCheck component is called twice before each test.


      [Parser] Running: ...myTest.xml
      
      INFO  [EnvironmentCheck] Starting Environment Check...
      INFO  [EnvironmentCheck] TimeZone: Greenwich Mean Time
      INFO  [EnvironmentCheck] Environment looks good.
      INFO  [EnvironmentCheck] Starting Environment Check...
      INFO  [EnvironmentCheck] TimeZone: Greenwich Mean Time
      INFO  [EnvironmentCheck] Environment looks good.
      PASSED: initTests
      
      ===============================================
          Init Tests 
          Tests run: 1, Failures: 0, Skips: 0
      ===============================================
      



      More over, when I start my Jboss-seam application, this component is still called twice.


      INFO  [Contexts] starting up: environmentCheck
      INFO  [EnvironmentCheck] Starting Environment Check...
      INFO  [EnvironmentCheck] TimeZone: Greenwich Mean Time
      INFO  [EnvironmentCheck] Environment looks good.
      INFO  [EnvironmentCheck] Starting Environment Check...
      INFO  [EnvironmentCheck] TimeZone: Greenwich Mean Time
      INFO  [EnvironmentCheck] Environment looks good.
      



      Also, there is another redundant log.


      [CacheManager] Selected [org.ajax4jsf.cache.LRUMapCacheFactory] cache factory
      INFO  [LRUMapCacheFactory] Creating LRUMap cache instance using parameters: {com.sun.faces.injectionProvider=org.jboss.web.jsf.integration.injection.JBossInjectionProvider, facelets.DEVELOPMENT=true, org.richfaces.SKIN=blueSky, javax.faces.DEFAULT_SUFFIX=.xhtml}
      INFO  [LRUMapCacheFactory] Creating LRUMap cache instance of default capacity
      INFO  [CacheManager] Selected [org.ajax4jsf.cache.LRUMapCacheFactory] cache factory
      INFO  [LRUMapCacheFactory] Creating LRUMap cache instance using parameters: {com.sun.faces.injectionProvider=org.jboss.web.jsf.integration.injection.JBossInjectionProvider, facelets.DEVELOPMENT=true, org.richfaces.SKIN=blueSky, javax.faces.DEFAULT_SUFFIX=.xhtml}
      INFO  [LRUMapCacheFactory] Creating LRUMap cache instance of default capacity
      




      My application runs over Seam 2.0.1.GA-JBoss 4.2.2.GA.


      Why does my component called twice? This is really weired.


      When debugging, firstly my application executes
      EnvironmentCheck.<init>() line: 23
      then it executes
      EnvironmentCheck_$$_javassist_0(EnvironmentCheck).<init>() line: 23


      does anyone have an explanation for this?


      Thanks,


      Hicham