On Sun, Sep 29, 2013 at 9:25 AM, Jeremie BOUSQUET <[email protected]> wrote:
2013/9/28 Jeremie BOUSQUET <[email protected]>
Hello again
Moving on to XWiki 5.1 did the trick, except that I run into another trouble ...
When my job is starting, I get a NPE:
Exception in thread "Job Manager daemon thread" java.lang.NullPointerException at org.xwiki.job.internal.AbstractJob.jobStarting(AbstractJob.java:170) at org.xwiki.job.internal.AbstractJob.run(AbstractJob.java:134) at org.xwiki.job.internal.DefaultJobManager.runJob(DefaultJobManager.java:131) at org.xwiki.job.internal.DefaultJobManager.run(DefaultJobManager.java:110) at java.lang.Thread.run(Unknown Source)
It's on following "this.logger..." line in AbstractJob:
if (getStatus().getRequest().getId() != null) {
this.logger.info("Starting job of type [{}] with identifier [{}]", getType(), getStatus().getRequest()
.getId()); } else {
I checked and getType() is not null. The other can't be. So could it be that this.logger is null ? Could it be again a pb of root component manager ?
Sorry I solved this, problem was that I @Inject-ed a Logger into my LoadingJob class. Somehow it caused the logger to be null.
When you override a field, XWiki component manager only see one and does not inject the abstract one.
Thanks, Jeremie
BR, Jeremie
2013/9/26 Jeremie BOUSQUET <[email protected]>
Oups... ;)
No I'm on 4.2, but I suppose I'll be on 5.x soon... Le 26 sept. 2013 18:52, "Thomas Mortagne" <[email protected]> a écrit :
addJob(Job job) not addJob(String jobType, Request request) ;)
But maybe you are not on 5.1 yet.
On Thu, Sep 26, 2013 at 6:28 PM, Jeremie BOUSQUET <[email protected]> wrote:
2013/9/26 Thomas Mortagne <[email protected]>
On Thu, Sep 26, 2013 at 5:13 PM, Thomas Mortagne <[email protected]> wrote: > On Thu, Sep 26, 2013 at 4:40 PM, Jeremie BOUSQUET > <[email protected]> wrote: >> 2013/9/26 Thomas Mortagne <[email protected]> >> >>> On Thu, Sep 26, 2013 at 1:08 PM, Jeremie BOUSQUET >>> <[email protected]> wrote: >>> > 2013/9/26 Thomas Mortagne <[email protected]> >>> > >>> >> 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. >>> >> >>> > >>> > I completely removed the ILoadingJob interface, but still the same issue >>> > occurs. >>> >>> Appart from this I did not seen anything wrong in your code. Are you >>> able to do this.componentManager.getInstance(Job.class, >>> "mailarchivejob"); ? >>> >> >> I added the line of code, that revealed a number of errors in my component. >> I fixed them, and now this getInstance(...) appropriately returns a >> LoadingJob object. I've put the code just before my code calling >> executeJob(). >> But even after these corrections, I still get the same issue on >> executeJob(). BTW, I have same problem when calling addJob(). >> >> >>> >>> Is you jar installed as extension ? >>> >> >> Yes it is. >> As I'm currently using some SNAPSHOT version, I installed it once with EM >> (linked to a local nexus repository), and now I patch the jar under >> $XWIKI_DATA_DIR/data/extensions/repository/..., during server restart. > > That's it then, I re-checked the DefaultJobManager and it only look at > root component manager. Fixing it in 5.2RC1.
In the meantime you can use addJob(Job).
addJob(Job) has the same problem:
org.xwiki.job.JobException: Failed to lookup any Job for role hint [mailarchivejob] at
org.xwiki.job.internal.DefaultJobManager.createJob(DefaultJobManager.java:185)
~[xwiki-commons-job-4.5.2.jar:na] at
org.xwiki.job.internal.DefaultJobManager.addJob(DefaultJobManager.java:208)
~[xwiki-commons-job-4.5.2.jar:na] at
org.xwiki.contrib.mailarchive.script.MailArchiveScriptService.createLoadingJob(MailArchiveScriptService.java:140)
[org.xwiki.contrib.mailarchive%253Axwiki-contrib-mailarchive-api-0.3-SNAPSHOT.jar:na]
> >> >> >>> >>> > >>> > >>> >> >>> >> > >>> >> > 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 >>> >> >>> > _______________________________________________ >>> > 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 >>> >> _______________________________________________ >> users mailing list >> [email protected] >> http://lists.xwiki.org/mailman/listinfo/users > > > > -- > Thomas Mortagne
-- Thomas Mortagne _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
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
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne