-
1. Re: Access to variable via EL ?
sebastian.s Jun 2, 2010 1:40 PM (in response to newbeewan)You did not mention which version of jBPM you are using. By default there are a couple of objects accessable via EL (at least in jBPM3).
<string value="#{variables['lastAssignee']}" /> will create a String-object with the value "
#{variables['lastAssignee']}
".
I believe you want to use <object expr="#{variables['lastAssignee']}" />
-
2. Re: Access to variable via EL ?
newbeewan Jun 3, 2010 5:06 AM (in response to sebastian.s)I'm targetting jbpm 4.3 (I put it into tags), and it doesn't works !
2010-06-03 11:03:26,085 [INFO ] org.jbpm.pvm.internal.svc.DefaultCommandService - exception while executing command org.jbpm.pvm.internal.cmd.CompleteTaskCmd@171fcdde org.jbpm.pvm.internal.wire.WireException: couldn't initialize object 'null': script evaluation error: javax.el.PropertyNotFoundException: Cannot find property variables
Is there any EL context in JBpm 4 ?
Regards
-
3. Re: Access to variable via EL ?
sebastian.s Jun 3, 2010 5:46 AM (in response to newbeewan)I have not checked the correctness of the expression itself. I just noticed the problem with string and object. What's the name of the variable and property you are trying to reference?
I suggest you have a look at the documentation. The example with assignment-handlers given there passes a string as an argument to the assignment-handler. Have a look at one of the other sections using EL where they use <object expr="" /> to reference a process variable.
-
4. Re: Access to variable via EL ?
newbeewan Jun 4, 2010 6:37 AM (in response to sebastian.s)Hi,
After several tests, variables doesn't seem to be accessible into the EL context
In the doc, there are only static value examples or object examples from the execution context, but not from process variables !
Perhaps I missed something or there is something to configure to have variables accessible into EL...
Regards
-
5. Re: Access to variable via EL ?
sebastian.s Jun 5, 2010 3:51 AM (in response to newbeewan)Could you provide a little test case to show you are trying to achieve? jBPM is trying to address your variable as if it was a property. When revisiting the code snippet you have provided here I am really confused about what are you trying to do.
Are you trying to reference a process variable which is called variables?
-
6. Re: Access to variable via EL ?
newbeewan Jun 7, 2010 4:42 AM (in response to sebastian.s)Hi,
My need seems to be pretty simple !
First :
I'have a task, owned by a user.
At the end of the task, I want to record the userid of the owner into a process variable using :
public class TaskAssigneeEventListener implements EventListener { ... @Override public void notify(EventListenerExecution execution) throws Exception { TaskService taskService = processEngine.getTaskService(); Task task = taskService.createTaskQuery().processInstanceId(execution.getProcessInstance().getId()).uniqueResult(); if (task == null) { logger.warn("No task found for ProcessInstance {}", execution.getProcessInstance().getId()); } else { logger.trace("task name {} ; assignee ", task.getName(),task.getAssignee()); execution.createVariable("MyLastTaskAssignee", task.getAssignee()); } } }
Second : I want to retreive that value into an assignment handler to assign that task to that user :
public class MyAssignementHandler implements AssignmentHandler { //Field I want to inject from my process private String previousUserId; @Override public void assign(Assignable assignable, OpenExecution execution) throws Exception { logger.trace("Value of previousUserId {} ", previousUserId); if (previousUserId != null) { assignable.setAssignee(previousUserId); } else { logger.warn("No assignee from the last task !!"); } } }
My tasks :
<task assignee="john" g="174,75,92,52" name="taskUser"> <on event="end"> <event-listener expr="#{taskAssigneeEventListener}"> </event-listener> </on> <transition name="to taskManager" to="taskOther" g="-126,-24" /> </task> <task g="337,173,92,52" name="taskOther"> <assignment-handler expr="#{myAssignementHandler}"> <field name="previousUserId"> <object expr="#{variables['MyLastTaskAssignee']}"/> </field> </assignment-handler> <transition name="to end1" to="end1" g="-65,-24" /> </task>
Is it better to understand my need ?
With that code I've got that exception :
org.jbpm.pvm.internal.wire.WireException: couldn't initialize object 'null': script evaluation error: javax.el.PropertyNotFoundException: Cannot find property variables at org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor.initialize(ObjectDescriptor.java:238) at org.jbpm.pvm.internal.wire.WireContext.performInitialization(WireContext.java:533) at org.jbpm.pvm.internal.wire.WireContext.initialize(WireContext.java:495) at org.jbpm.pvm.internal.wire.WireContext.create(WireContext.java:449) at org.jbpm.pvm.internal.wire.WireContext.create(WireContext.java:258) at org.jbpm.pvm.internal.util.ReflectUtil.instantiateUserCode(ReflectUtil.java:310) at org.jbpm.pvm.internal.wire.usercode.UserCodeReference.getObject(UserCodeReference.java:63) at org.jbpm.pvm.internal.wire.usercode.UserCodeReference.getObject(UserCodeReference.java:51) at org.jbpm.pvm.internal.model.ExecutionImpl.initializeAssignments(ExecutionImpl.java:759) at org.jbpm.jpdl.internal.activity.TaskActivity.execute(TaskActivity.java:95) at org.jbpm.jpdl.internal.activity.TaskActivity.execute(TaskActivity.java:58) at org.jbpm.pvm.internal.model.op.ExecuteActivity.perform(ExecuteActivity.java:60) at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperationSync(ExecutionImpl.java:656) at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperation(ExecutionImpl.java:616) at org.jbpm.pvm.internal.model.ExecutionImpl.signal(ExecutionImpl.java:417) at org.jbpm.pvm.internal.model.ExecutionImpl.signal(ExecutionImpl.java:403) 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:616) at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:197) at org.jbpm.pvm.internal.model.ExecutionImpl_$$_javassist_5.signal(ExecutionImpl_$$_javassist_5.java) at org.jbpm.pvm.internal.task.TaskImpl.complete(TaskImpl.java:194) at org.jbpm.pvm.internal.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:65) at org.jbpm.pvm.internal.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:32) at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42) at org.jbpm.pvm.internal.tx.SpringCommandCallback.doInTransaction(SpringCommandCallback.java:45) at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130) at org.jbpm.pvm.internal.tx.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:55) at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53) at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40) at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:55) at org.jbpm.pvm.internal.svc.TaskServiceImpl.completeTask(TaskServiceImpl.java:96) at mypackage.MyAssignementHandlerTest.testAssignement(MyAssignementHandlerTest.java:44) 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:616) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: org.jbpm.api.JbpmException: script evaluation error: javax.el.PropertyNotFoundException: Cannot find property variables at org.jbpm.pvm.internal.script.ScriptManager.evaluate(ScriptManager.java:130) at org.jbpm.pvm.internal.script.ScriptManager.evaluate(ScriptManager.java:118) at org.jbpm.pvm.internal.script.ScriptManager.evaluateExpression(ScriptManager.java:90) at org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor.construct(ObjectDescriptor.java:180) at org.jbpm.pvm.internal.wire.WireContext.construct(WireContext.java:469) at org.jbpm.pvm.internal.wire.WireContext.create(WireContext.java:448) at org.jbpm.pvm.internal.wire.operation.FieldOperation.apply(FieldOperation.java:43) at org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor.initialize(ObjectDescriptor.java:234) ... 61 more Caused by: javax.script.ScriptException: javax.el.PropertyNotFoundException: Cannot find property variables at org.jbpm.pvm.internal.script.JuelScriptEngine.evalExpr(JuelScriptEngine.java:180) at org.jbpm.pvm.internal.script.JuelScriptEngine.eval(JuelScriptEngine.java:64) at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264) at org.jbpm.pvm.internal.script.ScriptManager.evaluate(ScriptManager.java:126) ... 68 more Caused by: javax.el.PropertyNotFoundException: Cannot find property variables at de.odysseus.el.util.SimpleResolver.get(SimpleResolver.java:106) at de.odysseus.el.util.SimpleResolver.getValue(SimpleResolver.java:126) at de.odysseus.el.tree.impl.ast.AstIdentifier.eval(AstIdentifier.java:69) at de.odysseus.el.tree.impl.ast.AstProperty.eval(AstProperty.java:46) at de.odysseus.el.tree.impl.ast.AstEval.eval(AstEval.java:42) at de.odysseus.el.tree.impl.ast.AstNode.getValue(AstNode.java:29) at de.odysseus.el.TreeValueExpression.getValue(TreeValueExpression.java:120) at org.jbpm.pvm.internal.script.JuelScriptEngine.evalExpr(JuelScriptEngine.java:176) ... 71 more
Regards
-
7. Re: Access to variable via EL ?
newbeewan Jun 7, 2010 4:52 AM (in response to newbeewan)I solve it by using directly
#{MyLastTaskAssignee} in the expr attribute...
I don't understand why it was not working previously !
Thanks for all your help !
Regards