4 Replies Latest reply on Jan 15, 2010 9:55 AM by tejjbpm

    TaskService issue

    tejjbpm

      Hi

       

      I had to run the following line multiple times to get the list of tasks for a list of process instance ids.

       

      List<Task> tasks =

      taskService.createTaskQuery().processInstanceId(processInstanceId).list();

       

      The problem is that everytime this query is run the JBPM API opens a connection to my MYSQL database and is not explicitly closing it.(when i run netstat i see a list of connections in the ESTABLISHED state)

       

      So i get too many connections error even if I run for 20 times.

       

      Has anybody faced this problem? Is there any method in the API to cleanup the task query (and all connections related to it).

       

      Any help is appreciated.

        • 1. Re: TaskService issue
          saraswati.santanu

          Its not the responsibility of JBPM to manage connections. It must be hibernate which is opening the connection.

           

          You need to explicitly close a connection if you are not using transaction manager, otherwise transaction manager pretty much does it for you.

           

          If you are using a transaction manager then you might need to check why this particular task service call is executed outside a transaction.

           

          If you are developing a JEE app and not using a transaction manager, then... best of luck

          1 of 1 people found this helpful
          • 2. Re: TaskService issue
            tejjbpm

            Hi Santanu

             

            Thanks for the reply.

             

            I am using a transaction manager and it is my hiberate which is doing the talking with the database.

             

            Here is my config. Do you see anything wrong with this? Do I have to declare any additional params for cleanup.. Actually I am using the default config which came with the installation and have not added anything extra..I also ran a test for all my other API calls and everything seem to have the same issue..so it is just not the task query..

             

            Thanks in advance ..

             

            <?xml version="1.0" encoding="utf-8"?>

            <!DOCTYPE hibernate-configuration PUBLIC
                      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
                      "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">>
            <session-factory>

            <hibernate-configuration

              <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
                <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
                <property name="hibernate.connection.url">jdbc:mysql://localhost/mydb</property>
                <property name="hibernate.connection.username">username</property>
                <property name="hibernate.connection.password">password</property>
                <property name="hibernate.format_sql">true</property>

              <mapping resource="jbpm.repository.hbm.xml" />
              <mapping resource="jbpm.execution.hbm.xml" />
              <mapping resource="jbpm.history.hbm.xml" />
              <mapping resource="jbpm.task.hbm.xml" />
              <mapping resource="jbpm.identity.hbm.xml" />

            </session-factory>
            </hibernate-configuration>

            • 3. Re: TaskService issue
              saraswati.santanu

              I believe, if you need to use jta transaction manager and data source in a server managed environment then this configuration is not good. You should not give db driver, db url etc to hibernate. They should be configured in the server. And the data source and tx manager configured in server should be provided to hibernate.

               

              So instead of the following:

               

                <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
                  <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
                  <property name="hibernate.connection.url">jdbc:mysql://localhost/mydb</property>
                  <property name="hibernate.connection.username">username</property>
                  <property name="hibernate.connection.password">password</property>

               

              you should be using something like:

               

              <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>

              <!--Provide the actual data source name you have configured here-->

              <property name="connection.datasource">java:comp/jdbc/MySQLDataSource</property>

              <property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>

              <!--Provide the actual tx manager name you have configured here-->
              <property name="jta.UserTransaction">java:comp/UserTransaction</property>

               

              Give the actual datasource and tx manager JNDI name that you configured.

              • 4. Re: TaskService issue
                tejjbpm

                Hi Santanu

                 

                Thanks a ton.

                 

                After making the changes you suggested it worked for me.