workflow fails to set aspect

You are here

6 posts / 0 new
Last post
workflow fails to set aspect

I am following "http://ecmarchitect.com/alfresco-developer-series-tutorials" and have new workflow in my share's web app.

I have reused "http://ecmarchitect.com/alfresco-developer-series-tutorials/workflow/tutorial/tutorial.html#someco-whitepaper-submission-example" example and on "approve" action I am trying to set webable aspect. But I am getting following error.

org.activiti.engine.ActivitiException: Exception while invoking TaskListener: Exception while invoking TaskListener: 03020110 Failed to execute supplied script: null

somewhere deep in the error stack I find following lines :

at org.activiti.engine.impl.delegate.DelegateInvocation.proceed(DelegateInvocation.java:37)
	at org.activiti.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:25)
	at org.activiti.engine.impl.bpmn.helper.ClassDelegate.notify(ClassDelegate.java:92)
	... 189 more
Caused by: java.lang.UnsupportedOperationException
	at java.util.Collections$UnmodifiableMap.put(Collections.java:1342)
	at org.alfresco.repo.node.db.DbNodeServiceImpl.addAspectsAndProperties(DbNodeServiceImpl.java:546)
	at org.alfresco.repo.node.db.DbNodeServiceImpl.addAspectsAndProperties(DbNodeServiceImpl.java:466)
	at org.alfresco.repo.node.db.DbNodeServiceImpl.addAspect(DbNodeServiceImpl.java:834)
	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.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.jav

I am suing exactly same "extensionElements" in my bmpn.xml file

        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
            <activiti:field name="script">
                    var setWebFlagAction = actions.create("set-web-flag");
                    setWebFlagAction.parameters["active"] = true;
                    for (var i = 0; i &lt; bpm_package.children.length; i++) {
                        logger.log("Approving node:" + bpm_package.children[i].nodeRef);

and I am using SetWebFlag.java from "action" tutorial.

If someone can suggest me cause AND/OR fix of this issue, I will be thankful.


Re:workflow fails to set aspect


Can you send your whole error log and SetWebFlag.java, so I can find the cause.


Sagar Nimmala Alfresco Certified Engineer

    If this is helpful, please click Yes on the Post Rating

Thanks for your help.

Thanks for your help.
I am using sample file from tutorial. I have changed "constant" string to fit my model definition

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.alfresco.repo.action.ParameterDefinitionImpl;
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.QName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class SetWebFlag extends ActionExecuterAbstractBase {
public final static String NAME = "set-web-flag";
public final static String PARAM_ACTIVE = "active";
/** The NodeService to be used by the bean */
protected NodeService nodeService;
private static Log logger = LogFactory.getLog(SetWebFlag.class);
protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {
Boolean activeFlag = (Boolean)action.getParameterValue(PARAM_ACTIVE);
if (activeFlag == null) activeFlag = true;
if (logger.isDebugEnabled()) logger.debug("Inside executeImpl");
// set the sc:isActive property to true
// set the sc:published property to now
Map<QName, Serializable> properties = nodeService.getProperties(actionedUponNodeRef);
properties.put(QName.createQName(eDCRModel.NAMESPACE_SOMECO_WORKFLOW_MODEL, eDCRModel.PROP_IS_ACTIVE), activeFlag);
if (activeFlag) {
properties.put(QName.createQName(eDCRModel.NAMESPACE_SOMECO_WORKFLOW_MODEL, eDCRModel.PROP_PUBLISHED), new Date());
// if the aspect has already been added, set the properties
if (nodeService.hasAspect(actionedUponNodeRef,
if (logger.isDebugEnabled()) logger.debug("Node has aspect");
nodeService.setProperties(actionedUponNodeRef, properties);
} else {
// otherwise, add the aspect and set the properties
if (logger.isDebugEnabled()) logger.debug("Node does not have aspect");
nodeService.addAspect(actionedUponNodeRef, QName.createQName(eDCRModel.NAMESPACE_SOMECO_WORKFLOW_MODEL, eDCRModel.ASPECT_SC_WEBABLE), properties);
if (logger.isDebugEnabled()) logger.debug("Ran web enable/disable action");
protected void addParameterDefinitions(List<ParameterDefinition> paramList) {
new ParameterDefinitionImpl( // Create a new parameter definition to add to the list
PARAM_ACTIVE, // The name used to identify the parameter
DataTypeDefinition.BOOLEAN, // The parameter value type
false, // Indicates whether the parameter is mandatory
getParamDisplayLabel(PARAM_ACTIVE))); // The parameters display label
* @param nodeService The NodeService to set.

public void setNodeService(NodeService nodeService) {
this.nodeService = nodeService;

Error is attached as file


Try to create a new properties map instead of using the properties map returned by nodeService.getProperties(actionedUponNodeRef) When update properties or add aspect

Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
properties.put(QName.createQName(eDCRModel.NAMESPACE_SOMECO_WORKFLOW_MODEL, eDCRModel.PROP_IS_ACTIVE), activeFlag);
properties.put(QName.createQName(eDCRModel.NAMESPACE_SOMECO_WORKFLOW_MODEL, eDCRModel.PROP_PUBLISHED), new Date());
nodeService.addAspect(actionedUponNodeRef, QName.createQName(eDCRModel.NAMESPACE_SOMECO_WORKFLOW_MODEL, eDCRModel.ASPECT_SC_WEBABLE), properties);

If this post was helpful, please click Yes on the Post Rating

Thanks @kaynezhang

Thanks @kaynezhang

Using a newly created Map for properties does not give above error and aspect get set correctly.

But this way I am overriding any properties set by any other part of code on input node. Isn't this true ?

I even tried to iterate through map from nodeservice and copy it to new map but it still gives me error.

		Iterator it = exisitngproperties.keySet().iterator();
QName key = (QName) it.next();
properties.put(key, (Serializable)exisitngproperties.get(key));

Any idea what is reason of error when some properties are from nodeservice


properties map

The properties map returned by nodeService.getProperties is an unmodifiable map.If you modified it it will give you unmodifiable exception.
If you want to update some properties ,you can just create a new map and set the properties you want to modify ,Other existing properties not contained in your new map will not be affected.

If this post was helpful, please click Yes on the Post Rating