cancel
Showing results for 
Search instead for 
Did you mean: 

Service-context.xml file causing login issue

erichkey
Confirmed Champ
Confirmed Champ

I'm able to deploy a new custom workflow but upon testing a receive an error regarding the destination folder for the document in the workflow, the service-context.xml is not added into alfresco yet.

When Adding the file to {PATH}/alfresco/extension (this is were I copied the workflow bpmn file) and restart alfresco and go to the login page to test again, I'm unable to use admin login details. Once I remove the service-context.xml file, I can login again but the same error occurs on the workflow.

The following is the entire service-context.xml file:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at
        
    http://www.apache.org/licenses/LICENSE-2.0
        
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<beans>   

    <!-- A simple module component that will be executed once.
        Note. this module component will only be executed once, and then there will be an entry for it in the Repo.
        So doing for example $ mvn clean install -Pamp-to-war twice will only execute this component the first time.
        You need to remove /alf_data_dev for it to be executed again. -->
    <bean id="extension.workflowBootstrap" parent="workflowDeployer">
        <property name="workflowDefinitions">         
     <list>                
                <props>
                    <prop key="engineId">activiti</prop>
                    <prop key="location">alfresco/extension/MyProcess2.bpmn</prop>
                    <prop key="mimetype">text/xml</prop>
                    <prop key="redeploy">true</prop>
                </props>
                
                <props>
                    <prop key="engineId">activiti</prop>
                    <prop key="location">alfresco/extension/workflows/KeystoneDocumentReview.bpmn</prop>
                    <prop key="mimetype">text/xml</prop>
                    <prop key="redeploy">true</prop>
                </props>
     </list>
         </property>
    </bean>

</beans>

1 ACCEPTED ANSWER

Email notification resolved !

The problem was on the smtp server not allowing mail to be relayed due to an unauthorized host. Referred to: Fix SMTP AUTH required for message submission on port 587

View answer in original post

41 REPLIES 41

This definition has no transformation logic included.  It would be useful to see the definition that generate the new error.

Pardon, I did not realize it was the unmodified file.

The correct file:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://activiti.org/bpmn20" id="review-definitions">
  <process id="KeystoneDocumentReview" name="Keystone Document Review" isExecutable="true">
    <startEvent id="start" activiti:formKey="wf:submitReviewTask"></startEvent>
    <sequenceFlow id="flow1" sourceRef="start" targetRef="reviewTask"></sequenceFlow>
    <userTask id="reviewTask" name="Review Task" activiti:assignee="${bpm_assignee.properties.userName}" activiti:formKey="wf:activitiReviewTask">
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);
                        if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[execution.setVariable('wf_reviewOutcome', task.getVariable('wf_reviewOutcome'));

/* transform to pdf */
                     var drafts = bpm_package.children[0].parent;
                     var docroot = drafts.parent;
                     var dest = docroot.childByNamePath("Released");
                     var trans = actions.create("transform");
                     trans.parameters["destination-folder"] = dest;
                     trans.parameters["assoc-type"] = "{http://www.alfresco.org/model/content/1.0}contains";
                     trans.parameters["assoc-name"] = String("{http://www.alfresco.org/model/content/1.0}" + bpm_package.children[0].properties["cm:name"]);
                     trans.parameters["mime-type"] = "application/pdf";
                     trans.execute(bpm_package.children[0]);]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow2" sourceRef="reviewTask" targetRef="reviewDecision"></sequenceFlow>
    <exclusiveGateway id="reviewDecision" name="Review Decision"></exclusiveGateway>
    <sequenceFlow id="flow3" sourceRef="reviewDecision" targetRef="approved">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${wf_reviewOutcome == 'Approve'}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow4" sourceRef="reviewDecision" targetRef="rejected"></sequenceFlow>
    <userTask id="approved" name="Document Approved" activiti:assignee="${initiator.properties.userName}" activiti:formKey="wf:approvedTask">
      <documentation>The document was reviewed and approved.</documentation>
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);
                        if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <userTask id="rejected" name="Document Rejected" activiti:assignee="${initiator.properties.userName}" activiti:formKey="wf:rejectedTask">
      <documentation>The document was reviewed and rejected.</documentation>
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);
                        if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow5" sourceRef="approved" targetRef="end"></sequenceFlow>
    <sequenceFlow id="flow6" sourceRef="rejected" targetRef="end"></sequenceFlow>
    <endEvent id="end"></endEvent>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_activitiReview">
    <bpmndi:BPMNPlane bpmnElement="activitiReview" id="BPMNPlane_activitiReview">
      <bpmndi:BPMNShape bpmnElement="start" id="BPMNShape_start">
        <omgdc:Bounds height="35.0" width="35.0" x="30.0" y="200.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="reviewTask" id="BPMNShape_reviewTask">
        <omgdc:Bounds height="55.0" width="105.0" x="105.0" y="190.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="reviewDecision" id="BPMNShape_reviewDecision">
        <omgdc:Bounds height="40.0" width="40.0" x="250.0" y="197.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="approved" id="BPMNShape_approved">
        <omgdc:Bounds height="55.0" width="105.0" x="330.0" y="137.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="rejected" id="BPMNShape_rejected">
        <omgdc:Bounds height="55.0" width="105.0" x="330.0" y="257.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="end" id="BPMNShape_end">
        <omgdc:Bounds height="35.0" width="35.0" x="620.0" y="147.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="65.0" y="217.0"></omgdi:waypoint>
        <omgdi:waypoint x="105.0" y="217.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="210.0" y="217.0"></omgdi:waypoint>
        <omgdi:waypoint x="250.0" y="217.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="270.0" y="197.0"></omgdi:waypoint>
        <omgdi:waypoint x="270.0" y="164.0"></omgdi:waypoint>
        <omgdi:waypoint x="330.0" y="164.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="270.0" y="237.0"></omgdi:waypoint>
        <omgdi:waypoint x="270.0" y="284.0"></omgdi:waypoint>
        <omgdi:waypoint x="330.0" y="284.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
        <omgdi:waypoint x="435.0" y="164.0"></omgdi:waypoint>
        <omgdi:waypoint x="620.0" y="164.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
        <omgdi:waypoint x="435.0" y="284.0"></omgdi:waypoint>
        <omgdi:waypoint x="637.0" y="284.0"></omgdi:waypoint>
        <omgdi:waypoint x="637.0" y="182.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

