cancel
Showing results for 
Search instead for 
Did you mean: 

Unknown property used in expression -- Cannot resolve identifier 'departmentHeadUserTask'

sdwilly22
Champ in-the-making
Champ in-the-making
I have activiti explorer 5.9 running on a tomcat instance inside eclipse. I am exporting my classes into a jar file and putting that in the WEB-INF/lib folder of the tomcat instance. I am getting the following error messages.

Caused by: org.activiti.engine.ActivitiException: Unknown property used in expression
   at org.activiti.engine.impl.el.JuelExpression.getValue(JuelExpression.java:55)
   at org.activiti.engine.impl.bpmn.listener.ExpressionTaskListener.notify(ExpressionTaskListener.java:33)
   at org.activiti.engine.impl.delegate.TaskListenerInvocation.invoke(TaskListenerInvocation.java:34)
   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.persistence.entity.TaskEntity.fireEvent(TaskEntity.java:512)
   … 140 more
Caused by: org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'departmentHeadUserTask'
   at org.activiti.engine.impl.juel.AstIdentifier.eval(AstIdentifier.java:83)
   at org.activiti.engine.impl.juel.AstMethod.invoke(AstMethod.java:79)
   at org.activiti.engine.impl.juel.AstMethod.eval(AstMethod.java:75)
   at org.activiti.engine.impl.juel.AstEval.eval(AstEval.java:50)
   at org.activiti.engine.impl.juel.AstNode.getValue(AstNode.java:26)
   at org.activiti.engine.impl.juel.TreeValueExpression.getValue(TreeValueExpression.java:114)
   at org.activiti.engine.impl.delegate.ExpressionGetInvocation.invoke(ExpressionGetInvocation.java:33)
   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.el.JuelExpression.getValue(JuelExpression.java:50)


Here are the contents of my applicationContext.xml.

<blockcode>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
   xmlns:jee="http://www.springframework.org/schema/jee"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
       http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">





   <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
      <property name="dataSource" ref="dataSource" />
      <property name="transactionManager" ref="transactionManager" />
      <property name="databaseSchemaUpdate" value="true" />
      <property name="jobExecutorActivate" value="false" />
      <property name="customFormTypes">
         <list>
            <ref bean="userFormType" />
         </list>
      </property>
      <property name="customSessionFactories">
         <list>
            <bean class="org.bpmnwithactiviti.chapter10.ldap.LDAPUserManagerFactory">
               <constructor-arg ref="ldapConnectionParams" />
            </bean>
            <bean class="org.bpmnwithactiviti.chapter10.ldap.LDAPGroupManagerFactory">
               <constructor-arg ref="ldapConnectionParams" />
             </bean>
          </list>
      </property>
      <property name="deploymentResources" value="classpath*:GroupConferenceAttendanceRequest.bpmn20.xml" />
      <property name="history" value="full" />
   </bean>

   <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean" destroy-method="destroy">
      <property name="processEngineConfiguration" ref="processEngineConfiguration" />
   </bean>





   <bean id="departmentHeadUserTask" class="org.bpmnwithactiviti.chapter6.listener.DepartmentHeadUserTask" />

</beans>
</blockcode>

Here is the code from my process GroupConferenceAttendanceRequest.bpmn20.xml

<blockcode>

<userTask id="usertask2" name="Department Approval" activiti:assignee="hd.connor" activiti:formKey="ConferenceAttendanceForm">
      <extensionElements>
     <activiti:taskListener expression="${departmentHeadUserTask.assignDeptHeadTask(task, task.eventName)}" event="assignment" />
     <activiti:taskListener expression="${departmentHeadUserTask.assignDeptHeadTask(task, task.eventName)}" event="create" />
   …
</blockcode>


I have tried so many things to get this working without the a good result. I saw on another forum post that. The bean would be registered  when…

when using a SpringProcessEngineConfiguration AND a ProcessEngineFactoryBean in your application-context AND you don't specify a "beans" property on the SpringProcessEngineConfiguration, ALL spring-beans will be available in expressions.

