I'm to trying use a TimerService instance to schedule dynamically some
executions on a singleton EJB on a Tomee 1.6.0 server. The scheduling works
the first time, but on subsequent executions I get the following error (in
the Tomee console) and scheduling seem to stop working in the app:

mar 07, 2014 1:27:06 PM org.apache.openejb.cdi.CdiResourceInjectionService
fillInjectionProperties
WARNING: Injection data not found in JNDI context:
jndiName='comp/env/myapp.Bean/timerService', target=myapp.Bean/timerService
The EJB trying to achieve this looks like this:

package myapp;

@Singleton
public class Bean implements Serializable {
private static final long serialVersionUID = 1L;

    @Resource
    private transient TimerService timerService;

    private Timer oldTimer = null;

    public Bean() {
        super();
    }

    public void schedule(
            @Observes(during = TransactionPhase.AFTER_COMPLETION)
@ScheduleEvent ScheduleExpression schedule) {

        if (oldTimer != null) {
            oldTimer.cancel();
        }

        try {
            return oldTimer = timerService.createCalendarTimer(schedule, new
TimerConfig("TIMER", true));
        } catch (IllegalArgumentException e) {
            throw new EJBException(e);
        }
    }

    @Timeout
    @Lock(LockType.READ)
    private void timeout(Timer timer) {
          // Do stuff...
    }
}
The method schedule of Bean is triggered on an event fired from ConfigBean,
which monitors a ".properties" file (where the schedule timing information
is stored) and fires the necessary event whenever it detects any changes on
it:

@Singleton
@Startup
public class ConfigBean implements Serializable {
    @Inject
    @ScheduleEvent
    private Event<ScheduleExpression> scheduleEvent;

    //...
    private load() {
         //...
         //Loading routine
         //...
        
scheduleEvent.fire(ScheduleExpressionFactory.parse(scheduleExpression));
    }
    //...
}
Why does Tomee find the injection data the first time, and it doesn't the
next ones? How can I get it to work?

http://stackoverflow.com/questions/22251299/injection-data-not-found-in-jndi-context-when-injecting-timerservice-via-reso
<http://stackoverflow.com/questions/22251299/injection-data-not-found-in-jndi-context-when-injecting-timerservice-via-reso>
  



--
View this message in context: 
http://openejb.979440.n4.nabble.com/Injection-data-not-found-in-JNDI-context-when-injecting-TimerService-via-Resource-tp4668149.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to