cancel
Showing results for 
Search instead for 
Did you mean: 

Can I have acces to custom beans without Spring?

gsvano
Champ in-the-making
Champ in-the-making
Hi everyone!
I tried get access to my service to set dueDate in UserTask but.. fail
<userTask id="bidSelection" activiti:dueDate="${dateService.getDueDate()}" …

I tried set beans
Map<Object, Object> beans = new HashMap<Object, Object>();
beans.put("dateService", dateService);
((ProcessEngineConfigurationImpl) configuration).setBeans(beans);
but got same exception
Caused by: org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'dateService'
   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)

As far I understand I should use Spring for it but my project not use Spring (I use EJB and CDI).
Are there any way to get my services beans in this case?
Maybe I do something wrong?
Thanks!
5 REPLIES 5

deepyou
Champ in-the-making
Champ in-the-making
I tried set beansMap<Object, Object> beans = new HashMap<Object, Object>();
beans.put("dateService", dateService);
((ProcessEngineConfigurationImpl) configuration).setBeans(beans);

I suppose you have to set up your bean in your application context, in your spring configuration context you need something like this:

<bean id="dateServicer" class="org.activiti.yourpackage.dateService" />
Read the chapter about Use Activiti with Spring on "Activiti in Action" Book.
Let me know

gsvano
Champ in-the-making
Champ in-the-making
Yes, you right it will work, but I want find way to set beans without Spring.
I want to use them out of processes.

deepyou
Champ in-the-making
Champ in-the-making
Yes, you right it will work, but I want find way to set beans without Spring.
I want to use them out of processes.

Maybe you can use a DelegateExpression, it's work but if you'll use this your bean must implement JavaDelegate

gsvano
Champ in-the-making
Champ in-the-making
Any examles?
I want use it in UserTasks to set DueDate field.

gsvano
Champ in-the-making
Champ in-the-making
Ok, I found solution

Should add the Expression manager into configuration
ProcessEngineConfiguration configuration = CdiStandaloneProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();
configuration.setExpressionManager(new CdiExpressionManager());
and to use standart cdi annotations

@Named
public class DateService {
    public Date getDueDate() {
        …
    }
}