1 Reply Latest reply on Dec 3, 2008 7:27 PM by luxspes

    Injection with @In not working with Application-scoped components?

    marios

      Hi, all I have



      @Stateful
      @Name( "remoteRequestScheduler" ) @Scope( ScopeType.APPLICATION ) @Startup
      public class RemoteRequestSchedulerImpl implements RemoteRequestScheduler {
      
              @In private RemoteRequestDAO remoteRequestDAO;
              // ...  
          
              @PostConstruct  
              public void startUp() {
                      ensureDAOs();
                      logger.info( "Remote Request Scheduler starting ..." );
                      // remoteRequestDAO == null so I get an NPE!
                      remoteRequestDAO.removeAll();
              }
      
      
              @Remove @Destroy 
              public void shutDown() { ... }
      }



      This way I get the NPE when trying to use the DAO. Instead, if I get the component by name by calling:


      remoteRequestDAO = (RemoteRequestDAO) Component.getInstance( "remoteRequestDAO" );


      before using the DAO, then the instance is ready to be used. This is odd since every other place where I use @In the required attribute is true by default and so SEAM throws an exception because it doesn't find the dependency. In this case it just silently passes over: is this the expected behavior?