tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jean-Louis MONTEIRO <jeano...@gmail.com>
Subject Re: "Injection data not found in JNDI context" when injecting TimerService via @Resource
Date Tue, 11 Mar 2014 13:35:47 GMT
Hi,

I haven't been able to reproduce, but maybe I did not understand.
Could check that example
http://people.apache.org/~jlmonteiro/cdi-events.tar.gz
And give it a try, please?

Lemm me know, if that is the same use case.

JLouis


2014-03-10 11:10 GMT+01:00 beto <segura.alberto@gmail.com>:

> 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.
>



-- 
Jean-Louis

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message