将jBPM 5.4集成到J2EE Web应用程序时出现persistence.xml错误

时间:2013-10-07 23:00:47

标签: maven jboss jbpm

我一直无法将" jBPM集成到网络应用中#34;在使用Eclipse(Kepler)时。作为测试,我只是尝试将jBPM Full Installer评估示例中的代码复制到Maven JavaEE6 Archetype生成的模板代码中。我已经注意到下面的步骤,以便轻松复制问题。

1)添加到JBoss standalone.xml:

<datasource jndi-name="java:jboss/jdbc/jbpm-ds" pool-name="jBPMDS" enabled="true" use-java-context="true">
    <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
    <driver>h2</driver>
    <security>
        <user-name>sa</user-name>
        <password>sa</password>
    </security>
</datasource>

2)JBoss Central&gt; Maven项目&gt;过滤&#34; javaee6&#34; (创建&#34; myservlet&#34;项目):     Archetype = jboss-javaee6-webapp     接受所有默认值

3)将src \ main \ resources \ META-INF \ persistence.xml设置为包含:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
   xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
        http://java.sun.com/xml/ns/persistence
        http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
   <persistence-unit name="primary">
      <!-- If you are running in a production environment, add a managed 
         data source, the example data source is just for proofs of concept! -->
      <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
      <properties>
         <!-- Properties for Hibernate -->
         <property name="hibernate.hbm2ddl.auto" value="create-drop" />
         <property name="hibernate.show_sql" value="false" />
      </properties>
   </persistence-unit>
</persistence>

4)通过从jBPM完整安装程序指向\ runtime文件夹来添加jBPM运行时。

5)选择jBPM Perspective,右键单击myservlet Project&gt;转换为jBPM项目。

6)向部署程序集添加Java构建路径条目&gt; jBPM图书馆。

7)在src \ main \ java \ com \ mycompany \ mywebapp \ controller中添加(任意选择)MemberRegistration.java(它是作为Project的一部分自动创建的)以下来自评估示例代码:< / p>

import java.util.HashMap;
import java.util.Map;
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.logger.KnowledgeRuntimeLogger;
import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import org.jbpm.process.workitem.wsht.HornetQHTWorkItemHandler;

8)在同一个模块中,在register()中添加以下来自评估示例代码:

 try {
    // load up the knowledge base
    KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
    kbuilder.add(ResourceFactory.newClassPathResource("Evaluation.bpmn"), ResourceType.BPMN2);
    KnowledgeBase kbase = kbuilder.newKnowledgeBase();
    StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
    HornetQHTWorkItemHandler humanTaskHandler = new HornetQHTWorkItemHandler(ksession);
    humanTaskHandler.setIpAddress("127.0.0.1");
    humanTaskHandler.setPort(5153);
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", humanTaskHandler);
    KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, "test", 1000);
    // start a new process instance
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("employee", "krisv");
    params.put("reason", "Yearly performance evaluation");
    ksession.startProcess("com.sample.evaluation", params);
    System.out.println("Process started ...");
    logger.close();
    } catch (Throwable t) {
    t.printStackTrace();
}

在与六个jBPM WAR一起部署时,我们收到此错误: ... 引起:java.lang.IllegalArgumentException:JBAS011470:未指定持久性unitName,应用程序部署中有2个持久性单元定义&#34; myservlet.war&#34;。将应用程序更改为只有一个持久性单元定义,或者为持久性单元的每个引用指定unitName。

我已经确认在部署的myservlet文件夹中只有一个persistence.xml文件(它位于jboss-as-7.1.1.Final \ standalone \ deployments \ myservlet.war \ WEB-INF \ classes \ META中-INF)。

有人可以解释这个错误的含义以及如何消除它吗?

1 个答案:

答案 0 :(得分:0)

我的猜测是,在所有配置.xml的某个地方,你犯了一些不太清楚的错误。我知道a **可能会带来多大的痛苦。我已经编写了一个关于如何使用JBoss AS here为JBPM配置持久性的小教程。我建议您一步一步地按照它重新配置您的项目。

希望它能解决你的问题!