0 Replies Latest reply on Dec 24, 2012 2:20 AM by VinothKumar Srinivasan

    Error while starting the process

    VinothKumar Srinivasan Newbie

      I am facing the following errors when i start the process

       

      Exception in thread "main" javax.persistence.PersistenceException: [PersistenceUnit: org.jbpm.persistence.jpa] Unable to build EntityManagerFactory

                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677)

                at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126)

                at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52)

                at org.jbpm.test.JBPMHelper.loadStatefulKnowledgeSession(JBPMHelper.java:147)

                at org.jbpm.test.JBPMHelper.newStatefulKnowledgeSession(JBPMHelper.java:136)

                at com.sample.ProcessMain.main(ProcessMain.java:20)

      Caused by: org.hibernate.HibernateException: Could not obtain BTM transaction manager instance

                at org.hibernate.transaction.BTMTransactionManagerLookup.getTransactionManager(BTMTransactionManagerLookup.java:50)

                at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:367)

                at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)

                at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)

                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)

                ... 5 more

      Caused by: java.lang.reflect.InvocationTargetException

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                at java.lang.reflect.Method.invoke(Method.java:597)

                at org.hibernate.transaction.BTMTransactionManagerLookup.getTransactionManager(BTMTransactionManagerLookup.java:47)

                ... 9 more

      Caused by: bitronix.tm.utils.InitializationException: cannot open disk journal

                at bitronix.tm.BitronixTransactionManager.<init>(BitronixTransactionManager.java:75)

                at bitronix.tm.TransactionManagerServices.getTransactionManager(TransactionManagerServices.java:62)

                ... 14 more

      Caused by: java.io.IOException: The process cannot access the file because another process has locked a portion of the file

                at java.io.RandomAccessFile.read(Native Method)

                at java.io.RandomAccessFile.readInt(RandomAccessFile.java:720)

                at bitronix.tm.journal.TransactionLogHeader.<init>(TransactionLogHeader.java:96)

                at bitronix.tm.journal.TransactionLogAppender.<init>(TransactionLogAppender.java:69)

                at bitronix.tm.journal.DiskJournal.open(DiskJournal.java:151)

                at bitronix.tm.BitronixTransactionManager.<init>(BitronixTransactionManager.java:62)

                ... 15 more

       

       

      The source code for this process is

      Processmain.java ---

       

       

      package com.sample;

       

       

      import org.drools.KnowledgeBase;

      import org.drools.builder.KnowledgeBuilder;

      import org.drools.builder.KnowledgeBuilderFactory;

      import org.drools.builder.ResourceType;

      import org.drools.io.ResourceFactory;

      import org.drools.runtime.StatefulKnowledgeSession;

      import org.jbpm.test.JBPMHelper;

       

       

      /**

      * This is a sample file to launch a process.

      */

      public class ProcessMain {

       

       

                public static final void main(String[] args) throws Exception {

                          startUp();

                          // load up the knowledge base

                          KnowledgeBase kbase = readKnowledgeBase();

                          StatefulKnowledgeSession ksession = JBPMHelper.newStatefulKnowledgeSession(kbase);

                          // start a new process instance

                          ksession.startProcess("com.sample.bpmn.hello");

                          System.out.println("Process started ...");

                }

       

       

                private static KnowledgeBase readKnowledgeBase() throws Exception {

                          KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

                          kbuilder.add(ResourceFactory.newClassPathResource("sample.bpmn"), ResourceType.BPMN2);

                          return kbuilder.newKnowledgeBase();

                }

       

                private static void startUp() {

                          JBPMHelper.startH2Server();

                          JBPMHelper.setupDataSource();

                          // please comment this line if you already have the task service running,

                          // for example when running the jbpm-installer

                          //JBPMHelper.startTaskService();

                }

       

      }

       

       

      ProcessTest.java -------

       

      package com.sample;

       

       

      import java.util.List;

       

       

      import org.drools.runtime.StatefulKnowledgeSession;

      import org.drools.runtime.process.ProcessInstance;

      import org.jbpm.task.TaskService;

      import org.jbpm.task.query.TaskSummary;

      import org.jbpm.test.JbpmJUnitTestCase;

      import org.junit.Test;

       

       

      /**

      * This is a sample file to launch a process.

      */

      public class ProcessTest extends JbpmJUnitTestCase {

       

       

                public ProcessTest() {

                          super(true);

                          setPersistence(true);

                }

       

       

                @Test

                public void testProcess() {

                          StatefulKnowledgeSession ksession = createKnowledgeSession("sample.bpmn");

                          TaskService taskService = getTaskService(ksession);

       

                          ProcessInstance processInstance = ksession.startProcess("com.sample.bpmn.hello");

       

       

                          assertProcessInstanceActive(processInstance.getId(), ksession);

                          assertNodeTriggered(processInstance.getId(), "Start", "Task 1");

       

                          // let john execute Task 1

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

                          TaskSummary task = list.get(0);

                          System.out.println("John is executing task " + task.getName());

                          taskService.start(task.getId(), "john");

                          taskService.complete(task.getId(), "john", null);

       

       

                          assertNodeTriggered(processInstance.getId(), "Task 2");

       

                          // let mary execute Task 2

                          list = taskService.getTasksAssignedAsPotentialOwner("mary", "en-UK");

                          task = list.get(0);

                          System.out.println("Mary is executing task " + task.getName());

                          taskService.start(task.getId(), "mary");

                          taskService.complete(task.getId(), "mary", null);

       

       

                          assertNodeTriggered(processInstance.getId(), "End");

                          assertProcessInstanceCompleted(processInstance.getId(), ksession);

       

                          ksession.dispose();

                }

       

      }