2 Replies Latest reply on Jan 2, 2008 12:01 PM by yairfr

    Making JBPM and Hibernate Work Together

    yairfr

      hi ,

      i am trying to make JBPM use Hibernate session .
      the JBPM code worked with before .
      the error i get is :

      16:15:07,937 ERROR [STDERR] org.hibernate.MappingException: Named query not known: GraphSession.findLatestProcessDefinitionQuery
      
       at org.hibernate.impl.AbstractSessionImpl.getNamedQuery(AbstractSessionImpl.java:70)
      
       at org.hibernate.impl.SessionImpl.getNamedQuery(SessionImpl.java:1253)
      
       at org.jbpm.db.GraphSession.findLatestProcessDefinition(GraphSession.java:150)
      
       at org.jbpm.db.GraphSession.deployProcessDefinition(GraphSession.java:67)
      
       at org.jbpm.JbpmContext.deployProcessDefinition(JbpmContext.java:173)
      
       at com.mts.WF.Engine.RequestsHandler.deployProcess(RequestsHandler.java:250)
      
       at com.mts.WF.Engine.RequestsHandler.handleRequest(RequestsHandler.java:88)
      
       at com.mts.WF.Engine.WorkerThread.run(WorkerThread.java:30)
      
      


      the code :

      JbpmConfiguration conf = JbpmConfiguration.getInstance();
       context = conf.createJbpmContext();
       //context.setSession(HibernateSessionFactory.getSessionFactory().getCurrentSession());
      
      
       String fileName = FileHandler.assembleName(req.processProperties.Path+req.processProperties.Name, "processdefinition.xml");
       FileInputStream fis;
       fis = new FileInputStream(fileName);
      
       ProcessDefinition pd = ProcessDefinition.parseXmlInputStream(fis);
       if (pd == null) {
       logger.error("Unable to read definition: " + fileName);
       //context.close();
       return;
       }
      
       context.deployProcessDefinition(pd);
      


      the error happens on the last line .
      i have tried to make JBPM work with the already opened Hibernate session
      by :

      context = conf.createJbpmContext();
      context.setSession(HibernateSessionFactory.getSessionFactory().getCurrentSession());

      but is has crash because no CurrentSession is configured in the
      hibernate.cfg.xml
      i have tried entering this property with thread, JTA , MANAGED
      values - with no success .
      how can i resolve it ?

      Thanks,
      Yair

        • 1. Re: Making JBPM and Hibernate Work Together
          kukeltje

          if it worked before, what changed?

          • 2. Re: Making JBPM and Hibernate Work Together
            yairfr

            i found part of the problem :
            JBPM XML files were not mapped in the hibernate.cfg.xml file .
            when i mapped them all i got this error :

            
            2008-01-02 17:55:14,468 INFO [STDOUT] 17:55:14,452 ERROR [[/Total-e]] StandardWrapper.Throwable
            java.lang.NoClassDefFoundError: org/hibernate/hql/antlr/HqlBaseParser
             at java.lang.ClassLoader.defineClass1(Native Method)
             at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
             at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
             at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1812)
             at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:866)
             at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1319)
             at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
             at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
             at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:241)
             at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:156)
             at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:110)
             at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
             at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
             at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
             at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:397)
             at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:348)
             at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1213)
            


            i read that somehow it is connected to the

            line in the config file , but i don't see why, since it seems it reads from this mapping :
            2008-01-02 17:55:02,499 DEBUG [org.hibernate.cfg.Configuration] null<-org.dom4j.tree.DefaultAttribute@99146a [Attribute: name resource value "org/jbpm/db/hibernate.queries.hbm.xml"]
            2008-01-02 17:55:02,499 INFO [org.hibernate.cfg.Configuration] Reading mappings from resource: org/jbpm/db/hibernate.queries.hbm.xml
            2008-01-02 17:55:02,499 DEBUG [org.hibernate.util.DTDEntityResolver] trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd]
            2008-01-02 17:55:02,499 DEBUG [org.hibernate.util.DTDEntityResolver] recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
            2008-01-02 17:55:02,499 DEBUG [org.hibernate.util.DTDEntityResolver] located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath
            2008-01-02 17:55:02,531 DEBUG [org.hibernate.cfg.Mappings] Added string_max with class org.jbpm.db.hibernate.StringMax
            2008-01-02 17:55:02,531 DEBUG [org.hibernate.cfg.HbmBinder] Named query: GraphSession.findLatestProcessDefinitionQuery ->
            
             select pd
             from org.jbpm.graph.def.ProcessDefinition as pd
             where pd.name = :name
             order by pd.version desc
            
            
            2008-01-02 17:55:02,531 DEBUG [org.hibernate.cfg.HbmBinder] Named query: GraphSession.findProcessDefinitionByNameAndVersion ->
            
             select pd
             from org.jbpm.graph.def.ProcessDefinition as pd
             where pd.name = :name
             and pd.version = :version
            
            
            2008-01-02 17:55:02,531 DEBUG [org.hibernate.cfg.HbmBinder] Named query:
            

            so what is the problem ?