Problem with scheduled groovy task

I want to do some document updates by scheduled tasks. But even the small test tasks like

destinationDocument =  'Testoutput.Testoutput Scheduler.WebHome'

newContent = ["Line 1","**Line 2**"]
completeContent = newContent.join("\n")

newDoc = xwiki.getDocument(destinationDocument)
newDoc.setTitle('Testoutput Scheduler')

do not work if the code is used as groovy to be scheduled.
It works, if it is embedded with {{groovy}} … {{/groovy}} with a document.
What is missing ?

Hi, just tested your example and it works perfectly well.

Maybe you forgot to schedule the job and then to trigger it?

I did the typical test steps: deactivate - activate - trigger.

But - I could be that there are some right impacts:

The Testspace “Testoutput” has only (all rights) set to XWikiadmingroup. The job execution context user
is member of XWikiadmingroup.
I did an additional test with specific user rights for this space (all rights set), but there is no change.

Is it possible to get log / error messages of scheduled jobs? There is nothing in tomcat (catalina.out).

Thanks für any help

Ups - I forgot: we use 9.11.2

Yes it’s painfu FTM to debug scheduler jobs since the output is not saved anywhere.

What you can do use is use println(...) commands in your script and the result will be printed in the console/xwiki logs.

FYI: A restart of tomcat9 solved the problem. - Thanks for help