4 Replies Latest reply on Aug 16, 2006 7:08 PM by Ronald van Kuijk

    Jbpm classes deployed inside a hibernate HAR

    ulfreich Newbie

      Hi, I'm deploying my app in jBoss 4.0.3SP1 using a hibernate HAR to create the SessionFactory as an MBean. Now, in this part of the project, I need to use jBPM, which means I must include jBPM's persistent classes into the same SessionFactory. Any of you know how to include them into a HAR file, so my persistent classes and jBPM's get included in the same SessionFactory?

      Thanks!

        • 1. Re: Jbpm classes deployed inside a hibernate HAR
          Ronald van Kuijk Master

           

          I need to use jBPM, which means I must include jBPM's persistent classes into the same SessionFactory.


          I'm not a hibernate expert, but why? You can pass a sessionfactory to jBPM, so your app and jbpm share it.

          But it might be I missed something

          • 2. Re: Jbpm classes deployed inside a hibernate HAR
            ulfreich Newbie

            Thanks for your reply!

            So what you mean is, I must create the SessionFactory with my own persistent classes (without including jBPM's) and then simply pass that SessionFactory to jBPM as in JbpmContext.setSessionFactory(SessionFactory), and that's it?

            In the manual the only thing that says about including the user classes is:

            The easiest way to integrate your persistent classes with the jBPM persistent classes is by creating one central hibernate.cfg.xml. You can take the jBPM src/config.files/hibernate.cfg.xml as a starting point and add references to your own hibernate mapping files in there.


            Manually typing the classes sure could be the easiest way, but doesn't seem so practical at all given that, to create a SessionFactory manually, I can add the full jBPM jars to the configuration doing something like:

            Configuration configuration = new Configuration();
            configuration.addJar(myMappingsJar); // File object
            configuration.addJar(jbpmJarFile);
            configuration.addJar(jbpmIdentityJarFile);
            SessionFactory hibSessionFactory = configuration.buildSessionFactory();
            JbpmSessionFactory sessionFactory = new JbpmSessionFactory(configuration, hibSessionFactory);


            I'm looking for a way to do this using jBoss' Hibernate Archive (HAR). Thanks!

            • 3. Re: Jbpm classes deployed inside a hibernate HAR
              Uros Newbie

              Actually, you don't need har. Any sar will do.

              Basically, you need a sar with all the hbm.xml files of jbpm and following mbean:

               <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.jca:service=HibernateFactory,name=HibernateFactory">
              
               <depends>jboss.jca:service=RARDeployer</depends>
               <depends>jboss.jca:service=DataSourceBinding,name=HibernateDB2</depends>
              
               <attribute name="SessionFactoryName">java:/HibernateSessionFactory</attribute>
               <attribute name="DatasourceName">java:/HibernateDB2</attribute>
               <attribute name="Dialect">org.hibernate.dialect.DB2Dialect</attribute>
              
               <attribute name="ShowSqlEnabled">true</attribute>
               <attribute name="ScanForMappingsEnabled">true</attribute>
              
               </mbean>
              


              The mbean above will initialize hibernate session factory and load all hbm.xml files in the enclosing sar. Those mapping files should be for jbpm persistent objects and for yours own as well.

              That was first step. Second step is to configure jbpm to use configured hibernate session factory and to deploy it. You can do that with customizing jbpm.cfg.xml in your jbpm sar. More accurately, you must configure persistence service in the following manner:
              <service name="persistence">
               <factory>
               <bean class="org.jbpm.persistence.db.DbPersistenceServiceFactory">
               <field name="sessionFactoryJndiName">
               <string value="java:/HibernateSessionFactory" />
               </field>
               </bean>
               </factory>
               </service>


              And thats about it.

              • 4. Re: Jbpm classes deployed inside a hibernate HAR
                Ronald van Kuijk Master

                Hey, great tip jurglic. Maybe others new this as well, but I didn't. Would you care to make a wiki page for this?