[PUBLISHING-66] Groovy script fails sometimes when publishing Created: 26/Sep/19  Updated: 29/Mar/22  Resolved: 31/Oct/19

Status: Closed
Project: Publishing
Component/s: None
Affects Version/s: 1.1
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Carlos Cantalapiedra Assignee: Unassigned
Resolution: Not an issue Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
causality
relation
is related to DOCU-1967 Commands: wrong example of execution ... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Team: Nucleus

 Description   

Sometimes, while using groovy for publish content from website workspace, a PublicationException is launched and the message java.util.concurrent.ExecutionException: info.magnolia.publishing.exception.PublicationException: <ul><li>null: null</li></ul> is thrown.

It's not easy to reproduce because it looks like it mostly depends on the page name. Creating a page called "publish-me" and then executing the snippet below triggers the exception.

cm = info.magnolia.commands.CommandsManager.getInstance()
command = cm.getCommand('activate')
command.setRepository('website')
command.setPath('/publish-me')
command.execute(ctx)

Other page names like "intranet" won't get published.

The exception is launched by the class AbstractSender, method send, line 155 is throwing the nullPointer:

getOperationByName(PUBLISH) : getOperationByName(UNPUBLISH);


 Comments   
Comment by Jonathan Ayala [ 08/Oct/19 ]

According to shaun.mendham's experience (affected user in SUPPORT-10454), it seems that the error happens randomly, sometimes the exception is thrown whereas some other times it is not, even with same nodes:

However in my experience running the script locally, it can fail a number of times and then work as expected the next time. Which would be operating on the same nodes.

Comment by Jonathan Ayala [ 22/Oct/19 ]

Workaround: If the script is executed this way, it works perfectly for both publish and unpublish commands:

map  = new java.util.LinkedHashMap<String, String>()
map.put("path", "/PATH-TO-PAGE")
map.put("repository", "website")
cm = info.magnolia.commands.CommandsManager.getInstance()
cm.executeCommand('default','publish',map)  
Comment by Jonathan Ayala [ 23/Oct/19 ]

Workaround 2: It seems that what's making it fail is the context passed as a parameter in groovy. Using a SimpleContext object, just like it is done in cm.executeCommand(), would be enough to make the failing script work again:

cm = info.magnolia.commands.CommandsManager.getInstance()
command = cm.getCommand('activate')
command.setRepository('website')
command.setPath('/publish-me')
command.setRecursive(true)
command.execute(new info.magnolia.context.SimpleContext())
Comment by Jonathan Ayala [ 31/Oct/19 ]

Not an issue: the correct command execution is shown in the two previous comments.

The wrong script in the docs will be fixed according to DOCU-1967.

Generated at Mon Feb 12 10:35:04 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.