Am
21.11.2014 07:49, schrieb Thomas Mortagne:
> On Thu, Nov 20, 2014 at 10:45 PM, Stefan Bernsdorf
> <gruener.heinrich(a)web.de> wrote:
>> Thomas,
>> thanks. I managed to build my thread as an XWiki Job and also managed
>> to
>> add
>> it to the JobExecutor.
>> However, my initial problem still persists.
>> I am not able to add an attachment to a document in this job.
>> Find the stack trace below. Looking at the source of
>> XWikiHibernateBaseStore
>> tells me, it has something to do with the Execution context of the Job,
>> but
>> this should be managed by the job executor, right?
>> This is my code snip to add the attachment:
>> XWikiContext mycon = (XWikiContext)
>> execution.getContext().getProperty("xwikicontext");
> The ExecutionContext is initialized automatically but XWikiContext is
> something else and you should never try to get it directly from the
> ExecutionContext but use the provider instead as in:
>
> @Inject
> private Provider<XWikiContext> xcontextProvider;
>
>> XWikiDocument doc=mycon.getWiki().getDocument(m_adoc,
>> mycon);
>> XWikiAttachment att=doc.getAttachment(m_file);
>> if (att!=null) {
>> doc.deleteAttachment(att,mycon);
>> att=null;
>> }
>> if (att==null) {
>> att=doc.addAttachment(m_file,ins ,mycon);
>> XWikiAttachmentStoreInterface
>> ai=doc.getAttachmentStore(mycon);
>> XWikiHibernateAttachmentStore
>> hib=(XWikiHibernateAttachmentStore)ai;
>> hib.beginTransaction(mycon);
>> ai.saveAttachmentContent(att, mycon, true);
>> hib.endTransaction(mycon,true);
>> att.updateContentArchive(mycon);
>> }
>>
>>
>> This is the stack trace:
>> com.xpn.xwiki.XWikiException: Error number 3301 in 3: Exception while
>> switching to database xwiki
>> at
>>
>>
>>
com.xpn.xwiki.store.XWikiHibernateBaseStore.setDatabase(XWikiHibernateBaseStore.java:739)
>> ~[xwiki-platform-legacy-oldcore-6.2.1.jar:na]
>> at
>>
>>
>>
com.xpn.xwiki.store.XWikiHibernateBaseStore.beginTransaction(XWikiHibernateBaseStore.java:911)
>> ~[xwiki-platform-legacy-oldcore-6.2.1.jar:na]
>> at
>>
>>
>>
com.xpn.xwiki.store.XWikiHibernateBaseStore.beginTransaction(XWikiHibernateBaseStore.java:811)
>> ~[xwiki-platform-legacy-oldcore-6.2.1.jar:na]
>> at
>> org.centauron.xwiki.help.XWikiUpload.doCommand(XWikiUpload.java:68)
>> ~[centauron_xwiki.jar:na]
>> at
>> org.centauron.ant.TestScript.executeExtraData(TestScript.java:208)
>> ~[centauron_xwiki.jar:na]
>> at org.centauron.ant.TestProcess.doPost(TestProcess.java:249)
>> ~[centauron_xwiki.jar:na]
>> at org.centauron.ant.TestProcess.start(TestProcess.java:228)
>> ~[centauron_xwiki.jar:na]
>> at
>> org.centauron.xwiki.job.XWikiAntJob.internalCall(XWikiAntJob.java:112)
>> [centauron_xwiki.jar:na]
>> at
>> org.centauron.xwiki.job.XWikiAntJob.doStart(XWikiAntJob.java:98)
>> [centauron_xwiki.jar:na]
>> at org.centauron.xwiki.job.XWikiAntJob.run(XWikiAntJob.java:41)
>> [centauron_xwiki.jar:na]
>> at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown
>> Source)
>> [na:1.8.0_05]
>> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
>> Source)
>> [na:1.8.0_05]
>> at java.lang.Thread.run(Unknown Source) [na:1.8.0_05]
>> Caused by: java.lang.NullPointerException: null
>> at
>>
>>
>>
com.xpn.xwiki.store.migration.AbstractDataMigrationManager.getXWikiContext(AbstractDataMigrationManager.java:282)
>> ~[xwiki-platform-legacy-oldcore-6.2.1.jar:na]
>> at
>>
>>
>>
com.xpn.xwiki.store.migration.AbstractDataMigrationManager.getDataMigrationStatus(AbstractDataMigrationManager.java:406)
>> ~[xwiki-platform-legacy-oldcore-6.2.1.jar:na]
>> at
>>
>>
>>
com.xpn.xwiki.store.migration.AbstractDataMigrationManager.getDatabaseStatus(AbstractDataMigrationManager.java:548)
>> ~[xwiki-platform-legacy-oldcore-6.2.1.jar:na]
>> at
>>
>>
>>
com.xpn.xwiki.store.migration.AbstractDataMigrationManager.checkDatabase(AbstractDataMigrationManager.java:516)
>> ~[xwiki-platform-legacy-oldcore-6.2.1.jar:na]
>> at
>>
>>
>>
com.xpn.xwiki.store.XWikiHibernateBaseStore.setDatabase(XWikiHibernateBaseStore.java:735)
>> ~[xwiki-platform-legacy-oldcore-6.2.1.jar:na]
>> ... 12 common frames omitted
>> Am 20.11.2014 10:31, schrieb Thomas Mortagne:
>>
>>> Everything in XWiki is based on JobExecutor now so I can assure you it
>>> does not wait. Maybe your job is doing something slow in initialize.
>>>
>>> On Thu, Nov 20, 2014 at 10:24 AM, Stefan Bernsdorf
>>> <gruener.heinrich(a)web.de> wrote:
>>>> Thomas,
>>>> if I start a job using
>>>> jobExecutor.execute("antjob", req);
>>>> it waits until the job is finished.
>>>>
>>>> Am 20.11.2014 09:44, schrieb Thomas Mortagne:
>>>>
>>>>> As indicated in the javadoc of JobExecutor all jobs are executed
>>>>> asychronously. You actually need to use Job#join when you want to
>>>>> wait.
>>>>>
>>>>> On Thu, Nov 20, 2014 at 9:38 AM, Stefan Bernsdorf
>>>>> <gruener.heinrich(a)web.de> wrote:
>>>>>> Hi,
>>>>>> I have seen that the jobManager is deprecated since 6.1.
>>>>>> But how would I schedule a job and return immediately using the
>>>>>> jobExecutor?
>>>>>> (Using the jobManager it would be something like :
>>>>>> Job job = jobManager.addJob("jobtype", request))
>>>>>> Thanks , Stefan.
>>>>>> _______________________________________________
>>>>>> users mailing list
>>>>>> users(a)xwiki.org
>>>>>>
http://lists.xwiki.org/mailman/listinfo/users
>>>>>
>>>>>
>>>> _______________________________________________
>>>> users mailing list
>>>> users(a)xwiki.org
>>>>
http://lists.xwiki.org/mailman/listinfo/users
>>>
>>>
>> _______________________________________________
>> users mailing list
>> users(a)xwiki.org
>>
http://lists.xwiki.org/mailman/listinfo/users
>
>
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users