cancel
Showing results for 
Search instead for 
Did you mean: 

Activiti Spring bean not working with overloaded method error

smurfs
Champ in-the-making
Champ in-the-making
Activiti Spring bean and overloaded method error.
Follow this thread
I have the following Spring bean methods:
/**
    * Whether or not to auto-reject this applicant based on the
    * AutoRejectConfigItem rules configured in the system.
    *
    * @param user - The user to check.
    * @return - Whether or not to auto-reject.
    */
   public boolean isUserAutoRejectCandidate(User user);

   /**
    * Whether or not to auto-reject this applicant based on the
    * AutoRejectConfigItem rules configured in the system.
    *
    * @param email - The email address of the {@link seah.model.User} to check.
    * @return - true/false
    * @throws AppException - If the user cannot be found.
    */
   public boolean isUserAutoRejectCandidate(String email) throws AppException;
I'm calling one of them like this:
<conditionExpression xsi:type="tFormalExpression">${ userService.isUserAutoRejectCandidate(email) }</conditionExpression>

But I get the following exception:
Quote:
Caused by: org.activiti.engine.impl.javax.el.ELException: Cannot coerce from class java.lang.String to class seah.model.profile.User
at org.activiti.engine.impl.juel.TypeConverterImpl.coerceStringToType(TypeConverterImpl.java:287)
at org.activiti.engine.impl.juel.TypeConverterImpl.coerceToType(TypeConverterImpl.java:348)
at org.activiti.engine.impl.juel.TypeConverterImpl.convert(TypeConverterImpl.java:365)
at org.activiti.engine.impl.juel.ExpressionFactoryImpl.coerceToType(ExpressionFactoryImpl.java:418)
at org.activiti.engine.impl.javax.el.BeanELResolver.coerceValue(BeanELResolver.java:582)
at org.activiti.engine.impl.javax.el.BeanELResolver.coerceParams(BeanELResolver.java:574)
at org.activiti.engine.impl.javax.el.BeanELResolver.invoke(BeanELResolver.java:479)
at org.activiti.engine.impl.javax.el.CompositeELResolver.invoke(CompositeELResolver.java:397)
at org.activiti.engine.impl.juel.AstMethod.invoke(AstMethod.java:91)
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.el.JuelExpression.getValue(JuelExpression.java:46)
… 166 more
This seems like an issue with the reflection implementation in Activiti.
1 REPLY 1

vasile_dirla
Star Contributor
Star Contributor
Hi,

According to the EL specs method overloading is not supported.

As I know EL get the methods via reflection calling this method:
{code}
public Method[] getMethods() throws SecurityException;
{code}

but in the documentation is written:
"The elements in the array returned are not sorted and are not in any particular order."
Which could lead to inconsistent behaviour for multiple EL calls.
the first call could succeed but the second one could fail (as you already noticed)
So the best solution is to create different methods having different names just to remove the confusion.

Have a look also here:
https://github.com/beckchr/juel/issues/72
JUEL documentation says: "If the given paramTypes is not null, select the method with the given name and parameter types. Else select the method with the given name that has the same number of parameters. If there are more than one such method, the method selection process is undefined. Else select the method with the given name that takes a variable number of arguments."

You could also have a look here
https://bz.apache.org/bugzilla/show_bug.cgi?id=56147