0 Replies Latest reply on Jul 14, 2013 9:33 PM by yu zhou

    how to handle this?

    yu zhou Newbie

      This is my task server:

       
      import java.util.HashMap;
      import java.util.Map;
      import javax.persistence.EntityManagerFactory;
      import javax.persistence.Persistence;
      import org.drools.KnowledgeBaseFactory;
      import org.drools.SystemEventListenerFactory;
      import org.drools.runtime.Environment;
      import org.drools.runtime.EnvironmentName;
      import org.jbpm.task.User;
      import org.jbpm.task.service.TaskService;
      import org.jbpm.task.service.TaskServiceSession;
      import org.jbpm.task.service.mina.MinaTaskServer;
       
      import bitronix.tm.resource.jdbc.PoolingDataSource;
      
      public class JBPMTaskServer{
       public JBPMTaskServer() {
        // TODO Auto-generated constructor stub
       }
       /**
        * @param args
        */
       public static void main(String[] args) {
        // TODO Auto-generated method stub
        setupDataSource();
        //String dialect = properties.getProperty("persistence.persistenceunit.dialect", "org.hibernate.dialect.H2Dialect");
        Map<String, String> map = new HashMap<String, String>();
        map.put("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
              EntityManagerFactory emf = Persistence
          .createEntityManagerFactory("org.jbpm.persistence.jpa",map); 
         
      /*  Environment env = KnowledgeBaseFactory.newEnvironment();
        env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);*/
        TaskService taskService = new TaskService(emf, SystemEventListenerFactory.getSystemEventListener());
        TaskServiceSession taskSession = taskService.createSession();
              // now register new users and groups
              //taskSession.addUser(new User("mary"));
              //taskSession.addUser(new User("john"));
        
        MinaTaskServer server = new MinaTaskServer( taskService );
        Thread thread = new Thread( server );
        thread.start();
       }
       
       private static void setupDataSource(){
        PoolingDataSource ds = new PoolingDataSource();
        ds.setUniqueName("jdbc/jbpm-ds");
        ds.setClassName(com.mysql.jdbc.jdbc2.optional.MysqlXADataSource.class
          .getName());
        ds.setMaxPoolSize(3);
        ds.setAllowLocalTransactions(true);
        ds.getDriverProperties().put("user", "jbossjbpm");
        ds.getDriverProperties().put("password", "jbossjbpm");
        ds.getDriverProperties().put("URL", "jdbc:mysql://localhost:3306/jbpm");
        // ds.getDriverProperties().put("driverClassName",
        // "com.mysql.jdbc.Driver");
        ds.init();
       }
      }
      

      And this is my task client,

      and i seprate this class into two projects:

       

       
      import java.util.HashMap;
      import java.util.Map;
      import javax.persistence.EntityManagerFactory;
      import javax.persistence.Persistence;
      import org.drools.KnowledgeBaseFactory;
      import org.drools.SystemEventListenerFactory;
      import org.drools.runtime.Environment;
      import org.drools.runtime.EnvironmentName;
      import org.jbpm.task.User;
      import org.jbpm.task.service.TaskService;
      import org.jbpm.task.service.TaskServiceSession;
      import org.jbpm.task.service.mina.MinaTaskServer;
       
      import bitronix.tm.resource.jdbc.PoolingDataSource;
      
      public class JBPMTaskServer{
       public JBPMTaskServer() {
        // TODO Auto-generated constructor stub
       }
       /**
        * @param args
        */
       public static void main(String[] args) {
        // TODO Auto-generated method stub
        setupDataSource();
        //String dialect = properties.getProperty("persistence.persistenceunit.dialect", "org.hibernate.dialect.H2Dialect");
        Map<String, String> map = new HashMap<String, String>();
        map.put("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
              EntityManagerFactory emf = Persistence
          .createEntityManagerFactory("org.jbpm.persistence.jpa",map); 
         
      /*  Environment env = KnowledgeBaseFactory.newEnvironment();
        env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);*/
        TaskService taskService = new TaskService(emf, SystemEventListenerFactory.getSystemEventListener());
        TaskServiceSession taskSession = taskService.createSession();
              // now register new users and groups
              //taskSession.addUser(new User("mary"));
              //taskSession.addUser(new User("john"));
        
        MinaTaskServer server = new MinaTaskServer( taskService );
        Thread thread = new Thread( server );
        thread.start();
       }
       
       private static void setupDataSource(){
        PoolingDataSource ds = new PoolingDataSource();
        ds.setUniqueName("jdbc/jbpm-ds");
        ds.setClassName(com.mysql.jdbc.jdbc2.optional.MysqlXADataSource.class
          .getName());
        ds.setMaxPoolSize(3);
        ds.setAllowLocalTransactions(true);
        ds.getDriverProperties().put("user", "jbossjbpm");
        ds.getDriverProperties().put("password", "jbossjbpm");
        ds.getDriverProperties().put("URL", "jdbc:mysql://localhost:3306/jbpm");
        // ds.getDriverProperties().put("driverClassName",
        // "com.mysql.jdbc.Driver");
        ds.init();
       }
      }
      
      

      When i run these two classes,and threw the exception:

       

      1    15/07 09:30:33,936[main] ERROR workitem.wsht.GenericHTWorkItemHandler.executeWorkItem  - Mon Jul 15 09:30:33 CST 2013: Error when creating task on task server for work item id 7. Error reported by task server: Command AddTaskRequest faild due to Could not commit transaction. Please contact task server administrator.
      java.lang.RuntimeException: Command AddTaskRequest faild due to Could not commit transaction. Please contact task server administrator.
       at org.jbpm.task.service.TaskServerHandler.messageReceived(TaskServerHandler.java:729)
       at org.jbpm.task.service.mina.MinaTaskServerHandler.messageReceived(MinaTaskServerHandler.java:41)
       at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:716)
       at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
       at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
       at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:796)
       at org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolDecoderOutputImpl.flush(ProtocolCodecFilter.java:427)
       at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:245)
       at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
       at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
       at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:796)
       at org.apache.mina.filter.logging.LoggingFilter.messageReceived(LoggingFilter.java:177)
       at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
       at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
       at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:796)
       at org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:119)
       at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
       at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:426)
       at org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:692)
       at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:645)
       at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:634)
       at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:66)
       at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1078)
       at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
       at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
       at java.lang.Thread.run(Thread.java:662)
      Process started ...7