Re: [xwiki-users] Not able to read attachments from server thread

2014-11-13 Thread Thomas Mortagne
That's probably because you don't properly initialize your thread
(initialize an ExecutionContext and stuff like this). You can use
org.xwiki.context.concurrent.ExecutionContextRunnable to help with
this. Also to get a proper XWikiContext it's usually better to use
ProviderXWikiContext (either by injecting it or by using
XWikiContext#TYPE_PROVIDER as role type).

On Wed, Nov 12, 2014 at 11:14 PM, Stefan Bernsdorf
gruener.heinr...@web.de wrote:

 Hi,

 the Job Module looks promising,
 however this is the stack:
 CONTENT IS NUL!com.xpn.xwiki.XWikiException: Error number 3231 in 3:
 Exc
 eption while loading attachment myseedfile.dgn of document
 microtest_oto.Templates_Test-Stefan
 at
 com.xpn.xwiki.store.XWikiHibernateAttachmentStore.loadAttachmentContent(XWikiHibernateAttachmentStore.java:233)
 at
 com.xpn.xwiki.doc.XWikiDocument.loadAttachmentContent(XWikiDocument.java:4600)
 at
 com.xpn.xwiki.doc.XWikiAttachment.getContentInputStream(XWikiAttachment.java:576)
 at
 org.centauron.xwiki.help.XWikiAttachmentCopy.doCommand(XWikiAttachmentCopy.java:79)
 at
 org.centauron.ant.TestScript.executeExtraData(TestScript.java:208)
 at org.centauron.ant.TestProcess.doPre(TestProcess.java:246)
 at org.centauron.ant.TestProcess.start(TestProcess.java:212)
 at
 org.centauron.ant.TestProcesses.startNextProcess(TestProcesses.java:114)
 at org.centauron.ant.TestProcesses.run(TestProcesses.java:54)
 at java.lang.Thread.run(Unknown Source)
 Caused by: 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)
 at
 com.xpn.xwiki.store.XWikiHibernateBaseStore.beginTransaction(XWikiHibernateBaseStore.java:911)
 at
 com.xpn.xwiki.store.XWikiHibernateBaseStore.beginTransaction(XWikiHibernateBaseStore.java:826)
 at
 com.xpn.xwiki.store.XWikiHibernateAttachmentStore.loadAttachmentContent(XWikiHibernateAttachmentStore.java:207)
 ... 9 more
 Caused by: java.lang.NullPointerException
 at
 com.xpn.xwiki.store.migration.AbstractDataMigrationManager.getXWikiContext(AbstractDataMigrationManager.java:282)
 at
 com.xpn.xwiki.store.migration.AbstractDataMigrationManager.getDataMigrationStatus(AbstractDataMigrationManager.java:406)
 at
 com.xpn.xwiki.store.migration.AbstractDataMigrationManager.getDatabaseStatus(AbstractDataMigrationManager.java:548)
 at
 com.xpn.xwiki.store.migration.AbstractDataMigrationManager.checkDatabase(AbstractDataMigrationManager.java:516)
 at
 com.xpn.xwiki.store.XWikiHibernateBaseStore.setDatabase(XWikiHibernateBaseStore.java:735)
 ... 12 more

 Am 12.11.2014 13:45, schrieb Thomas Mortagne:

 Could you copy the complete error, you should have a more detailed cause.

 On Wed, Nov 12, 2014 at 11:39 AM, Stefan Bernsdorf
 gruener.heinr...@web.de wrote:

 Hi,
 I created a Macro in xwiki.
 In this macro a server process is started that tries to read attachments.
 For this, I created a XWikiCOntext to access the Wiki.
 This is the code:
  XWikiStubContextProvider
 prov=Utils.getComponent(XWikiStubContextProvider.class);
  prov.initialize(template);
  XWikiContext con=prov.createStubContext();
  con.setUser(XWiki.TestProcess, true);
  con.setVirtual(true);

 Unfortunately it is not possible to access the attachment content using
 this
 context.
 The following error is thrown:
 com.xpn.xwiki.XWikiException: Error number 3231 in 3: Exception while
 loading attachment myseedfile.dgn of document
 microtest_oto.Templates_Test-Stefan
  at

 com.xpn.xwiki.store.XWikiHibernateAttachmentStore.loadAttachmentContent(XWikiHibernateAttachmentStore.java:233)
  at

 com.xpn.xwiki.doc.XWikiDocument.loadAttachmentContent(XWikiDocument.java:4600)
  at

 com.xpn.xwiki.doc.XWikiAttachment.getContentInputStream(XWikiAttachment.java:576)
  at

 org.centauron.xwiki.help.XWikiAttachmentCopy.doCommand(XWikiAttachmentCopy.java:79)
  

 Any help would be appreciated.
 Regards, Stefan.

 ___
 users mailing list
 users@xwiki.org
 http://lists.xwiki.org/mailman/listinfo/users





 ___
 users mailing list
 users@xwiki.org
 http://lists.xwiki.org/mailman/listinfo/users



