[jboss-user] [JBoss Seam] - @Startup help...

bsmithjj do-not-reply at jboss.com
Thu Jan 25 10:14:36 EST 2007


I am trying to do the following:

On startup of my application, create an EJB Timer (javax.ejb.Timer) using the EJB TimerService (javax.ejb.TimerService).

The timer bean that I am trying to install is a stateless session bean.

I initially tried to use @PostConstruct on a method that would use the TimerService (@Resource private TimerService timerService) to create my timer.  This didn't work immediately, so I figured, no instances of my stateless session bean have been created - fine, I turned to @Startup to create bootstrap component that gets a handle to the stateless session bean and invokes its starter method.  Now I'm not sure what dependencies I need to add to the @Startup(depends={...}) list.

I know that I need the following resources available before my @Startup component's @Create method is called:

- my stateless session bean needs to be deployed
- the persistence context for my EJB jar needs to be available for injection

I've noticed that the @In annotation doesn't seem to work for my @Startup component (i.e. I can't get a reference to my stateless session bean);  so I looked up the reference manually:

  |         MyBean myBean = null;
  |         try {
  |             myBean = (MyBean)Naming.getInitialContext().lookup("my-ear/MyBean/local");
  |             mailReader.startReading();
  |         } catch (NamingException e) {
  |             log.error(e,e);
  |         }

I can get a reference but invariably some other dependency fails (a @Factory component, etc...).

Is there someway of telling @Startup something to the effect of:

"start me up after everything else" ?

Is there a better way of installing a timer in Seam?

Brad Smith

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4006380#4006380

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4006380

More information about the jboss-user mailing list