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?
What version of Seam are you using?
Have you tried using @Create instead of @PostConstruct ?