cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with createTaskQuery().taskCandidateGroup and user

cweber
Champ in-the-making
Champ in-the-making
Hi everybody.
I got a problem by using
return taskService.createTaskQuery().taskCandidateGroup("sales").list();
and
return taskService.createTaskQuery().taskCandidateUser("kermit").list();

If I run this commands from eclipse with contacting the h2 database from the activiti demo 5.9 on my computer it works allright.
But I copied the  "apps\h2" folder from the demo into a virtual maschine.

There I also can run different commands like…
taskService.createTaskQuery().taskAssignee(pUserId).list();

but if I try to run this…
return taskService.createTaskQuery().taskCandidateGroup("sales").list();

I got the following error.
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: org.apache.ibatis.builder.BuilderException: Error evaluating expression 'candidateGroups != null && candidateGroups.size() > 0'. Cause: org.apache.ibatis.ognl.MethodFailedException: Method "size" failed for object [sales] [java.lang.IllegalAccessException: Method [public int java.util.Collections$SingletonList.size()] cannot be accessed.]
### The error may exist in org/activiti/db/mapping/entity/Task.xml
### The error may involve org.activiti.engine.impl.persistence.entity.TaskEntity.selectTaskByQueryCriteria
### The error occurred while executing a query
### Cause: org.apache.ibatis.builder.BuilderException: Error evaluating expression 'candidateGroups != null && candidateGroups.size() > 0'. Cause: org.apache.ibatis.ognl.MethodFailedException: Method "size" failed for object [sales] [java.lang.IllegalAccessException: Method [public int java.util.Collections$SingletonList.size()] cannot be accessed.]
    org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
    org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:81)
    org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:73)
    org.activiti.engine.impl.db.DbSqlSession.selectList(DbSqlSession.java:188)
    org.activiti.engine.impl.persistence.entity.TaskManager.findTasksByQueryCriteria(TaskManager.java:91)
    org.activiti.engine.impl.TaskQueryImpl.executeList(TaskQueryImpl.java:368)
    org.activiti.engine.impl.AbstractQuery.execute(AbstractQuery.java:138)
    org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
    org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:42)
    org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
    org.activiti.engine.impl.AbstractQuery.list(AbstractQuery.java:112)
    de.mettenmeier.activiti.engine.MBSActivitiTask.getAllFreeTasksForGroup(MBSActivitiTask.java:72)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    java.lang.reflect.Method.invoke(Method.java:611)
    com.ibm.jscript.types.JavaAccessObject.call(JavaAccessObject.java:321)
    com.ibm.jscript.types.FBSObject.call(FBSObject.java:161)
    com.ibm.jscript.ASTTree.ASTCall.interpret(ASTCall.java:175)
    com.ibm.jscript.ASTTree.ASTProgram.interpret(ASTProgram.java:119)
    com.ibm.jscript.ASTTree.ASTProgram.interpretEx(ASTProgram.java:139)
    com.ibm.jscript.JSExpression._interpretExpression(JSExpression.java:435)
    com.ibm.jscript.JSExpression.access$1(JSExpression.java:424)
    com.ibm.jscript.JSExpression$2.run(JSExpression.java:414)
    java.security.AccessController.doPrivileged(AccessController.java:284)
    com.ibm.jscript.JSExpression.interpretExpression(JSExpression.java:410)
    com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:251)
    com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:234)
    com.ibm.xsp.javascript.JavaScriptInterpreter.interpret(JavaScriptInterpreter.java:221)
    com.ibm.xsp.javascript.JavaScriptInterpreter.interpret(JavaScriptInterpreter.java:193)
    com.ibm.xsp.binding.javascript.JavaScriptValueBinding.getValue(JavaScriptValueBinding.java:78)
    com.ibm.xsp.component.UIDataEx.resolveValue(UIDataEx.java:371)
    com.ibm.xsp.component.UIDataEx._createDataModel(UIDataEx.java:209)
    com.ibm.xsp.component.UIDataEx.createDataModel(UIDataEx.java:162)
    com.ibm.xsp.component.UIDataEx.getDataModel(UIDataEx.java:136)
    com.ibm.xsp.renderkit.html_extended.DataTableRendererEx.encodeChildren(DataTableRendererEx.java:1347)
    com.ibm.xsp.renderkit.ReadOnlyAdapterRenderer.encodeChildren(ReadOnlyAdapterRenderer.java:162)
    javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:979)
    com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:842)
    com.ibm.xsp.renderkit.html_extended.TabbedPanelRenderer.encodeChildren(TabbedPanelRenderer.java:272)
    com.ibm.xsp.renderkit.ReadOnlyAdapterRenderer.encodeChildren(ReadOnlyAdapterRenderer.java:162)
    javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:979)
    com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:842)
    com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
    com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
    com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
    com.ibm.xsp.component.UIViewRootEx._renderView(UIViewRootEx.java:1317)
    com.ibm.xsp.component.UIViewRootEx.renderView(UIViewRootEx.java:1255)
    com.ibm.xsp.application.ViewHandlerExImpl.doRender(ViewHandlerExImpl.java:641)
    com.ibm.xsp.application.ViewHandlerExImpl._renderView(ViewHandlerExImpl.java:320)
    com.ibm.xsp.application.ViewHandlerExImpl.renderView(ViewHandlerExImpl.java:335)
    com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:103)
    com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:210)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:120)
    com.ibm.xsp.controller.FacesControllerImpl.render(FacesControllerImpl.java:264)
    com.ibm.xsp.webapp.FacesServlet.serviceView(FacesServlet.java:248)
    com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:204)
    com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:160)
    com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:138)
    com.ibm.xsp.webapp.DesignerFacesServlet.service(DesignerFacesServlet.java:103)
    com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(ComponentModule.java:576)
    com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(NSFComponentModule.java:1281)
    com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:847)
    com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(ComponentModule.java:796)
    com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(ComponentModule.java:565)
    com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(NSFComponentModule.java:1265)
    com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:653)
    com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:476)
    com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:341)
    com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:297)
    com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)