I just deploy this definition and works without any problem. 

A pair of considerations:

You must check if the transformed document exist in the drafs space, in other case you would get an error en the transformation process.

You make the document transformation whether you approve it or reject it  

Regards.

That is very odd. I reverted to snapshot of alfresco that would be considered a clean installation and deployed the workflow above. I created a new site with only the folders Draft and Released and created a test document in Draft.

I started the workflow for the test document and assigned the task to a non-admin employee. Upon logging in as the employee and completing the workflow by clicking on Approve, I first received a access denied error, I added the employee then to the admin group and was able to resolve that error just to be confronted by another error.

org.activiti.engine.ActivitiException: Exception while invoking TaskListener: Exception while invoking TaskListener: 02060661 Failed to execute supplied script: 02060660 Content conversion failed:
    reader: ContentAccessor[ contentUrl=store://2019/3/6/13/9/767322e5-9b06-4c6e-9a4c-9693cdd9e6d7.bin, mimetype=application/vnd.oasis.opendocument.text, size=0, encoding=UTF-8, locale=en_US]
    writer: ContentAccessor[ contentUrl=store://2019/3/6/13/29/ac64d1fa-fbfb-473e-9eac-4965154ff474.bin, mimetype=application/pdf, size=0, encoding=UTF-8, locale=en_US]
    options: {use=null, contentReaderNodeRef=workspace://SpacesStore/d52eb780-b083-4904-bbd7-36578c27bdfa, sourceContentProperty={http://www.alfresco.org/model/content/1.0}name, contentWriterNodeRef=workspace://SpacesStore/37a8eb81-1ec0-4d3c-b75a-c6586b7955e9, targetContentProperty={http://www.alfresco.org/model/content/1.0}name, includeEmbedded=null}
    limits: {timeoutMs=120000}

Before I continue with the troubleshooting with this issue, could you kindly provide me with the details as to how you went about to deploy the workflow to a document being approved and transformed to pdf then moved to Released.

The steps I followed are as follow:

Created Service-context.xml file with the following configuration in alfresco/extension

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>

    <bean id="extension.workflowBootstrap" parent="workflowDeployer">
        <property name="workflowDefinitions">
            <list>
                <!-- Activiti version of lifecycle process -->
                <props>
                    <prop key="engineId">activiti</prop>
                    <prop key="location">alfresco/extension/MyProcess3.bpmn</prop>
                    <prop key="mimetype">text/xml</prop>
                    <prop key="redeploy">true</prop>
                </props>
            </list>
        </property>
     </bean>

</beans>

MyProcess3.bmpn file is created and added to the same directory with the same configuration I posted that you requested.

I open the workflow admin console and proceed to use

deploy activiti alfresco/extension/MyProcess3.bpmn

with out any errors.

After logging in I go to task, start a task with the new workflow, choose the document and assign the reviewer then the workflow starts and the reviewer gets an email notification for the task.

Anything I'm doing wrong in this process?

The deploying method you are using is correct.  To asure the transformation only will be done when the document will be appove you could:

  1. Check the property task.getVariable('wf_reviewOutcome') before doing the actual transformation.
  2. Do the transformation action in the creation event of the appoved user task instead in the complete event of the review task.