-- 
Thomas Mortagne
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Not able to read attachments from server thread

2014-11-12 Thread Thomas Mortagne
Could you copy the complete error, you should have a more detailed cause.

On Wed, Nov 12, 2014 at 11:39 AM, Stefan Bernsdorf
gruener.heinr...@web.de wrote:

 Hi,
 I created a Macro in xwiki.
 In this macro a server process is started that tries to read attachments.
 For this, I created a XWikiCOntext to access the Wiki.
 This is the code:
 XWikiStubContextProvider
 prov=Utils.getComponent(XWikiStubContextProvider.class);
 prov.initialize(template);
 XWikiContext con=prov.createStubContext();
 con.setUser(XWiki.TestProcess, true);
 con.setVirtual(true);

 Unfortunately it is not possible to access the attachment content using this
 context.
 The following error is thrown:
 com.xpn.xwiki.XWikiException: Error number 3231 in 3: Exception while
 loading attachment myseedfile.dgn of document
 microtest_oto.Templates_Test-Stefan
 at
 com.xpn.xwiki.store.XWikiHibernateAttachmentStore.loadAttachmentContent(XWikiHibernateAttachmentStore.java:233)
 at
 com.xpn.xwiki.doc.XWikiDocument.loadAttachmentContent(XWikiDocument.java:4600)
 at
 com.xpn.xwiki.doc.XWikiAttachment.getContentInputStream(XWikiAttachment.java:576)
 at
 org.centauron.xwiki.help.XWikiAttachmentCopy.doCommand(XWikiAttachmentCopy.java:79)
 

 Any help would be appreciated.
 Regards, Stefan.

 ___
 users mailing list
 users@xwiki.org
 http://lists.xwiki.org/mailman/listinfo/users



-- 
Thomas Mortagne
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Not able to read attachments from server thread

2014-11-12 Thread Marius Dumitru Florea
Btw, you should take a look at the Job Module
http://extensions.xwiki.org/xwiki/bin/view/Extension/Job+Module which
provides a clean way to perform, in a background thread, tasks that
access the XWiki model.

Hope this helps,
Marius

On Wed, Nov 12, 2014 at 2:45 PM, Thomas Mortagne
thomas.morta...@xwiki.com wrote:
 Could you copy the complete error, you should have a more detailed cause.

 On Wed, Nov 12, 2014 at 11:39 AM, Stefan Bernsdorf
 gruener.heinr...@web.de wrote:

 Hi,
 I created a Macro in xwiki.
 In this macro a server process is started that tries to read attachments.
 For this, I created a XWikiCOntext to access the Wiki.
 This is the code:
 XWikiStubContextProvider
 prov=Utils.getComponent(XWikiStubContextProvider.class);
 prov.initialize(template);
 XWikiContext con=prov.createStubContext();
 con.setUser(XWiki.TestProcess, true);
 con.setVirtual(true);

 Unfortunately it is not possible to access the attachment content using this
 context.
 The following error is thrown:
 com.xpn.xwiki.XWikiException: Error number 3231 in 3: Exception while
 loading attachment myseedfile.dgn of document
 microtest_oto.Templates_Test-Stefan
 at
 com.xpn.xwiki.store.XWikiHibernateAttachmentStore.loadAttachmentContent(XWikiHibernateAttachmentStore.java:233)
 at
 com.xpn.xwiki.doc.XWikiDocument.loadAttachmentContent(XWikiDocument.java:4600)
 at
 com.xpn.xwiki.doc.XWikiAttachment.getContentInputStream(XWikiAttachment.java:576)
 at
 org.centauron.xwiki.help.XWikiAttachmentCopy.doCommand(XWikiAttachmentCopy.java:79)
 

 Any help would be appreciated.
 Regards, Stefan.

 ___
 users mailing list
 users@xwiki.org
 http://lists.xwiki.org/mailman/listinfo/users



 --
 Thomas Mortagne
 ___
 users mailing list
 users@xwiki.org
 http://lists.xwiki.org/mailman/listinfo/users
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Not able to read attachments from server thread

