0

我开始使用 Jbpm5 几天并直接在以下问题中运行:

我找到了下面的示例,可以将其作为 JUnit 测试运行。已成功创建包含用户和组的所有表。之后,我创建了一个 Spring Service 并将该片段发布到 @PostConstruct 方法中。但是现在总是发生以下异常。我不得不说我的 SpringContext 使用 org.springframework.orm.hibernate4.HibernateTransactionManager 作为 PlatformTxMngr。但这应该不是问题,如果我以编程方式准备所有资源,对吧?我也在 JBPM 社区中发布了这个:https ://community.jboss.org/thread/232060

非常感谢您的帮助!!!

例外:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'workflowServiceWrapper': Invocation of init method failed; nested exception is java.lang.NullPointerException

    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:135)

    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:394)

    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1448)

    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)

    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)

    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)

    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)

    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)

    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)

    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607)

    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:925)

    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:472)

    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:388)

    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:293)

    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)

    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4797)

    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5291)

    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)

    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)

    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)

    at java.util.concurrent.FutureTask.run(FutureTask.java:166)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)

    at java.lang.Thread.run(Thread.java:722)

引起:java.lang.NullPointerException

    at org.drools.persistence.jta.JtaTransactionManager.getStatus(JtaTransactionManager.java:205)

    at org.jbpm.task.service.persistence.TaskJTATransactionManager.getStatus(TaskJTATransactionManager.java:72)

    at org.jbpm.task.service.persistence.TaskJTATransactionManager.begin(TaskJTATransactionManager.java:45)

    at org.jbpm.task.service.persistence.TaskPersistenceManager.beginTransaction(TaskPersistenceManager.java:100)

    at org.jbpm.task.service.persistence.TaskPersistenceManager.getUnescalatedDeadlines(TaskPersistenceManager.java:177)

    at org.jbpm.task.service.TaskServiceSession.scheduleUnescalatedDeadlines(TaskServiceSession.java:242)

    at org.jbpm.task.service.TaskService.initialize(TaskService.java:134)

    at org.jbpm.task.service.TaskService.initialize(TaskService.java:119)

    at org.jbpm.task.service.TaskService.<init>(TaskService.java:97)

我的测试:

 @Test  
      public void startDemo() {  

        Properties driverProperties = new Properties();  
        driverProperties.put("driverClassName", "driverName");  
        driverProperties.put("user", "username");  
        driverProperties.put("password", "password");  
        driverProperties.put("url", "url");      

        //JNDI Support to make DataSources for TransactionManager available   
        System.getProperties().put("java.naming.factory.initial", "bitronix.tm.jndi.BitronixInitialContextFactory");  

        //JPA/JTA/JNDI compatible DataSource   
        PoolingDataSource ds = new PoolingDataSource();  
        ds.setUniqueName("jdbc/BitronixJTADataSource"); // => referenced by persistence.xml  
        ds.setClassName("bitronix.tm.resource.jdbc.lrc.LrcXADataSource");  
        ds.setMaxPoolSize(3);  
        ds.setAllowLocalTransactions(true);  
        ds.setDriverProperties(driverProperties);  
        ds.init();  

        EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.task");  
        TaskService taskService = new TaskService(emf, SystemEventListenerFactory.getSystemEventListener());  
        TaskServiceSession taskSession = taskService.createSession();  

        // Add demo users  
        Map vars = new HashMap();  
        InputStream usersin = DemoTaskService.class.getResourceAsStream("LoadUsers.mvel");  
        if(usersin != null) {  
          Reader reader = new InputStreamReader(usersin);  
          @SuppressWarnings("unchecked")  
          Map<String, User> users = (Map<String, User>) TaskService.eval(reader, vars);  
          for(User user : users.values()) {  
            taskSession.addUser(user);  
          }  
        }  
        //add demo groups  
        InputStream groupsin = DemoTaskService.class.getResourceAsStream("LoadGroups.mvel");  
        if(groupsin != null) {  
          Reader reader = new InputStreamReader(groupsin);  
          @SuppressWarnings("unchecked")  
          Map<String, Group> groups = (Map<String, Group>) TaskService.eval(reader, vars);  
          for(Group group : groups.values()) {  
            taskSession.addGroup(group);  
          }  
        }  

        // start mina server  
        MinaTaskServer server = new MinaTaskServer(taskService, 5153);  
        Thread thread = new Thread(server);  
        thread.start();  
        taskSession.dispose();  
        System.out.println("Task service started correctly!");  
        System.out.println("Task service running ...");  

        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();  
        kbuilder.add(ResourceFactory.newClassPathResource("sample.bpmn"), ResourceType.BPMN2);  
        KnowledgeBase kbase = kbuilder.newKnowledgeBase();  
        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();  
        MinaHTWorkItemHandler humanTaskHandler = new MinaHTWorkItemHandler(ksession);  
        humanTaskHandler.setIpAddress("127.0.0.1");  
        humanTaskHandler.setPort(5153);  
        ksession.getWorkItemManager().registerWorkItemHandler("Human Task", humanTaskHandler);  
        Map<String, Object> params = new HashMap<String, Object>();  

        ksession.startProcess("com.sample.bpmn.hello", params);  
        ksession.dispose();  

        taskSession = taskService.createSession();  
        List<TaskSummary> list = taskSession.getTasksOwned("krisv", "en-UK");  

        System.out.println("Taskinstance: " + list.size());  
        taskSession.dispose();  

      }  

