hi,

your nested job-class needs to be static.

-> in your example:
//...
public static class CustomJob implements Job { /*...*/ }
//...

regards,
gerhard

http://www.irian.at

Your JavaEE powerhouse -
JavaEE Consulting, Development and
Courses in English and German

Professional Support for Apache
MyFaces, DeltaSpike and OpenWebBeans



2014-10-30 23:03 GMT+01:00 Tvori Kod <[email protected]>:

> Hi,
>
> Sorry I sended the question incomplete (wrong key pressed). Here is the
> complete question.
>
> CustomJob is a nested class  annotated with @Scheduled inside in class
> annotated with @ApplicationScoped and @Named.
>
>
> @Named
> @ApplicationScoped
> public class ApplicationBean implements Serializable {
>
> ...
>
>     @Scheduled(cronExpression = "0/5 * * * * ?")
>     public class CustomJob implements Job {
>
>         public CustomJob() {}
>
>         @Override
>         public void execute(JobExecutionContext context) throws
> JobExecutionException {
>             System.out.println(System.currentTimeMillis());
>         }
>     }
>
> ...
> }
>
> When Wildfly (8.1.0.Final, patched Weld 2.2.5) is starting throws the next
> exception:
>
> 15:49:55,001 ERROR [org.quartz.core.ErrorLogger]
> (DefaultQuartzScheduler_QuartzSchedulerThread) An error occured
> instantiating job to be executed. job= 'DEFAULT.CustomJob':
> org.quartz.SchedulerException: Problem instantiating class
> 'com.app.ApplicationBean$CustomJob' [See nested exception:
> java.lang.InstantiationException: com.app.ApplicationBean$CustomJob]
>     at org.quartz.simpl.SimpleJobFactory.newJob(SimpleJobFactory.java:58)
>     at
>
> org.quartz.simpl.PropertySettingJobFactory.newJob(PropertySettingJobFactory.java:69)
>     at org.quartz.core.JobRunShell.initialize(JobRunShell.java:127)
>     at
> org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:375)
> Caused by: java.lang.InstantiationException:
> com.app.ApplicationBean$CustomJob
>     at java.lang.Class.newInstance(Class.java:359) [rt.jar:1.7.0_67]
>     at org.quartz.simpl.SimpleJobFactory.newJob(SimpleJobFactory.java:56)
>     ... 3 more
>
> I'm using the last snapshot of 1.4 Deltaspike version and  JSF 2.2.
>
> There is a some problem creating the instance of nested class. When I'm
> not using nested class is working well. If the nested class is static also
> work well.
>
> On Thu, Oct 30, 2014 at 3:54 PM, Tvori Kod <[email protected]> wrote:
>
> > Hi,
> >
> > CustomJob is a nested class  annotated with @Scheduled inside in class
> > annotated with @ApplicationScoped and @Named
> >
> >
> > @Named("appBean")
> > @ApplicationScoped
> > public class ApplicationBean implements Serializable {
> >
> >
> > @Scheduled(cronExpression = "0/5 * * * * ?")
> >     public class CustomJob implements Job {
> >
> >         public CustomJob() {}
> >
> >         @Override
> >         public void execute(JobExecutionContext context) throws
> > JobExecutionException {
> >             System.out.println(System.currentTimeMillis());
> >         }
> >     }
> >
>

Reply via email to