Bug 1105868 - SQLGrammarException in getTasksAssignedAsPotentialOwner executed via Remote API
Summary: SQLGrammarException in getTasksAssignedAsPotentialOwner executed via Remote API
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss BPMS Platform 6
Classification: Retired
Component: Business Central
Version: 6.0.2
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: CR1
: 6.0.2
Assignee: Mauricio Salatino
QA Contact: Ivo Bek
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-06-08 10:52 UTC by Ivo Bek
Modified: 2014-08-06 19:51 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-08-06 19:51:18 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
server log with the stacktrace of the exception (33.12 KB, text/x-log)
2014-06-08 10:52 UTC, Ivo Bek
no flags Details
mysql stacktrace (14.69 KB, text/plain)
2014-06-09 12:05 UTC, Radovan Synek
no flags Details

Description Ivo Bek 2014-06-08 10:52:06 UTC
Created attachment 903274 [details]
server log with the stacktrace of the exception

Description of problem:

I use BPMS 6.0.2.ER3 with PostgreSQL 9.2 but I assume that on other databases could be the problem as well. Although, it does work with the default H2 database. 

When I execute getTasksAssignedAsPotentialOwner operation in the JMS TaskService, I get:

org.kie.services.client.api.command.exception.RemoteApiException: SQLGrammarException thrown with message 'could not extract ResultSet'
	at org.kie.services.client.api.command.AbstractRemoteCommandObject.executeJmsCommand(AbstractRemoteCommandObject.java:358)
	at org.kie.services.client.api.command.AbstractRemoteCommandObject.execute(AbstractRemoteCommandObject.java:126)
	at org.jbpm.services.task.impl.command.CommandBasedTaskService.getTasksAssignedAsPotentialOwner(CommandBasedTaskService.java:185)

I attached the part of server log where is the full stacktrace of the exception. :

org.postgresql.util.PSQLException: ERROR: syntax error at or near ")"
  Position: 1167
.....

Version-Release number of selected component (if applicable):


How reproducible:

In your test case, it is not needed to have some existing task. In such scenario the operation should return empty list but in this case it returns the exception.

It should be enough to run this code:
List<TaskSummary> tasksForTestUser = taskService.getTasksAssignedAsPotentialOwner("testuser", "en-UK");

and the list should be empty.

Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 2 Ivo Bek 2014-06-09 11:28:00 UTC
The issue appeares not only on Postgresql but also on MySQL and it is not specific just for JMS, REST API fails too.

Comment 3 Mauricio Salatino 2014-06-09 11:31:15 UTC
Hi Ivo,
can you provide the log for MySQL? 
And can you confirm that you are using the taskorm.xml file that is provided by the jbpm-human-task-jpa jar module? -> https://github.com/droolsjbpm/jbpm/blob/master/jbpm-human-task/jbpm-human-task-jpa/src/main/resources/META-INF/Taskorm.xml

Comment 4 Ivo Bek 2014-06-09 11:49:00 UTC
Hi Mauricio,

Radek will attach the server log for MySQL.

Everything is running on the BPMS server and the problem happens there so I do not think that I should configure anything else in the client. I just do some REST or JMS requests. If Jbpm engine is not configured correctly to use taskorm.xml in the Business Central then it is a bug and I am not sure if can change there anything.

Comment 5 Mauricio Salatino 2014-06-09 11:53:26 UTC
Ivo, that's ok I just wanted to be sure that you are not running against a modified copy of the taskorm.xml file. 

Can you also please attach the result of running the tests that you mention before -> http://git.app.eng.bos.redhat.com/git/jbossqe/brms.git/tree/test-jbpm-integration/src/test/java/org/jboss/qa/bpms/jbpm/integration/client/task/CGetTaskTest.java#n102 with MySQL and postgreSQL? because the logs that you have attached doesn't seem to be running that specific test.

I'm doing some tests with the internal APIs and there seems to not be any issue at that level.

Comment 6 Mauricio Salatino 2014-06-09 12:02:53 UTC
There seems to be an issue with the DBs in general regarding the IN operator in the queries: http://postgresql.1045698.n5.nabble.com/IN-query-operator-and-NULL-values-td1901954.html

This means that we will need to check for empty lists. 
Can you please confirm that the user has roles (groups) configured? So we make sure that this will work if the user is providing at least a group?

regards

Comment 7 Radovan Synek 2014-06-09 12:05:41 UTC
Created attachment 904621 [details]
mysql stacktrace

Mauricio, here is the requested stacktrace for mysql.

Comment 8 Ivo Bek 2014-06-09 12:45:37 UTC
This is the output of the test on the client side:

