6 Replies Latest reply on May 15, 2007 5:32 PM by Ronald van Kuijk

    deploy from code problem

    s b Newbie

      Using a default Hibernate config, code to deploy a ProcessDefinition blows up on:

      jbpmContext.deployProcessDefinition(newProcessDefinition);
      


      15:59:15,828 [main] ERROR JDBCExceptionReporter : Table not found in statement [/* named HQL query GraphSession.findLatestProcessDefinitionQuery */ select top ? processdef0_.ID_ as ID1_4_, processdef0_.NAME_ as NAME2_4_, processdef0_.VERSION_ as VERSION3_4_, processdef0_.ISTERMINATIONIMPLICIT_ as ISTERMIN4_4_, processdef0_.STARTSTATE_ as STARTSTATE5_4_ from JBPM_PROCESSDEFINITION processdef0_ where processdef0_.NAME_=? order by processdef0_.VERSION_ desc]
      15:59:15,828 [main] ERROR GraphSession : org.hibernate.exception.SQLGrammarException: could not execute query
      org.hibernate.exception.SQLGrammarException: could not execute query
      


      I don't know enough about Hibernate yet to understand what is missing. The error seems to occur because the "deploy" method first checks for an existing Process Definition, but the tables haven't been created yet. I thought Hibernate under jBPM built the tables on the fly as needed -- no?

        • 2. Re: deploy from code problem
          Edward Staub Expert

          Simon,

          Some things are done in the starter kit that aren't in the engine when it's used separately. As I recall, the starter kit builds the schema on the fly in the in-memory HQSL database. I don't know where that's done, but it's not in the engine per se.

          The next thing you're likely to wonder is "Where's Cookie Monster?".

          See http://wiki.jboss.org/wiki/Wiki.jsp?page=UseHibernateToCreateJbpmDB

          -Ed Staub

          • 3. Re: deploy from code problem
            s b Newbie

            Thanks Ed for the reference, each little piece sheds some light (and more questions as well).

            For the heck of it, I blindly threw in a "JbpmConfiguration.createSchema()" statement in my code because, hey, it sounds promising...

            Guess what, my errors went away and my logging shows a lot of insert statements into what appear to be tables with names like JBPM_NODE, JBPM_EVENT, etc.

            Did I do good?

            Now, when I look at the (outdated?) jBPM 2.0 Deployment Doc, under Configuration it describes 4 configuration mechanisms and some properties. One of the properties is "jbpm.create.tables" and a possible value is "only-if-not-present". The description is

            If applicable, jbpm will create the the JBPM_ tables at startup if they are not present. The generated ddl starts with dropping the tables and contraints, then creates the tables, then adds the constraints.


            Q: If I had had this property in my "jbpm.cfg.xml" file, would the schema have been created automatically at first access?

            To continue the discussion:

            For my bare-bones test, my "jbpm.cfg.xml" file is empty, and the comment in it says
            The default configurations can be found in org/jbpm/default.jbpm.cfg.xml
            Those configurations can be overwritten by putting this file called
            jbpm.cfg.xml on the root of the classpath and put in the customized values.


            Q: Does that mean that jBPM first reads the default file, then reads the "jbpm.cfg.xml" file and overrides any repeated settings, or does it mean that if the "jbpm.cfg.xml" file is present, the default file is ignored?

            Also, when I look in that default file, there is a comment in it that says
            This configuration is used when there is no jbpm.cfg.xml file found in the root of the classpath. It is a very basic configuration without persistence and message services. Only the authorization service installed.
            You can parse and create processes, but when you try to use one of the unavailable services, you'll get an exception.


            Two issues: 1) The first sentence seems to imply that the default file is completely ignored when the "jbpm.cfg.xml" file is present -- implying you need to copy any settings from the default file to the "jbpm.cfg.xml" if you want to use them, and 2) the comment says "without persistence", but the file has entries for persistence service and hibernate (see below).

            Q: Is the comment correct that there is no persistence set up?

            <jbpm-configuration>
            
             <!--
             This configuration is used when there is no jbpm.cfg.xml file found in the
             root of the classpath. It is a very basic configuration without persistence
             and message services. Only the authorization service installed.
             You can parse and create processes, but when you try to use one of the
             unavailable services, you'll get an exception.
             -->
            
             <jbpm-context>
             <service name="persistence" factory="org.jbpm.persistence.db.DbPersistenceServiceFactory" />
             <service name="message" factory="org.jbpm.msg.db.DbMessageServiceFactory" />
             <service name="scheduler" factory="org.jbpm.scheduler.db.DbSchedulerServiceFactory" />
             <service name="logging" factory="org.jbpm.logging.db.DbLoggingServiceFactory" />
             <service name="authentication" factory="org.jbpm.security.authentication.DefaultAuthenticationServiceFactory" />
             </jbpm-context>
            
             <!-- configuration resource files pointing to default configuration files in jbpm-{version}.jar -->
             <string name="resource.hibernate.cfg.xml" value="hibernate.cfg.xml" />
             <string name="resource.business.calendar" value="org/jbpm/calendar/jbpm.business.calendar.properties" />
             <string name="resource.default.modules" value="org/jbpm/graph/def/jbpm.default.modules.properties" />
             <string name="resource.converter" value="org/jbpm/db/hibernate/jbpm.converter.properties" />
             <string name="resource.action.types" value="org/jbpm/graph/action/action.types.xml" />
             <string name="resource.node.types" value="org/jbpm/graph/node/node.types.xml" />
             <string name="resource.parsers" value="org/jbpm/jpdl/par/jbpm.parsers.xml" />
             <string name="resource.varmapping" value="org/jbpm/context/exe/jbpm.varmapping.xml" />
            
             <long name="jbpm.msg.wait.timout" value="5000" singleton="true" />
             <int name="jbpm.byte.block.size" value="1024" singleton="true" />
             <string name="mail.smtp.host" value="localhost" />
             <bean name="jbpm.task.instance.factory" class="org.jbpm.taskmgmt.impl.DefaultTaskInstanceFactoryImpl" singleton="true" />
             <bean name="jbpm.variable.resolver" class="org.jbpm.jpdl.el.impl.JbpmVariableResolver" singleton="true" />
             <bean name="jbpm.mail.address.resolver" class="org.jbpm.identity.mail.IdentityAddressResolver" singleton="true" />
            
            </jbpm-configuration>
            


            • 4. Re: deploy from code problem
              Edward Staub Expert

              Simon,
              Sorry, I'd have to research all of these to answer - no time.
              -Ed Staub

              • 5. Re: deploy from code problem
                s b Newbie

                Thanks, I'll keep researching it.

                • 6. Re: deploy from code problem
                  Ronald van Kuijk Master

                  FORGET THE JBPM 2.0 DEPLOYMENT DOC. IT IS THE "DEPLOYMENT DOC FOR JBPM 2.0", NOT THE "DEPLOYMENT DOC FOR JBPM 3.2" v2.0

                  SO YES IT IS OUTDATED.....