But this did not seem to be the case. I also tried making a property called "beans" inside the processEngineConfiguration like this    
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="beans"> <map> <entry key="departmentHeadUserTask" value-ref="departmentHeadUserTask" /> </map> </property>

</bean>

but that did not register the bean for use in the expression language.  I have verified that the jar file contains the class I am referencing. Other classes in that jar file are working fine. Can anyone spot how my configuration is not correct?
6 REPLIES 6

frederikherema1
Star Contributor
Star Contributor
So you're LDAP configuration is being picked up correctly I presume? Just to make sure this application-context is being used…

But this did not seem to be the case. I also tried making a property called "beans" inside the processEngineConfiguration like this

Something went wrong with your code-snippet so it seems. Can you re-post the "beans" attribute you're using?

Yes the LDAP configuration is working. I am logging in and getting user data from the LDAP users.
Here is the repost of that beans property. But I did not think that I needed it.
<code>
<property name="beans">
<map>
  <entry key="departmentHeadUserTask" value-ref="departmentHeadUserTask" />
</map>
</property>
</code>
Here is another piece of the puzzle. It is output from the console when tomcat is starting. The last defined bean is "departmentHeadUserTask" and that is the same name as the bean that is identified in the JUEL error message.

11 Jun 2013 13:36:49,128 [localhost-startStop-1]  INFO org.springframework.beans.factory.support.DefaultListableBeanFactory:549 - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@5e8e918a: defining beans [dbProperties,dataSource,transactionManager,processEngineConfiguration,processEngine,repositoryService,runtimeService,taskService,historyService,managementService,identityService,activitiLoginHandler,activitiUiPropertyPlaceholder,navigatorManager,attachmentRendererManager,formPropertyRendererManager,variableRendererManager,componentFactories,userCache,navigationFragmentChangeListener,mainWindow,explorerApp,i18nManager,notificationManager,viewManager,userFormType,ldapConnectionParams,gossipActivity,gossipTransition,<b>departmentHeadUserTask</b>]; root of factory hierarchy

jbarrez
Star Contributor
Star Contributor
Indeed, you dont need to reference the bean explicitly normally.
Your logging indeed indicates the bean exists.

Could you create the simplest of simple unit tests: ie a simple process with only a task listener that calls a spring bean that sysouts something, but using the dependencies and environment your currently running in?

sdwilly22
Champ in-the-making
Champ in-the-making
DeptHeadListenerTest.java
<blockcode>

import static org.junit.Assert.assertNotNull;

import org.activiti.engine.RuntimeService;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.test.ActivitiRule;
import org.activiti.engine.test.Deployment;
import org.bpmnwithactiviti.common.AbstractTest;
import org.junit.Rule;
import org.junit.Test;



public class DeptHeadListenerTest extends AbstractTest
{

@Rule
public ActivitiRule activitiRule = new ActivitiRule("applicationContext.xml");


private RuntimeService runtimeService;

@Test
@Deployment(resources={"GroupConferenceAttendanceRequest.bpmn20.xml"})
public void testListener()
{
  runtimeService = activitiRule.getRuntimeService();
 
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("groupConferenceAttendanceRequestProcess");
  assertNotNull(processInstance);
}
}

</blockcode>

DepartmentHeadUserTask.java
<blockcode>
package edu.usu.listener;

import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.ExecutionListener;

public class DepartmentHeadUserTask implements ExecutionListener
{

public void assignDeptHeadTask(DelegateTask task, String eventName)
{

   System.out.println("DepartmentHead User Task has been assigned to  ");// + task.getAssignee() +"");
}

@Override
public void notify(DelegateExecution execution) throws Exception
{
  // TODO Auto-generated method stub

}

}

</blockcode>

applicationContext.xml
<blockcode>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
       http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">


<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
  <property name="driverClassName" value="org.h2.Driver" />
  <property name="url" value="jdbc:h2:tcp://somehost/activiti" />
  <property name="username" value="someuser" />
  <property name="password" value="somepassword" />
  <property name="defaultAutoCommit" value="false" />
</bean>


<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  <property name="dataSource" ref="dataSource" />
</bean>

