0

我想在我的带有 MySQL 数据库的 GWT 项目上使用 JBPM,但是当我想创建EntityManagerFactory. 我究竟做错了什么?

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:51)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
at com.ayriksoft.desktopapp.server.TaskServiceManager.getInstance(TaskServiceManager.java:319)
at com.ayriksoft.desktopapp.server.JBPMServiceImpl.setup(JBPMServiceImpl.java:116)
at com.ayriksoft.desktopapp.server.JBPMServiceImpl.initializeJbpmSession(JBPMServiceImpl.java:51)
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 com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:561)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
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:619)

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)
... 35 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)
... 39 more

Caused by: bitronix.tm.utils.InitializationException: initialization failed, cannot safely start the transaction manager
at bitronix.tm.BitronixTransactionManager.<init>(BitronixTransactionManager.java:79)
at bitronix.tm.TransactionManagerServices.getTransactionManager(TransactionManagerServices.java:62)
... 44 more

Caused by: java.nio.channels.OverlappingFileLockException
at sun.nio.ch.FileChannelImpl$SharedFileLockTable.checkList(FileChannelImpl.java:1176)
at sun.nio.ch.FileChannelImpl$SharedFileLockTable.add(FileChannelImpl.java:1078)
at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:878)
at bitronix.tm.journal.TransactionLogAppender.<init>(TransactionLogAppender.java:70)
at bitronix.tm.journal.DiskJournal.open(DiskJournal.java:151)
at bitronix.tm.BitronixTransactionManager.<init>(BitronixTransactionManager.java:62)
... 45 more

我的persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
    <persistence 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_1_0.xsd" version="1.0">
    <!--     
    <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="org.jbpm.persistence.jpa" transaction-type="JTA">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <!-- non-jta-data-source>jdbc/jbpm-ds</non-jta-data-source-->

        <jta-data-source>java:comp/env/jdbc/jbpm-ds</jta-data-source>

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

        <class>org.drools.persistence.info.SessionInfo</class>
        <class>org.jbpm.persistence.processinstance.ProcessInstanceEventInfo</class>
        <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
        <class>org.drools.persistence.info.WorkItemInfo</class>

        <class>org.jbpm.process.audit.ProcessInstanceLog</class>
        <class>org.jbpm.process.audit.NodeInstanceLog</class>
        <class>org.jbpm.process.audit.VariableInstanceLog</class>       

        <class>org.jbpm.task.Task</class>
        <class>org.jbpm.task.Comment</class>
        <class>org.jbpm.task.Attachment</class>
        <class>org.jbpm.task.I18NText</class>
        <class>org.jbpm.task.SubTasksStrategy</class>
        <class>org.jbpm.task.Deadline</class>
        <class>org.jbpm.task.Escalation</class>
        <class>org.jbpm.task.Reassignment</class>
        <class>org.jbpm.task.Notification</class>
        <class>org.jbpm.task.BooleanExpression</class>
        <class>org.jbpm.task.User</class>
        <class>org.jbpm.task.PeopleAssignments</class>


        <properties>

             <!-- H2 dialect -->
               <!--   <property name="hibernate.dialect"              value="org.hibernate.dialect.H2Dialect"/>   -->

           <!-- Oracle dialect --> 
               <!--   <property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/> -->


             <!-- mysql dialect --> 

            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>

            <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
            <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/jbpm" />
            <property name="hibernate.connection.username" value="root"/>
            <property name="hibernate.connection.password" value="admin2000"/>     

              <property name="hibernate.hbm2ddl.auto" value="update" />
            <property name="hibernate.connection.autocommit" value="false"/>
            <property name="hibernate.max_fetch_depth" value="3"/>
            <property name="hibernate.show_sql" value="true" />
           <property name="hibernate.jndi.class" value="bitronix.tm.jndi.BitronixInitialContextFactory"/> 
      <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.BTMTransactionManagerLookup" />

        </properties>
    </persistence-unit>

    <persistence-unit name="org.jbpm.task">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>

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

        <class>org.jbpm.task.Attachment</class>
        <class>org.jbpm.task.Content</class>
        <class>org.jbpm.task.BooleanExpression</class>
        <class>org.jbpm.task.Comment</class>
        <class>org.jbpm.task.Deadline</class>
        <class>org.jbpm.task.Comment</class>
        <class>org.jbpm.task.Deadline</class>
        <class>org.jbpm.task.Delegation</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.EmailNotification</class>
        <class>org.jbpm.task.EmailNotificationHeader</class>
        <class>org.jbpm.task.PeopleAssignments</class>
        <class>org.jbpm.task.Reassignment</class>
        <class>org.jbpm.task.Status</class>
        <class>org.jbpm.task.Task</class>
        <class>org.jbpm.task.TaskData</class>
        <class>org.jbpm.task.SubTasksStrategy</class>
        <class>org.jbpm.task.OnParentAbortAllSubTasksEndStrategy</class>
        <class>org.jbpm.task.OnAllSubTasksEndParentEndStrategy</class>
        <class>org.jbpm.task.OnAllSubTasksEndParentEndStrategy</class>

        <class>org.jbpm.task.User</class>

        <class>org.drools.persistence.info.SessionInfo</class>
        <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
        <class>org.jbpm.persistence.processinstance.ProcessInstanceEventInfo</class>
        <class>org.drools.persistence.info.WorkItemInfo</class>


        <properties>
             <!-- sample H2 configuration  

            <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
            <property name="hibernate.connection.driver_class" value="org.h2.Driver"/>
            <property name="hibernate.connection.url" value="jdbc:h2:mem:droolsflow" />
            <property name="hibernate.connection.username" value="sa"/>
            <property name="hibernate.connection.password" value="sasa"/>
          -->

            <!-- Sample Oracle Configuration  

             <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
            <property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver"/>
            <property name="hibernate.connection.url" value="jdbc:oracle:thin:oracleserver:1521:db" />
            <property name="hibernate.connection.username" value="nagios"/>
            <property name="hibernate.connection.password" value="nagios"/>
            -->

             <!-- Sample mysql Configuration  -->

            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
            <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
            <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/task" />
            <property name="hibernate.connection.username" value="jbpm"/>
            <property name="hibernate.connection.password" value="jbpm"/>
             <property name="hibernate.hbm2ddl.auto" value="update" />


            <property name="hibernate.connection.autocommit" value="true" />
            <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.jndi.class" value="bitronix.tm.jndi.BitronixInitialContextFactory"/> 
      <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.BTMTransactionManagerLookup" />

        </properties>
    </persistence-unit>

</persistence>
4

1 回答 1

0

此异常意味着您已经有一个仍在运行的 bitronix 实例(它正在使用文件来获得锁定)。这可能是先前执行未正确关闭的结果。例如,如果我在 Eclipse 中多次运行相同的示例,并且它们都尝试实例化 bitronix 事务管理器。简单地在 Eclipse 中关闭其他正在运行的 Java 进程通常可以解决此问题。

于 2013-04-25T15:07:21.433 回答