Document query casting error?

I've done the following query two ways:

  1. Using parent/child in Studio.

  2. Using NXQL query in Studio and get the same error. Here is the NXQL.

    SELECT * FROM Document WHERE ecm:isCheckedInVersion = 0 AND ecm:parentId = '@{Context[“TRAVELERID”]}' AND ecm:primaryType = '@{Context[“NEXTRECIPEDOCTYPE”]}' AND ecm:currentLifeCycleState = '@{Context[“NEXTRECIPESTARTSTATE”]}'

All of the context variables resolve correctly in both cases. I have used similar queries in content views with success.

I get the following error:

org.nuxeo.ecm.automation.core.collectors.DocumentModelCollector cannot be cast to org.nuxeo.ecm.core.api.DocumentModel

I basically have a container document that has just made a state transition and I want to select one of the documents in the container. The query is trying to retrieve the “now active” document context so I can edit the metadata.

Any suggestions on what is wrong and how to troubleshoot this effort!?

0 votes

1 answers



After digging a bit in the code it appears the public class OperationServiceImpl which implements AutomationService returns a DocumentModelCollector rather than a DocumentModel which produces the error above.

I placed a List filter after the call but it does not seem to have any effect on the error.


I also tried Get Children rather that Get Child and go the same error.

Am I correct in my analysis of this bit of code?


My container document has several documents of different types. It appears the DocumentModelCollector returns a document model list. Which then returns each DocumentModel contained in the parent document. For some reason the DocumentModelCollector itself is being returned NOT each individual DocumentModel.

I found the automation chain I was calling did not return a document this was by my design. I was using Run Document Chain which expects a document or documents to be returned. Since nothing was returned (the end result of the called chain was a task being queued) the casting error was thrown.

The Fix:

Changing the the Automation command to Run Chain fixed the casting issue.

0 votes