<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
  <property name="dataSource" ref="dataSource" />
  <property name="transactionManager" ref="transactionManager" />
  <property name="databaseSchemaUpdate" value="true" />
  <property name="jobExecutorActivate" value="false" />
  <property name="customFormTypes">
   <list>
    <ref bean="userFormType" />
   </list>
  </property>
  <property name="customSessionFactories">
   <list>
    <bean class="edu.usu.ldap.LDAPUserManagerFactory">
     <constructor-arg ref="ldapConnectionParams" />
    </bean>
    <bean class="edu.usu.ldap.LDAPGroupManagerFactory">
     <constructor-arg ref="ldapConnectionParams" />
    </bean>
   </list>
  </property>
  <property name="history" value="full" />
</bean>

<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
  <property name="processEngineConfiguration" ref="processEngineConfiguration" />
</bean>

<bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
<bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />
<bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
<bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
<bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />
<bean id="identityService" factory-bean="processEngine" factory-method="getIdentityService" />

<bean id="activitiLoginHandler" class="org.activiti.explorer.ui.login.DefaultLoginHandler">
  <property name="identityService" ref="identityService" />
</bean>

<!– Include the UI-related wiring. This UI context will be used in the alfresco activiti admin UI –>
<import resource="activiti-ui-context.xml" />
<!– <import resource="usu-application-context.xml" /> –>
<!– Custom form types –>
<bean id="userFormType" class="org.activiti.explorer.form.UserFormType" />

<bean id="ldapConnectionParams" class="edu.usu.ldap.LDAPConnectionParams">
  <property name="ldapServer" value="somehost" />
  <property name="ldapPort" value="636" />
  <property name="ldapUser" value="uid=admin,dc=usu,dc=edu" />
  <property name="ldapPassword" value="somepass" />
</bean>

<bean id="departmentHeadUserTask" class="edu.usu.listener.DepartmentHeadUserTask" />

</beans>
</blockcode>

Junit error:
<blockcode>

Caused by: org.activiti.engine.ActivitiException: Unknown property used in expression
at org.activiti.engine.impl.el.JuelExpression.getValue(JuelExpression.java:55)
at org.activiti.engine.impl.bpmn.listener.ExpressionTaskListener.notify(ExpressionTaskListener.java:33)
at org.activiti.engine.impl.delegate.TaskListenerInvocation.invoke(TaskListenerInvocation.java:34)
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.persistence.entity.TaskEntity.fireEvent(TaskEntity.java:512)
… 132 more
Caused by: org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'departmentHeadUserTask'
at org.activiti.engine.impl.juel.AstIdentifier.eval(AstIdentifier.java:83)
at org.activiti.engine.impl.juel.AstMethod.invoke(AstMethod.java:79)
at org.activiti.engine.impl.juel.AstMethod.eval(AstMethod.java:75)
at org.activiti.engine.impl.juel.AstEval.eval(AstEval.java:50)
at org.activiti.engine.impl.juel.AstNode.getValue(AstNode.java:26)
at org.activiti.engine.impl.juel.TreeValueExpression.getValue(TreeValueExpression.java:114)
at org.activiti.engine.impl.delegate.ExpressionGetInvocation.invoke(ExpressionGetInvocation.java:33)
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.el.JuelExpression.getValue(JuelExpression.java:50)
… 137 more

</blockcode>

sdwilly22
Champ in-the-making
Champ in-the-making
This simple test did not work when I ran it. BUT what did work was including the compiled classes in WEB-INF/lib and running tomcat. When I deployed the GroupConferenceAttendanceRequest.bpmn20.xml process and ran it that System.out.println output showed up in the console. So there is a differnce between my test application context and the one running in Tomcat. Eventhough the two applicationContext.xml files are identical. Sure would be nice to be able to test this bean. The end goal is to have this listener read the Form data and get the Department field and connect to the LDAP read the Department head of that Department and to assign the Usertask to that person. Any help getting to that end point would be helpful. Thanks for all your help so far.

jbarrez
Star Contributor
Star Contributor
It should run exactly the same in both settings.
Howevere, the most important part, the process xml is missing from your pasted files. Also, could you group those in a standard maven project, that makes it easier for me to test.