Hi Florian,

is your EntityManager request-scoped? If so, you need to either start the request scope through "startScopes", or re-scope your EM.

As to the first issue, did you include an implementation of ContainerControl in your project? This is not yet documented, but you need to have a runtime dependency on e.g. org.apache.deltaspike.cdictrl: deltaspike-cdictrl-weld if you use Weld (and similarly for other CDI impls) anytime you use the Scheduler module.

Also, I think this belongs to us...@deltaspike.apache.org :)

Regards,
Ron

On 2.4.2015 14:09, Florian Limpöck wrote:
Hello Deltaspike Team,

I try to make a scheduled send mail application, for a monthly reminder.

My Code looks like this and it works until the point i try to use my Injection.

@Scheduled(cronExpression = "0 0/1 * * * ?")
public class SimpleJob implements Job {

     @Inject
     ProjektRepository projektRepository;

     @Override
     public void execute(JobExecutionContext context) throws 
JobExecutionException {
         System.out.println("Test");

         List<Projekt> projektList = projektRepository.getAll();

         System.out.println(projektList.get(0).getName());
     }
}


I get the following Error:

11:14:00,008 ERROR [org.quartz.core.ErrorLogger] 
(DefaultQuartzScheduler_Worker-1) Unable to notify JobListener(s) of Job to be 
executed: (Job will NOT be executed!). trigger= 
DEFAULT.6da64b5bd2ee-cac2ad65-b6c9-4cfa-8402-6b5ccc8a1467 job= 
DEFAULT.SimpleJob: org.quartz.SchedulerException: JobListener 
'org.apache.deltaspike.scheduler.impl.QuartzScheduler$InjectionAwareJobListener'
 threw exception: Could not find beans for Type=interface 
org.apache.deltaspike.cdise.api.ContextControl and qualifiers:[] [See nested 
exception: java.lang.IllegalStateException: Could not find beans for 
Type=interface org.apache.deltaspike.cdise.api.ContextControl and qualifiers:[]]
        at 
org.quartz.core.QuartzScheduler.notifyJobListenersToBeExecuted(QuartzScheduler.java:1947)
 [quartz-2.2.1.jar:]
        at 
org.quartz.core.JobRunShell.notifyListenersBeginning(JobRunShell.java:324) 
[quartz-2.2.1.jar:]
        at org.quartz.core.JobRunShell.run(JobRunShell.java:173) 
[quartz-2.2.1.jar:]
        at 
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) 
[quartz-2.2.1.jar:]
Caused by: java.lang.IllegalStateException: Could not find beans for 
Type=interface org.apache.deltaspike.cdise.api.ContextControl and qualifiers:[]
        at 
org.apache.deltaspike.core.api.provider.BeanProvider.getContextualReference(BeanProvider.java:150)
 [deltaspike-core-api-1.0.1.jar:1.0.1]
        at 
org.apache.deltaspike.core.api.provider.BeanProvider.getContextualReference(BeanProvider.java:119)
 [deltaspike-core-api-1.0.1.jar:1.0.1]
        at 
org.apache.deltaspike.core.api.provider.BeanProvider.getContextualReference(BeanProvider.java:100)
 [deltaspike-core-api-1.0.1.jar:1.0.1]
        at 
org.apache.deltaspike.scheduler.impl.QuartzScheduler$JobListenerContext.startContexts(QuartzScheduler.java:427)
 [deltaspike-scheduler-module-impl-1.0.1.jar:1.0.1]
        at 
org.apache.deltaspike.scheduler.impl.QuartzScheduler$InjectionAwareJobListener.jobToBeExecuted(QuartzScheduler.java:372)
 [deltaspike-scheduler-module-impl-1.0.1.jar:1.0.1]
        at 
org.quartz.core.QuartzScheduler.notifyJobListenersToBeExecuted(QuartzScheduler.java:1945)
 [quartz-2.2.1.jar:]
        ... 3 more


I try to add startScopes={} because of this ticket 
https://issues.apache.org/jira/browse/DELTASPIKE-656, then the job is executed, 
but then I got this exception.


11:10:00,001 INFO  [stdout] (DefaultQuartzScheduler_Worker-6) Test
11:10:00,003 ERROR [org.quartz.core.JobRunShell] 
(DefaultQuartzScheduler_Worker-4) Job DEFAULT.SimpleJob threw an unhandled 
Exception: : org.jboss.weld.context.ContextNotActiveException: WELD-001303: No 
active contexts for scope type javax.enterprise.context.RequestScoped
        at 
org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:680) 
[weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
        at 
org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:79)
 [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
        at 
org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:99) 
[weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
        at 
org.jboss.weld.proxies.EntityManager$1197393252$Proxy$_$$_WeldClientProxy.getCriteriaBuilder(Unknown
 Source) [weld-core-impl-2.1.2.Final.jar:]
        at 
com.xy.repository.AbstractRepository.getAll(AbstractRepository.java:75) 
[classes:]
        at com.xy.quartz.SimpleJob.execute(SimpleJob.java:28) [classes:]
        at org.quartz.core.JobRunShell.run(JobRunShell.java:202) 
[quartz-2.2.1.jar:]
        at 
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) 
[quartz-2.2.1.jar:]

11:10:00,004 ERROR [org.quartz.core.ErrorLogger] 
(DefaultQuartzScheduler_Worker-4) Job (DEFAULT.SimpleJob threw an exception.: 
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested 
exception: org.jboss.weld.context.ContextNotActiveException: WELD-001303: No 
active contexts for scope type javax.enterprise.context.RequestScoped]
        at org.quartz.core.JobRunShell.run(JobRunShell.java:213) 
[quartz-2.2.1.jar:]
        at 
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) 
[quartz-2.2.1.jar:]
Caused by: org.jboss.weld.context.ContextNotActiveException: WELD-001303: No 
active contexts for scope type javax.enterprise.context.RequestScoped
        at 
org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:680) 
[weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
        at 
org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:79)
 [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
        at 
org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:99) 
[weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
        at 
org.jboss.weld.proxies.EntityManager$1197393252$Proxy$_$$_WeldClientProxy.getCriteriaBuilder(Unknown
 Source) [weld-core-impl-2.1.2.Final.jar:]
        at 
com.xy.repository.AbstractRepository.getAll(AbstractRepository.java:75) 
[classes:]
        at com.xy.quartz.SimpleJob.execute(SimpleJob.java:28) [classes:]
        at org.quartz.core.JobRunShell.run(JobRunShell.java:202) 
[quartz-2.2.1.jar:]
        ... 1 more


I use Deltaspike 1.3.0.

I also tried everything with 1.0.1 because it was the Fixed Version mentioned 
in the ticket above.

Am I missing something? or is there any example, which shows how to get started 
with Deltaspike and Quartz besides the documentation.

Thanks,
Florian

--
Ron Smeral
JBoss Quality Engineer
Brno

Reply via email to