[jboss-user] [jBPM] - Instantiating workflow from EJB deployed as part of .ear : javax.persistence.PersistenceException: [PersistenceUnit: org.jbpm.persistence.jpa.secureall] Unable to build EntityManagerFactory

Chaitanya Desai do-not-reply at jboss.com
Thu Aug 4 17:24:31 EDT 2011


Chaitanya Desai [http://community.jboss.org/people/chaitanya1987] created the discussion

"Instantiating workflow from EJB deployed as part of .ear : javax.persistence.PersistenceException: [PersistenceUnit: org.jbpm.persistence.jpa.secureall] Unable to build EntityManagerFactory"

To view the discussion, visit: http://community.jboss.org/message/619510#619510

--------------------------------------------------------------
I am trying to instantiate a process instance based on a process definition for JBPM 5.1 from a EJB deployed in the JBoss application server. The EJB is part of a .ear file , using the MySQL database. 


I have defined a persistence unit in persistence.xml within the META-INF folder and also placed the corresponding JBPMorm.xml in the META-INF folder. The datasaource is deployed in the deploy folder of JBOss 5.1

persistence .xml 

<?xml version="1.0" encoding="UTF-8"?> 
<persistence xmlns=" http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence"
     xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation=" http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence  http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
      version="1.0">   

             <persistence-unit name="SecureALLPU" transaction-type="JTA">
              <jta-data-source>java:/SecureAll</jta-data-source>
              <properties>
                              <property name="hibernate.format_sql" value="true"/>
                              <property name="dialect" value="org.hibernate.dialect.OracleDialect"/>
                              <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
                    </properties>   
    </persistence-unit>

  <persistence-unit name="org.jbpm.persistence.jpa.secureall" transaction-type="JTA">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>    
    <jta-data-source>java:jdbc/SecureAlljbpmDatasource</jta-data-source>           
    <mapping-file>META-INF/JBPMorm.xml</mapping-file>    
    <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
    <class>org.drools.persistence.info.SessionInfo</class>
    <class>org.drools.persistence.info.WorkItemInfo</class>
    <properties>    
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>         
      <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.JBossTransactionManagerLookup" /> -->
      <property name="hibernate.transaction.manager_lookup_class" 
                value="org.hibernate.transaction.BTMTransactionManagerLookup"/>
    </properties>        
  </persistence-unit>

   </persistence>

JBPMORM.XML

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns=" http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm"
               xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation=" http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
               version="1.0">  
      <named-query name="ProcessInstancesWaitingForEvent">
          <query>
select 
    processInstanceInfo.processInstanceId
from 
    ProcessInstanceInfo processInstanceInfo
where
    :type in elements(processInstanceInfo.eventTypes)
          </query>
      </named-query>
</entity-mappings>

Datasource:

<?xml version="1.0" encoding="UTF-8"?>
<datasources>
          <local-tx-datasource>
    <jndi-name>jdbc/SecureAlljbpmDatasource</jndi-name>
    <connection-url>jdbc:mysql://localhost:3306/JBPM?useUnicode=true&amp;characterEncoding=UTF-8</connection-url>
    <!--<connection-url>jdbc:h2:mem:mydb</connection-url>-->
    <driver-class>com.mysql.jdbc.Driver</driver-class>
    <user-name>root</user-name>
    <password></password>
          <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
           <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
  </local-tx-datasource> 

</datasources>


When i deploy my .ear file
App Server is able to recognise the datasource, persistence unit for jbpm datasource from persistence.xml and corresponding jbpmorm.xml.

However I get the exception : javax.persistence.PersistenceException: [PersistenceUnit: org.jbpm.persistence.jpa.secureall] Unable to build EntityManagerFactory

On looking into the details for it I understand that EntityManagerFactory needs to be loaded by the name: org.jbpm.persistence.jpa.secureall
Something like:

| 
 | 
 | EntityManagerFactory emf = |
| 
 | 
 |     Persistence.createEntityManagerFactory( "org.jbpm.persistence.jpa.secureall" ); |

| 
 | 
 | Environment env = KnowledgeBaseFactory.newEnvironment(); |

| 
 | 
 | env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf ); |
| 
 | 
 | env.set(EnvironmentName.GLOBALS, new MapGlobalResolver());  |


However I am not sure how do i define EntityManagerFactory by that name such that it gets loaded by that name during deployment rather than during run time.
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/619510#619510]

Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110804/721c5dee/attachment-0001.html 


More information about the jboss-user mailing list