org.apache.ibatis.builder.BuilderException: Error evaluating expression 'candidateGroups != null && candidateGroups.size() > 0'. Cause: org.apache.ibatis.ognl.MethodFailedException: Method "size" failed for object [sales] [java.lang.IllegalAccessException: Method [public int java.util.Collections$SingletonList.size()] cannot be accessed.]
    org.apache.ibatis.builder.xml.dynamic.ExpressionEvaluator.evaluateBoolean(ExpressionEvaluator.java:23)
    org.apache.ibatis.builder.xml.dynamic.IfSqlNode.apply(IfSqlNode.java:15)
    org.apache.ibatis.builder.xml.dynamic.MixedSqlNode.apply(MixedSqlNode.java:14)
    org.apache.ibatis.builder.xml.dynamic.IfSqlNode.apply(IfSqlNode.java:16)
    org.apache.ibatis.builder.xml.dynamic.MixedSqlNode.apply(MixedSqlNode.java:14)
    org.apache.ibatis.builder.xml.dynamic.TrimSqlNode.apply(TrimSqlNode.java:27)
    org.apache.ibatis.builder.xml.dynamic.MixedSqlNode.apply(MixedSqlNode.java:14)
    org.apache.ibatis.builder.xml.dynamic.MixedSqlNode.apply(MixedSqlNode.java:14)
    org.apache.ibatis.builder.xml.dynamic.DynamicSqlSource.getBoundSql(DynamicSqlSource.java:22)
    org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:198)
    org.apache.ibatis.executor.BaseExecutor.createCacheKey(BaseExecutor.java:142)
    org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:112)
    org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:72)
    org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:79)
    org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:73)
    org.activiti.engine.impl.db.DbSqlSession.selectList(DbSqlSession.java:188)
    org.activiti.engine.impl.persistence.entity.TaskManager.findTasksByQueryCriteria(TaskManager.java:91)
    org.activiti.engine.impl.TaskQueryImpl.executeList(TaskQueryImpl.java:368)
    org.activiti.engine.impl.AbstractQuery.execute(AbstractQuery.java:138)
    org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
    org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:42)
    org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
    org.activiti.engine.impl.AbstractQuery.list(AbstractQuery.java:112)
    de.mettenmeier.activiti.engine.MBSActivitiTask.getAllFreeTasksForGroup(MBSActivitiTask.java:72)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    java.lang.reflect.Method.invoke(Method.java:611)
    com.ibm.jscript.types.JavaAccessObject.call(JavaAccessObject.java:321)
    com.ibm.jscript.types.FBSObject.call(FBSObject.java:161)
    com.ibm.jscript.ASTTree.ASTCall.interpret(ASTCall.java:175)
    com.ibm.jscript.ASTTree.ASTProgram.interpret(ASTProgram.java:119)
    com.ibm.jscript.ASTTree.ASTProgram.interpretEx(ASTProgram.java:139)
    com.ibm.jscript.JSExpression._interpretExpression(JSExpression.java:435)