2014-11-12 Thread Stefan Bernsdorf


Hi,

the Job Module looks promising,
however this is the stack:
CONTENT IS NUL!com.xpn.xwiki.XWikiException: Error number 3231 
in 3: Exc
eption while loading attachment myseedfile.dgn of document 
microtest_oto.Templates_Test-Stefan
at 
com.xpn.xwiki.store.XWikiHibernateAttachmentStore.loadAttachmentContent(XWikiHibernateAttachmentStore.java:233)
at 
com.xpn.xwiki.doc.XWikiDocument.loadAttachmentContent(XWikiDocument.java:4600)
at 
com.xpn.xwiki.doc.XWikiAttachment.getContentInputStream(XWikiAttachment.java:576)
at 
org.centauron.xwiki.help.XWikiAttachmentCopy.doCommand(XWikiAttachmentCopy.java:79)
at 
org.centauron.ant.TestScript.executeExtraData(TestScript.java:208)

at org.centauron.ant.TestProcess.doPre(TestProcess.java:246)
at org.centauron.ant.TestProcess.start(TestProcess.java:212)
at 
org.centauron.ant.TestProcesses.startNextProcess(TestProcesses.java:114)

at org.centauron.ant.TestProcesses.run(TestProcesses.java:54)
at java.lang.Thread.run(Unknown Source)
Caused by: 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)
at 
com.xpn.xwiki.store.XWikiHibernateBaseStore.beginTransaction(XWikiHibernateBaseStore.java:911)
at 
com.xpn.xwiki.store.XWikiHibernateBaseStore.beginTransaction(XWikiHibernateBaseStore.java:826)
at 
com.xpn.xwiki.store.XWikiHibernateAttachmentStore.loadAttachmentContent(XWikiHibernateAttachmentStore.java:207)

... 9 more
Caused by: java.lang.NullPointerException
at 
com.xpn.xwiki.store.migration.AbstractDataMigrationManager.getXWikiContext(AbstractDataMigrationManager.java:282)
at 
com.xpn.xwiki.store.migration.AbstractDataMigrationManager.getDataMigrationStatus(AbstractDataMigrationManager.java:406)
at 
com.xpn.xwiki.store.migration.AbstractDataMigrationManager.getDatabaseStatus(AbstractDataMigrationManager.java:548)
at 
com.xpn.xwiki.store.migration.AbstractDataMigrationManager.checkDatabase(AbstractDataMigrationManager.java:516)
at 
com.xpn.xwiki.store.XWikiHibernateBaseStore.setDatabase(XWikiHibernateBaseStore.java:735)

... 12 more

Am 12.11.2014 13:45, schrieb Thomas Mortagne:

Could you copy the complete error, you should have a more detailed cause.

On Wed, Nov 12, 2014 at 11:39 AM, Stefan Bernsdorf
gruener.heinr...@web.de wrote:

Hi,
I created a Macro in xwiki.
In this macro a server process is started that tries to read attachments.
For this, I created a XWikiCOntext to access the Wiki.
This is the code:
 XWikiStubContextProvider
prov=Utils.getComponent(XWikiStubContextProvider.class);
 prov.initialize(template);
 XWikiContext con=prov.createStubContext();
 con.setUser(XWiki.TestProcess, true);
 con.setVirtual(true);

Unfortunately it is not possible to access the attachment content using this
context.
The following error is thrown:
com.xpn.xwiki.XWikiException: Error number 3231 in 3: Exception while
loading attachment myseedfile.dgn of document
microtest_oto.Templates_Test-Stefan
 at
com.xpn.xwiki.store.XWikiHibernateAttachmentStore.loadAttachmentContent(XWikiHibernateAttachmentStore.java:233)
 at
com.xpn.xwiki.doc.XWikiDocument.loadAttachmentContent(XWikiDocument.java:4600)
 at
com.xpn.xwiki.doc.XWikiAttachment.getContentInputStream(XWikiAttachment.java:576)
 at
org.centauron.xwiki.help.XWikiAttachmentCopy.doCommand(XWikiAttachmentCopy.java:79)
 

Any help would be appreciated.
Regards, Stefan.

___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users






___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users