1 Reply Latest reply on Dec 3, 2008 7:27 PM by Francisco Jose Peredo Noguez

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

    Mario Scalas Newbie

      Hi, all I have

      @Name( "remoteRequestScheduler" ) @Scope( ScopeType.APPLICATION ) @Startup
      public class RemoteRequestSchedulerImpl implements RemoteRequestScheduler {
              @In private RemoteRequestDAO remoteRequestDAO;
              // ...  
              public void startUp() {
                      logger.info( "Remote Request Scheduler starting ..." );
                      // remoteRequestDAO == null so I get an NPE!
              @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?