持久性.xml

<persistence>  
  </persistence-unit>  
  <persistence-unit name="org.jbpm.task">  
    <provider>org.hibernate.ejb.HibernatePersistence</provider>  
    <jta-data-source>jdbc/BitronixJTADataSource</jta-data-source>  

    <mapping-file>META-INF/Taskorm-JPA2.xml</mapping-file>  

    <class>org.jbpm.task.Attachment</class>  
    <class>org.jbpm.task.BooleanExpression</class>  
    <class>org.jbpm.task.Comment</class>  
    <class>org.jbpm.task.Content</class>  
    <class>org.jbpm.task.Deadline</class>  
    <class>org.jbpm.task.Delegation</class>  
    <class>org.jbpm.task.EmailNotification</class>  
    <class>org.jbpm.task.EmailNotificationHeader</class>  
    <class>org.jbpm.task.Escalation</class>  
    <class>org.jbpm.task.Group</class>  
    <class>org.jbpm.task.I18NText</class>  
    <class>org.jbpm.task.Notification</class>  
    <class>org.jbpm.task.OnAllSubTasksEndParentEndStrategy</class>  
    <class>org.jbpm.task.OnParentAbortAllSubTasksEndStrategy</class>  
    <class>org.jbpm.task.PeopleAssignments</class>  
    <class>org.jbpm.task.Reassignment</class>  
    <class>org.jbpm.task.Status</class>  
    <class>org.jbpm.task.SubTasksStrategy</class>  
    <class>org.jbpm.task.Task</class>  
    <class>org.jbpm.task.TaskData</class>  
    <class>org.jbpm.task.User</class>  

    <properties>  
      <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect" />  
      <property name="hibernate.max_fetch_depth" value="3" />  
      <property name="hibernate.hbm2ddl.auto" value="create" />  
      <property name="hibernate.show_sql" value="false" />  
      <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.BTMTransactionManagerLookup" />  
      <!-- BZ 841786: AS7/EAP 6/Hib 4 uses new (sequence) generators which seem to cause problems -->  
      <property name="hibernate.id.new_generator_mappings" value="false" />  

    </properties>  
  </persistence-unit>  
</persistence>  
4

1 回答 1

0

我自己找到了一个解决方案并将其发布在https://community.jboss.org/thread/232060

于 2013-09-03T08:57:58.653 回答