cancel
Showing results for 
Search instead for 
Did you mean: 

PropertyNotFoundException: Cannot resolve identifier

shukla_raghav
Champ in-the-making
Champ in-the-making
I am using demo setup.

Here is my test Process
[img]http://localhost:8080/activiti-explorer/APP/13/MyFirstProcessDiagram.my_test_process.png[/img]

<?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:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="my_test_process" name="MyTestProcess">
    <startEvent id="startevent1" name="Start" activiti:initiator="kermit"></startEvent>
    <exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway"></exclusiveGateway>
    <userTask id="details" name="Enter Details" activiti:assignee="kermit" activiti:candidateUsers="fozzie">
      <documentation>This is a Test Form Documentation 2</documentation>
      <extensionElements>
        <activiti:formProperty id="user_name" name="Name" type="string"></activiti:formProperty>
        <activiti:formProperty id="salary" name="salary" type="long"></activiti:formProperty>
      </extensionElements>
    </userTask>
    <userTask id="usertask4" name="Gold Member" activiti:assignee="kermit" activiti:candidateUsers="fozzie">
      <documentation>This is documentation for Gold Member</documentation>
    </userTask>
    <exclusiveGateway id="exclusivegateway2" name="Exclusive Gateway"></exclusiveGateway>
    <endEvent id="endevent1" name="End"></endEvent>
    <serviceTask id="servicetask1" name="Platinum Member" activiti:expression="#{platinum.doSomething()}"></serviceTask>
    <sequenceFlow id="flow2" name="" sourceRef="details" targetRef="exclusivegateway1"></sequenceFlow>
    <sequenceFlow id="flow3" name="salary_flow_a" sourceRef="exclusivegateway1" targetRef="servicetask1">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${salary > 2000}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow4" name="" sourceRef="startevent1" targetRef="details"></sequenceFlow>
    <sequenceFlow id="flow5" name="salary_flow_b" sourceRef="exclusivegateway1" targetRef="usertask4">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${salary <= 2000}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow6" name="" sourceRef="usertask4" targetRef="exclusivegateway2"></sequenceFlow>
    <sequenceFlow id="flow7" name="" sourceRef="servicetask1" targetRef="exclusivegateway2"></sequenceFlow>
    <sequenceFlow id="flow8" name="" sourceRef="exclusivegateway2" targetRef="endevent1"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_my_test_process">
    …
    …
    …
  </bpmndi:BPMNDiagram>
</definitions>

a) I create  the deployment artifacts in eclipse (.bar file + .jar file containing the .class for com.osr.test.PlatinumService ).
b) Since i was not sure where to copy the jar in the Demo Setup. Many of the post discussed putting the JAR file to activiti-XXX\WEB-INF\lib folder, some of the posts discuss putting the jar into activiti-explorer\WEB-INF\lib and also activiti-rest\WEB-INF\lib. I got a little confused so i added the jar to all the following locations
   
   - C:\activiti-5.9\apps\apache-tomcat-6.0.32\lib.
   - C:\activiti-5.9\apps\apache-tomcat-6.0.32\lib
   - C:\activiti-5.9\apps\apache-tomcat-6.0.32\webapps\activiti-explorer\WEB-INF\lib
   - C:\activiti-5.9\apps\apache-tomcat-6.0.32\webapps\activiti-rest\WEB-INF\lib
   - C:\activiti-5.9\setup\build\webapps\activiti-explorer.war\WEB-INF\lib
   - C:\activiti-5.9\setup\build\webapps\activiti-rest.war\WEB-INF\lib      

Where should we put the JAR ?

c) Modified the activiti.cfg.xml in C:\activiti-5.9\setup\build\activiti-cfg to add a custom bean 'platinum'
   
   
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans.xsd">

  <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
 
    <!– Database configurations –>
    <property name="databaseSchemaUpdate" value="true" />
    <property name="jdbcUrl" value="jdbc:h2:tcp://localhost/activiti" />
    <property name="jdbcDriver" value="org.h2.Driver" />
    <property name="jdbcUsername" value="sa" />
    <property name="jdbcPassword" value="" />
   
    <property name="jobExecutorActivate" value="true" />
   
  </property>

  </bean>
   <bean id="platinum" class="com.osr.test.PlatinumService"/>
</beans>

I noticed that the modified activiti.cfg.xml was overridden by original one everytime i started the server, so the custom bean was removed. So i made a small modification in build.xml. Changed the value of overwrite attribute to false.

<copy todir="${activiti.home}/setup/build/activiti-cfg" overwrite="false">

c) Deployed the .bar file in activiti-explorer

d) started the application using

c:\activiti-5.9\setup> ant demo.start

and signed in using kermit/kermit. Started my process from processes tab to view the Form showing two input fields for entering Name and Salary. But as soon as i complete the form i get error with following root cause

Caused by: org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'platinum'

Why the activiti engine cannot find my jar to locate the class file for identifier 'platinum' ? What could be the problem, i am struggling since last 3 days.
10 REPLIES 10

frederikherema1
Star Contributor
Star Contributor
When you're just using the activiti.cfg.xml, the other BEANS in the XML are not exposed as beans to activiti expressions.

See http://forums.activiti.org/en/viewtopic.php?f=6&t=4722&start=0 for more information on how this mechanism works