org.kie.services.client.api.command.exception.RemoteApiException: SQLGrammarException thrown with message 'could not extract ResultSet'
	at org.kie.services.client.api.command.AbstractRemoteCommandObject.executeJmsCommand(AbstractRemoteCommandObject.java:358)
	at org.kie.services.client.api.command.AbstractRemoteCommandObject.execute(AbstractRemoteCommandObject.java:126)
	at org.jbpm.services.task.impl.command.CommandBasedTaskService.getTasksAssignedAsPotentialOwner(CommandBasedTaskService.java:185)
	at org.jboss.qa.bpms.jbpm.integration.client.task.CGetTaskTest.testGetGroupTask(CGetTaskTest.java:110)

The log I attached previously is from the server log what is happening there because the client log won't tell much as you can see. Actually it fails when I do:

List<TaskSummary> tasksForTestUser = taskService.getTasksAssignedAsPotentialOwner("testuser", "en-UK");

For sure the user does not have any tasks to do, so it might be the problem as you pointed in the case the list is empty.

If you mean the groups like admin, analyst, manager, ... then yes, I set admin group for the testadmin.

Comment 9 Mauricio Salatino 2014-06-09 12:47:07 UTC
Ivo, can you try setting a different role like for example user to the testuser? To see if you get the exact same error?

Comment 10 Ivo Bek 2014-06-09 12:57:21 UTC
Sure, I will try it. We have a meeting now, so after that.

Comment 11 Mauricio Salatino 2014-06-09 14:20:56 UTC
The role admin is filtered to not be used as a group for a user, so it must be avoided for doing tests, let us know if it works with a user with different roles.

Comment 12 Ivo Bek 2014-06-09 16:57:40 UTC
The issue is independent on the role I set. The test fails also when I use a testuser with role user.

AFAIK the admin role is allowed and we use it quite often because otherwise we don't have all the permissions we need but the problem is when the user is called admin too, isn't it?

Comment 13 Mauricio Salatino 2014-06-10 08:56:56 UTC
Hi Ivo, guys,
I've pushed some internal checks for empty lists inside the TaskQueryService -> http://github.com/droolsjbpm/jbpm/commit/32fba6dad (6.0.x)

Can you please test again to verify that these fixes fix the issue with PostgreSQL and MySQL?

Comment 14 Radovan Synek 2014-06-10 11:40:23 UTC
Hi Mauricio,
fixed (at least) for mysql.

Thanks!

Comment 15 Mauricio Salatino 2014-06-10 13:50:58 UTC
Hi Radovan!
Great news! Let's see if it works for PostgreSQL. Any idea if anyone is testing with Oracle? just to confirm that too?

Comment 16 Ivo Bek 2014-06-10 14:05:54 UTC
Mauricio, it is not easy to test the fix against all databases we support right now (Oracle, DB2, MSSql, ...) because we have to configure it all locally, so I would wait for the next build. At least I could try PostgreSQL too if you want to be sure.

Comment 17 Mauricio Salatino 2014-06-10 15:19:26 UTC
Hi Ivo, if you can try with PostgreSQL that will be great

Comment 18 Ivo Bek 2014-06-10 16:01:15 UTC
Tomorrow, we will test the fix against all databases and run all integration tests to confirm and be absolutely sure there are no regressions.

Comment 19 Kris Verlaenen 2014-06-10 19:17:26 UTC
I've reconfigured business-central (BPMS 6.0.2.ER3) to run on PostgreSQL 9.3 (installed on localhost) and didn't have any issues using the remote Java client (through REST) to get the task list.

I did the following changes from a clean unzip of the EAP distribution:

in jboss-eap-6.1\standalone\deployments\business-central.war\WEB-INF\classes\META-INF\persistence.xml
      <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />

in jboss-eap-6.1\standalone\configuration\standalone.xml

         <datasources>
            <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
               <connection-url>jdbc:postgresql://localhost/jbpm</connection-url>
               <driver>postgresql</driver>
               <security>
                  <user-name>jbpm</user-name>
                  <password>jbpm</password>
               </security>
            </datasource>
            <drivers>
               <driver name="h2" module="com.h2database.h2">
                  <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
               </driver>
               <driver name="postgresql" module="org.postgresql">
                  <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
               </driver>
            </drivers>
         </datasources>

Afterwards, I ran the following code (where adminuser is a user with only role admin):

RuntimeEngine engine = RemoteRestRuntimeEngineFactory.newBuilder()
			.addUserName("adminuser").addPassword("password1_")
			.addUrl(new URL("http://localhost:8080/business-central")).build().newRuntimeEngine();
		System.out.println(engine.getTaskService().getTasksAssignedAsPotentialOwner("adminuser", "en-UK").size());

I did that once without any tasks, and then once after creating one task through the UI, it returned 0 and 1 respectively (as expected).

Comment 20 Ivo Bek 2014-06-11 14:58:44 UTC
All the integration tests passed against db2-97, mssql2012, mysql5.5, postgresql 9.2, and oracle11. There no regressions and the changes fix the problem.

Comment 21 Ivo Bek 2014-06-18 14:55:49 UTC
Verified in BPMS 6.0.2.CR1


Note You need to log in before you can comment on or make changes to this bug.