On Thu, Sep 26, 2013 at 11:20 AM, Jeremie BOUSQUET
<[email protected]> wrote:
> Hello,
>
> I'm trying to use the Job Module [1] for my own needs.
> I know some of its APIs are marked as unstable, but well I wanted to give
> it a try.
>
> I'm on a XWiki 4.5.2 instance currently.
>
> So I created some dummy interface:
>
> @Role
> public interface ILoadingJob extends Job
> {
> }
Job is already a @Role so I don't understand why override it with ILoadingJob.
>
> A Job implementation:
>
> @Component
> @Named(LoadingJob.JOBTYPE)
> public class LoadingJob extends AbstractJob<DefaultRequest> implements
> ILoadingJob, Initializable
> {
> public static final String JOBTYPE = "mailarchivejob";
>
> // ...
> }
>
> In debug mode, I run the following:
>
> this.componentManager.getComponentDescriptorList(org.xwiki.job.Job.class)
>
> It returns:
>
> [implementation = [org.xwiki.contrib.mailarchive.internal.LoadingJob],
> instantiation = [PER_LOOKUP], implementation =
> [org.xwiki.extension.job.internal.UpgradePlanJob], ... ]
>
> So it seems OK.
>
> I have the following code to create and execute my Job:
>
> DefaultRequest request = new DefaultRequest();
> request.setId("test");
> request.setInteractive(false);
> // ... other properties set
> LoadingJob job = (LoadingJob)
> jobManager.executeJob("mailarchivejob", request);
>
> But this code fails with following stack trace:
>
> org.xwiki.job.JobException: Failed to lookup any Job for role hint
> [mailarchivejob]
> at
> org.xwiki.job.internal.DefaultJobManager.createJob(DefaultJobManager.java:185)
> at
> org.xwiki.job.internal.DefaultJobManager.addJob(DefaultJobManager.java:208)
> at
> org.xwiki.job.internal.DefaultJobManager.executeJob(DefaultJobManager.java:194)
> at
> org.xwiki.contrib.mailarchive.internal.MailArchiveScriptService.createLoadingJob(MailArchiveScriptService.java:112)
> at
> org.xwiki.contrib.mailarchive.internal.MailArchiveScriptService.load(MailArchiveScriptService.java:94)
> [...]
> Caused by: org.xwiki.component.manager.ComponentLookupException: Can't find
> descriptor for the component [role = [interface org.xwiki.job.Job] hint =
> [mailarchivejob]]
> at
> org.xwiki.component.embed.EmbeddableComponentManager.getComponentInstance(EmbeddableComponentManager.java:355)
> at
> org.xwiki.component.embed.EmbeddableComponentManager.getInstance(EmbeddableComponentManager.java:161)
> at
> org.xwiki.job.internal.DefaultJobManager.createJob(DefaultJobManager.java:183)
> [...]
>
> I also tried to manually register my custom Job component, in the
> initialize() of a side component (I checked that this code got executed
> previously to job creation), but with no different result:
>
> // Register custom job
>
> this.componentManager.registerComponent(this.componentManager.getComponentDescriptor(Job.class,
> "mailarchivejob"));
>
> Do you see something wrong in my approach ?
>
> Thanks,
> Jeremie
> _______________________________________________
> users mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/users
--
Thomas Mortagne
_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users