shukla_raghav
Champ in-the-making
Champ in-the-making
Thanks for the reply, I did not quite understand the thread that you have sent. Do you mean the only way to expose beans to expressions is through a script by using execution.setVariable(). The user guide in that case is a little confusing. Here is an excerpt from the user guide that i followed.

Exposing configuration beans in expressions and scripts

By default, all beans that you specify in the activiti.cfg.xml configuration or in your own spring configuration file are available to expressions and in the scripts. If you want to limit the visibility of beans in your configuration file, then you can configure a property called beans in your process engine configuration. The beans property in ProcessEngineConfiguration is a map. When you specify that property, only beans specified in that map will be visible to expressions and scripts. The exposed beans will be exposed with the names as you specify in that map.

In simple terms if i say, there are two ways of configuring activiti engine.

1. Non-Spring way of configuration using activiti.cfg.xml
2. Spring style way of configuration using activiti-context.xml

I want to try both the ways one by one. For now i want to know learn how expose custom beans using the Non-Spring way i.e. activiti.cfg.xml

frederikherema1
Star Contributor
Star Contributor
Do you mean the only way to expose beans to expressions is through a script by using execution.setVariable().

No, that's not what I mean. There is a property called "beans" on the ProcessEngineConfiguration. This can hold a map<String, Object> mapping a bean name to an object. The object will be available to expressions, using the key it's added in the map. This "beans" property can be used in the standalone-case (activiti.cfg.xml) and in spring-case.

On top of that, 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.

ingo_ri
Champ in-the-making
Champ in-the-making
Hi,

I wanted to allow expressions in process templates to use beans in the standalone engine, too. But out of the box it's just supported in the spring configuration.

The org.activiti.engine.impl.el.ExpressionManager doesn't look for beans when he resolves an expression.

So I wrote a subclass of org.activiti.engine.impl.el.ExpressionManager, overwriting

// see ExpressionManager for the rest of the code
public MyExpressionManager(Map<Object, Object> beans) {
super();
this.beans = beans;
}

protected ELResolver createElResolver(VariableScope variableScope) {

if (beans != null) {
  compositeELResolver.add(new MyReadOnlyMapELResolver(beans));
}

}
MyReadOnlyMapELResolver is an extension of org.activiti.engine.impl.javax.el.ELResolver and has access to the map of configured beans:


public MyReadOnlyMapELResolver(Map<Object, Object> beans) {
this.wrappedBeans = beans;
}

@Override
public Object getValue(ELContext context, Object base, Object property) {
if (base == null) {
  if (wrappedBeans.containsKey(property)) {
   log.info("getValue für Bean " + property + ": " + wrappedBeans.get(property));
   context.setPropertyResolved(true);
   return wrappedBeans.get(property);
  }
}
return null;
}

I replace the ExpressionManager with MyExpressionManager in the my own ProcessEngineConfigurationImpl and it works.

Kind Regards,

Ingo

frederikherema1
Star Contributor
Star Contributor
Glad it works for you!

shukla_raghav
Champ in-the-making
Champ in-the-making
Hi frederik,

As you said I changed my activiti.cfg.xml to include <map>. But still i am getting the same exception PropertyNotFoundException.

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans.xsd">
  <bean id="platinum" class="com.osr.test.PlatinumService" />
  <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
  
      
       <!– Database configurations  –>
    <property name="databaseSchemaUpdate" value="true" />
    <property name="jdbcUrl" value="jdbc:h2:tcp://localhost/activiti" />
    <property name="jdbcDriver" value="org.h2.Driver" />
    <property name="jdbcUsername" value="sa" />
    <property name="jdbcPassword" value="" />
   
    <property name="jobExecutorActivate" value="true" />

  </bean>

<property name="beans">
    <map>
      <entry key="platinum" value-ref="platinum" />
    </map>
  </property>

</beans>

I would also like to include the how i am deploying the app.

1. My JAR file included only the com/osr/test/PlatinumService.class. This jar was copied to location C:\activiti-5.9\apps\apache-tomcat-6.0.32\webapps\activiti-rest\WEB-INF\lib  
2. i deploy my .bar file using activiti-explorer

What is it that i am missing ?  Smiley Sad

frederikherema1
Star Contributor
Star Contributor
Please don't post the same question in different topics… Answered your question in the other topic, btw.

arihant_banthia
Champ in-the-making
Champ in-the-making
Hi,

I am getting a similar error but I am not using any beans property in my activiti.cfg.xml. Instead I am setting the bean as a process variable. "roleInfo" in an instance of that bean.

After creating the deployment artefacts using eclipse I added the jar file in both activiti-explorer or activiti-rest webapp lib (/WEB-INF/lib).
<blockcode>
Caused by: org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'roleInfo'
at org.activiti.engine.impl.juel.AstIdentifier.eval(AstIdentifier.java:83)
at org.activiti.engine.impl.juel.AstProperty.eval(AstProperty.java:52)
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:48)
… 86 more
</blockcode>

I am new to activiti. Can you please tell me what am I missing?

arihant_banthia
Champ in-the-making
Champ in-the-making
Hi,

I think I found the problem with my implementation. I am not specifying the class of "roleInfo" bean anywhere as it is a custom class. Can you tell me where do that. I did not understand it from the user guide..?

Thanks in advance..