Any idea what I have to do to get it work on the copy of the database? (as I said: the other queries work on that)
7 REPLIES 7

frederikherema1
Star Contributor
Star Contributor
It's not database-related, it's your JVM:


java.lang.IllegalAccessException: Method [public int java.util.Collections$SingletonList.size()] cannot be accessed

Strange, calling the size() on a singletonList should be possible. What JDK are you running?

cweber
Champ in-the-making
Champ in-the-making
Thanks for the quick answear.

I think my problem has to do with the domino server 8 where I use to run the code.
If I run the code from eclipse with java 1.6 (in the vm) the queries work fine. But on the domino server (uses java 1.6, too) it crahes with the shown exception.

During the time I tested it with eclipse and the jvm folder of the domino server and it worked there ,too.

I thougt maybe domino could not handle singletonLists with Xpages.
So I tried to instanciate my own Collection.singletonList

public List<List> testSingletonList()
{ System.out.println("Erzeuge Singleton Liste()");
  List<String> str = Collections.singletonList("Listenelement1");
  System.out.println("Nach dem 1 Element ist die Size() "+str.size());
  return str;
}

And it worked fine with that. I could show the list element in my Xpage.

I have no idea, why domino can not get the function taskCandidateGroup done.

two further questions:
1. Is there another way to get the candidate tasks for a user or his groups?
2. Why is the singletonList used for the taskCandidateGroup and nowhere else?

Thanks for help.

frederikherema1
Star Contributor
Star Contributor
1. This is the only way to get tasks for the user (including his/her groups).
2. Internally, we use a list of groups the query operates on. When you just use a single group (taskCandidateGroup("sales")), this is wrapped in such a list. Maybe a bit dirty, but if you can't get your environment sorted out, you can always replace the taskCandidateGroup("sales") by taskCandidateGroupIn(Arrays.asList("sales")) which is equivalent (if you know how the engine handles this inside).

cweber
Champ in-the-making
Champ in-the-making
thanks again frederikheremans.

If somebody else run into the same error it would be great to read about here.
I go on searching. If i get to know why it would not work on domino I will post it here.

cweber
Champ in-the-making
Champ in-the-making
I found out why I couldn't get the methods for taskCandidate work on domino.
Maybe it will help somebody else.

It was defenitly a jvm permission problem. I'm not sure what permission is the correct one, but if I insert
permission java.security.AllPermission;into the [domino]/jvm/lib/security/java.policy it works.

So I can go on testing and have to find out which permissions are needed for a Collections.singletonList.

Thanks frederikheremans for help.

long_187
Champ in-the-making
Champ in-the-making
1. This is the only way to get tasks for the user (including his/her groups).
2. Internally, we use a list of groups the query operates on. When you just use a single group (taskCandidateGroup("sales")), this is wrapped in such a list. Maybe a bit dirty, but if you can't get your environment sorted out, you can always replace the taskCandidateGroup("sales") by taskCandidateGroupIn(Arrays.asList("sales")) which is equivalent (if you know how the engine handles this inside).

I have encountered the same problem in Load test!

but taskCandidateGroupIn(Arrays.asList("sales"))  cannot resolve this problem, because Arrays.asList("sales") returns a Arrays$ArrayList instance which class is declared by "private" modifer, just like Collections$SingletonList.

Use java.util.ArrayList can resolve this problem:
List candidateGroupList = new java.util.ArrayList(1);
candidateGroupList.add(candidateGroup);
taskService.createTaskQuery().taskCandidateGroupIn(candidateGroupList);

I advice modify TaskQueryImpl.getCandidateGroups() method as follow:
public List<String> getCandidateGroups() {
    if (candidateGroup!=null) {
      //return Collections.singletonList(candidateGroup);
      List candidateGroupList = new java.util.ArrayList(1);
      candidateGroupList.add(candidateGroup);
      return candidateGroupList;
    } else if (candidateUser != null) {
      return getGroupsForCandidateUser(candidateUser);
    } else if(candidateGroups != null) {
      return candidateGroups;
    }
    return null;
  }