Why this error occurs in automation chain when use Query operation?

I have a content view and it has defined a nxql query, it works perfectly. Now I want to get those documents using query operation in a automation chain for create relations with another documents but an error is printed in the server log.

My automation chain:

> Context.FetchDocument:run

> Context.SetInputAsVar:run
name: tramiteFolder

> Context.SetVar:run
name: variableContext
value: @{Document["myschema:myfield"]}

> Document.Query:run
query: SELECT * FROM Document WHERE anotherschema:anotherfield = '@{variableContext}' AND ecm:currentLifeCycleState != 'deleted'

> Relations.CreateRelation:run
object: @{Context["tramiteFolder"]}
predicate: http://purl.org/dc/terms/References

This is my logic:

  1. I have a workflow, it is started automaticaly when document type “A” is created
  2. I want to run my chain on automatic_transition from start node.

the error printed in the log:

Caused by: org.nuxeo.ecm.core.api.ClientRuntimeException: org.nuxeo.ecm.platform.routing.api.exception.DocumentRouteException: Error running chain: test
    at org.nuxeo.ecm.platform.routing.core.impl.GraphRunner.run(GraphRunner.java:81)
    at org.nuxeo.ecm.platform.routing.core.impl.DocumentRouteElementImpl.run(DocumentRouteElementImpl.java:82)
    at org.nuxeo.ecm.platform.routing.core.impl.DocumentRoutingEngineServiceImpl.start(DocumentRoutingEngineServiceImpl.java:37)
    at org.nuxeo.ecm.platform.routing.core.impl.DocumentRoutingServiceImpl$1.run(DocumentRoutingServiceImpl.java:194)
    at org.nuxeo.ecm.core.api.UnrestrictedSessionRunner.runUnrestricted(UnrestrictedSessionRunner.java:115)
    at org.nuxeo.ecm.platform.routing.core.impl.DocumentRoutingServiceImpl.createNewInstance(DocumentRoutingServiceImpl.java:164)
    at org.nuxeo.ecm.platform.routing.core.impl.DocumentRoutingServiceImpl.createNewInstance(DocumentRoutingServiceImpl.java:230)
    at org.nuxeo.ecm.platform.routing.api.operation.StartWorkflowOperation.startNewInstance(StartWorkflowOperation.java:76)
    at org.nuxeo.ecm.platform.routing.api.operation.StartWorkflowOperation.run(StartWorkflowOperation.java:71)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.nuxeo.ecm.automation.core.impl.InvokableMethod.doInvoke(InvokableMethod.java:125)
    at org.nuxeo.ecm.automation.core.impl.InvokableMethod.invoke(InvokableMethod.java:132)
    ... 141 more
Caused by: org.nuxeo.ecm.platform.routing.api.exception.DocumentRouteException: Error running chain: test
    at org.nuxeo.ecm.platform.routing.core.impl.GraphNodeImpl.executeChain(GraphNodeImpl.java:470)
    at org.nuxeo.ecm.platform.routing.core.impl.GraphNodeImpl.executeTransitionChain(GraphNodeImpl.java:444)
    at org.nuxeo.ecm.platform.routing.core.impl.GraphRunner.runGraph(GraphRunner.java:270)
    at org.nuxeo.ecm.platform.routing.core.impl.GraphRunner.run(GraphRunner.java:75)
    ... 155 more
Caused by: org.nuxeo.ecm.automation.AdapterNotFoundException: No type adapter found for input: class org.nuxeo.ecm.core.api.impl.DocumentModelListImpl and output interface org.nuxeo.ecm.core.api.DocumentModel
> Context.FetchDocument:run
> Context.SetInputAsVar:run
> Context.SetVar:run
> Document.Query:run
> Relations.CreateRelation:run
    at org.nuxeo.ecm.automation.core.impl.OperationServiceImpl.getAdaptedValue(OperationServiceImpl.java:244)
    at org.nuxeo.ecm.automation.core.impl.OperationTypeImpl.inject(OperationTypeImpl.java:179)
    at org.nuxeo.ecm.automation.core.impl.OperationTypeImpl.newInstance(OperationTypeImpl.java:155)
    at org.nuxeo.ecm.automation.core.impl.InvokableMethod.doInvoke(InvokableMethod.java:114)
    at org.nuxeo.ecm.automation.core.impl.InvokableIteratorMethod.doInvoke(InvokableIteratorMethod.java:111)
    at org.nuxeo.ecm.automation.core.impl.InvokableMethod.invoke(InvokableMethod.java:132)
    at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.doInvoke(CompiledChainImpl.java:114)
    at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.invoke(CompiledChainImpl.java:96)
    at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.doInvoke(CompiledChainImpl.java:117)
    at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.invoke(CompiledChainImpl.java:96)
    at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.doInvoke(CompiledChainImpl.java:117)
    at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.invoke(CompiledChainImpl.java:96)
    at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.doInvoke(CompiledChainImpl.java:117)
    at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.invoke(CompiledChainImpl.java:96)
    at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.doInvoke(CompiledChainImpl.java:117)
    at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.invoke(CompiledChainImpl.java:96)
    at org.nuxeo.ecm.automation.core.impl.OperationServiceImpl.run(OperationServiceImpl.java:65)
    at org.nuxeo.ecm.platform.routing.core.impl.GraphNodeImpl.executeChain(GraphNodeImpl.java:462)
    ... 158 more

on the other hand, I have another chain where I create this same logic and works perfectly but with another query:

SELECT * FROM MyTypeDocument WHERE uid:uid = '@{variableContext}'
0 votes

1 answers

5606 views

ANSWER

Why are you using @{code} in the query ? Are you using the context object.

The strange is that the creation behave as that can't accept a documentmodelList. That's why when your query return just one result it works. Can you give your Nuxeo instance version and hot fixes applied ?

05/21/2013

Hi, I updated my example code in my question, "code" is a context variable. I replaced "code" by variableContext. But is strange because the operation create relations should accept documentModelList. My nuxeo instance is 5.6 and hotfixs from 1 to 16
05/21/2013



Hi,

The reason of your problem is that create Relation expects a Document as a value for parameter “Object”, and you give a document list (tramiteFolder).

Indeed, the input of the chain is a document list. So, Context.SetInputAsVar sets a documents list as a variable.

You could simply refer to “@{workflowDocuments[0]}” in the object attribute, or, just before Context.SetInputAsVar, use a Run Script operation with “return This[0]” script value.

1 votes