6 Replies Latest reply on Feb 8, 2016 9:33 PM by calca

    jBPM6.3+Hibernate4+Tomcat7 Exception: Unable to build EntityManagerFactory

    samiswt

      Hi, guys, this problem drives me crazy. Please help me!

      My scenario is the following:

      I successfully configured and ran jbpm-console on my Tomcat 7.0.64 server, and then I downloaded a jbpm web example from here,

      The major difference between mine and original example is my database is PostgreSQL 9.3.

       

      When I create a new process, error message "Error:[PersistenceUnit: org.jbpm.persistence.jpa] Unable to build EntityManagerFactory" showed up, and I checked tomcat log, it was stuck here:

       

      INFO: HHH000205: Loaded properties from resource hibernate.properties: {hibernate.connection.password=****, c3p0.numHelperThreads=10, c3p0.maxIdleTime=60, c3p0.testConnectionOnCheckout=true, c3p0.maxStatements=100, hibernate.show_sql=true, hibernate.default_catalog=mybox, hibernate.jdbc.batch_size=50, hibernate.bytecode.use_reflection_optimizer=false, hibernate.jdbc.fetch_size=100, c3p0.maxPoolSize=30, c3p0.initialPoolSize=3, hibernate.hbm2ddl.auto=create, hibernate.default_schema=public, hibernate.connection.release_mode=after_transaction, hibernate.connection.username=postgres, c3p0.idleConnectionTestPeriod=900, hibernate.connection.driver_class=org.postgresql.Driver, c3p0.minPoolSize=2, c3p0.preferredTestQuery=select now(), c3p0.acquireIncrement=3, hibernate.dialect=org.hibernate.dialect.PostgreSQL9Dialect, hibernate.connection.url=jdbc:postgresql://192.168.1.80:5432/mybox}

      Feb 05, 2016 3:58:09 PM org.hibernate.cfg.Environment buildBytecodeProvider

      INFO: HHH000021: Bytecode provider name : javassist

      Feb 05, 2016 3:58:10 PM org.hibernate.cfg.Configuration addResource

      INFO: HHH000221: Reading mappings from resource: META-INF/JBPMorm.xml

      Feb 05, 2016 3:58:10 PM org.hibernate.cfg.Configuration addResource

      INFO: HHH000221: Reading mappings from resource: META-INF/Taskorm.xml

      Feb 05, 2016 3:58:10 PM org.hibernate.cfg.Configuration addResource

      INFO: HHH000221: Reading mappings from resource: META-INF/Executor-orm.xml

      Feb 05, 2016 3:58:10 PM org.hibernate.cfg.Configuration addResource

      INFO: HHH000221: Reading mappings from resource: META-INF/Servicesorm.xml

      Feb 05, 2016 3:58:10 PM org.hibernate.cfg.Configuration addResource

      INFO: HHH000221: Reading mappings from resource: META-INF/TaskAuditorm.xml

       

      My questions are:

      1. Is there any connection between jbpm-console and myJBPMExample(just named my example project)? Am I able to see tasks of myJBPMExample in jbpm-console?

      2. Datasource jdbc/jbpm-ds should be working fine, am I right? Because jbpm-console is working, but jbpm-console and myJBPMExample share the same datasource, is it OK?

      3. How am I able to tackle this problem? I can't find anything helpful from Google.

       

      Thank you very much!

      Happy weekend.

       

      P.S.: No stuff like Spring, Maven involved for now.

      Basic Software Environment:

      Ubuntu 14.04 64-bit

      Eclipse Mars1

      Tomcat 7.0.64

      Jbpm-6.3.0.Final

      Hibernate-4.2.21.Final

      JPA 2.0

       

      tomcat log, my persistence.xml, and a java file modified from the original attached below.

       

      Message was edited by: Tao Wang. sam.zip contained new version of these three files above.

        • 1. Re: jBPM6.3+Hibernate4+Tomcat7 Exception: Unable to build EntityManagerFactory
          calca

          Hey Tao Wang,

           

          In the servlet you attached, could you please add logging? I mean, here

           

                  } catch(Exception e){
                      out.println("Error:"+ e.getMessage().toString());
                  }

          Add something like:

                  } catch(Exception e){

          log.error(e);           

          out.println("Error:"+ e.getMessage().toString());

                  }

          And then see in the logs if you can see the cause of not being able to create the EM?


          Thanks!

           

          Demia

          • 2. Re: jBPM6.3+Hibernate4+Tomcat7 Exception: Unable to build EntityManagerFactory
            samiswt

            Thank you very much Demian,

             

            I restarted my laptop, and now error message changed to what was shown on the attached catalina.out. I've noticed that log said there is no resource registered with uniqueName 'jdbc/jbpm-ds', but the truth is at the top of few lines of log, there is a line INFO said:

             

            INFO: recovery committed 0 dangling transaction(s) and rolled back 0 aborted transaction(s) on 1 resource(s) [jdbc/jbpm-ds] (restricted to serverId 'tomcat-btm-node0')

             

            There is a jbpm-console on my Tomcat Server, and myJBPMExample project named 'jbpm' on it as well. They share the same data source, is it valid?

            I also attached my btm configuration files, please take a look to see if there's something wrong in it.

             

            Thank you again,

             

            Tao

            • 3. Re: jBPM6.3+Hibernate4+Tomcat7 Exception: Unable to build EntityManagerFactory
              calca

              I think you have a problem in your btm config or something. I can see this

               

              Feb 08, 2016 10:28:58 AM org.apache.catalina.core.NamingContextListener addEnvironment

              SEVERE: Environment entry jdbc/jbpm-ds has an invalid type

               

              Before it even starts deploying anything. Did you add the postgres driver into the tomcat lib?

              • 4. Re: jBPM6.3+Hibernate4+Tomcat7 Exception: Unable to build EntityManagerFactory
                calca

                And also, did you add this:

                    <Resource name="jdbc/jbpm-ds" auth="Container" type="javax.sql.DataSource"

                               maxActive="15" maxIdle="2" maxWait="10000"

                logAbandoned="true"

                               username="sa" password=""

                driverClassName="org.h2.jdbcx.JdbcDataSource"

                               url="jdbc:h2:tcp://localhost/~/test"/>

                to the context.xml tomcat file?

                 

                And this:

                to the server.xml file?

                <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

                  <Listener className="bitronix.tm.integration.tomcat55.BTMLifecycleListener" />

                • 5. Re: jBPM6.3+Hibernate4+Tomcat7 Exception: Unable to build EntityManagerFactory
                  samiswt

                  Thank you, Demian,

                  These lines have been included in my {CATALINA_HOME}/conf/*.xml files. I'm glad to tell you that I made a big progress today. I referred to here,and changed my server.xml, as shown below. Take a look at the line with Bold font, original type="javax.sql.DataSource", that's why you see SEVERE in catalina.out.

                   

                  I updated the log file now, please take a look and give me some suggestions, OK?

                   

                  server.xml:

                  <GlobalNamingResources>

                      <!-- Editable user database that can also be used by

                           UserDatabaseRealm to authenticate users

                      -->

                      <Resource name="UserDatabase" auth="Container"

                                type="org.apache.catalina.UserDatabase"

                                description="User database that can be updated and saved"

                                factory="org.apache.catalina.users.MemoryUserDatabaseFactory"

                                pathname="conf/tomcat-users.xml" />

                      <Environment name="jdbc/jbpm-ds" override="false" type="java.lang.String" value="192.168.1.80:8080"/>

                          <ResourceLink name="jdbc/jbpm-ds" uniqueName="jdbc/jbpm-ds" auth="Container" type="javax.sql.DataSource"/>

                   

                   

                          <Resource name="jta/UserTransaction" auth="Container" type="javax.transaction.UserTransaction" 

                                  factory="bitronix.tm.BitronixUserTransactionObjectFactory" />

                          <Resource name="TransactionManager" auth="Container" type="javax.transaction.TransactionManager"

                                  factory="bitronix.tm.BitronixTransactionManagerObjectFactory" />

                          <Resource name="TransactionSynchronizationRegistry" auth="Container" type="javax.transaction.TransactionSynchronizationRegistry"

                                  factory="bitronix.tm.BitronixTransactionSynchronizationRegistryObjectFactory" />

                    </GlobalNamingResources>

                  • 6. Re: jBPM6.3+Hibernate4+Tomcat7 Exception: Unable to build EntityManagerFactory
                    calca

                    Hey,

                     

                    to be honest, it seems something is not right from the beggining.

                    I would recommend to clone this example:

                    GitHub - mswiderski/spring-jbpm-app: jBPM spring application that shows how to build execution server using jBPM 6 and s…

                    and see how to deploy it in tomcat (instructions in the README)

                    spring-jbpm-app/README.md at master · mswiderski/spring-jbpm-app · GitHub

                    I have followed this and was able to run it with tomcat.