6 Replies Latest reply on Jul 9, 2009 8:59 AM by Ronald van Kuijk

    Hibernate error while deploying process in a web application

    Viki . Newbie

      i am trying to implement jBPM in a J2EE Web application. I am doing three things.
      1) Deploy a process
      2) Start an instance.
      3) Show a list of available instances.

      My Environment:
      jBPM : 3.2.X
      jBoss : 4.2.X
      Database: MySQL

      Below is the piece of code embedded in a method inside a DAO class. This is invoked from the servlet when the user hits the Deploy button in the jsp page.

      public String redeployProcess(String processName) {
       System.out.println("->public String redeployProcess(String processName)");
       System.out.println("----->Creating jBPM Configuration....");
       JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
       try {
       System.out.println("----->Parsing process definition....");
       ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource(processName);
       System.out.println("----->Deploying Process definition....");
       jbpmContext.deployProcessDefinition(processDefinition);
       System.out.println("----->Deploy Successful....");
       return "Process " + processDefinition.getName() + " redeployed.";
       } finally {
       System.out.println("----->Closing jBPM Context....");
       jbpmContext.close();
       }
       }
      


      And this is the exception i got....
      ->public String redeployProcess(String processName)
      13:45:38,882 INFO [STDOUT] ----->Creating jBPM Configuration....
      13:45:38,882 INFO [STDOUT] ----->Parsing process definition....
      13:45:38,928 INFO [STDOUT] ----->Deploying Process definition....
      13:45:38,928 INFO [STDOUT] ----->Closing jBPM Context....
      13:45:38,928 ERROR [[JBPMServlet]] Servlet.service() for servlet JBPMServlet threw exception
      org.hibernate.HibernateException: No CurrentSessionContext configured!
       at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:542)
       at org.jbpm.persistence.db.DbPersistenceService.getSession(DbPersistenceService.java:90)
       at org.jbpm.persistence.db.DbPersistenceService.getGraphSession(DbPersistenceService.java:330)
       at org.jbpm.JbpmContext.getGraphSession(JbpmContext.java:636)
       at org.jbpm.JbpmContext.deployProcessDefinition(JbpmContext.java:170)
       at com.sample.dao.JBPMDao.redeployProcess(JBPMDao.java:23)
       at com.sample.JBPMServlet.doGet(JBPMServlet.java:34)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
       at java.lang.Thread.run(Thread.java:595)
      


      Works well in Tomcat !

      I ran this application in Tomcat and it worked perfectly alright. Initially i faced some problems but with the help of existing posts, i made it work well.....

      Why not in jBoss ?

      If it works well in Tomcat, then it must work in jBoss too. And also i dont know Hibernate. I can see that it is trying to get a Session through SessionFactoryImpl.getCurrentSession() and the effort fails.
      But how is it able to get one in Tomcat ?

      Any help here would be deeply appreciated. if I am missing out to provide any info, please do ask me.


        • 1. Re: Hibernate error while deploying process in a web applica
          Ronald van Kuijk Master

          maybe due to a different hibernate config or the way hibernate deployed? Turn on hibernate debugging to see more

          • 2. Re: Hibernate error while deploying process in a web applica
            Viki . Newbie

            Hi, i turned on the DEBUG mode. i was surprised to see 8000 lines being traced between these two lines.

            13:45:38,928 INFO [STDOUT] ----->Deploying Process definition....
            13:45:38,928 INFO [STDOUT] ----->Closing jBPM Context....
            


            I gave a try but it ain't worth identifying the root cause.
            And also I cant paste it here or even attach it seperately :(

            What can i do now ? Thanks for helping me.



            • 3. Re: Hibernate error while deploying process in a web applica
              Ronald van Kuijk Master

              8000 lines? Of just jBPM and hibernate debug? If so then look at the stacktrace and put less packages in debug mode.

              • 4. Re: Hibernate error while deploying process in a web applica
                Viki . Newbie

                yeah it did showed up 8000 lines !
                I don't know whether it is right or wrong but i added this property to my hibernate.cfg.xml file & got rid of the above error.

                <property name="hibernate.current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</property>


                But again, i faced another problem. Removed few repeated log statements add embedded it below.

                16:21:45,481 INFO [STDOUT] ->public String redeployProcess(String processName)
                16:21:45,481 INFO [STDOUT] ----->Creating jBPM Configuration....
                16:21:45,544 INFO [STDOUT] ----->Parsing process definition....
                16:21:46,122 INFO [STDOUT] ----->Deploying Process definition....
                16:21:46,200 INFO [Environment] Hibernate 3.2.6
                16:21:46,200 INFO [Environment] hibernate.properties not found
                16:21:46,216 INFO [Environment] Bytecode provider name : cglib
                16:21:46,216 INFO [Environment] using JDK 1.4 java.sql.Timestamp handling
                16:21:46,325 INFO [Configuration] configuring from resource: hibernate.cfg.xml
                16:21:46,325 INFO [Configuration] Configuration resource: hibernate.cfg.xml
                16:21:46,341 INFO [Configuration] Reading mappings from resource : hibernate.extra.hbm.xml
                16:21:46,419 INFO [Configuration] Reading mappings from resource : hibernate.identity.hbm.xml
                16:21:46,434 INFO [HbmBinder] Mapping class: org.jbpm.identity.User -> JBPM_ID_USER
                .
                .
                .
                16:21:47,216 INFO [Configuration] Reading mappings from resource : org/jbpm/taskmgmt/log/SwimlaneAssignLog.hbm.xml
                16:21:47,216 INFO [HbmBinder] Mapping subclass: org.jbpm.taskmgmt.log.SwimlaneAssignLog -> JBPM_LOG
                16:21:47,216 INFO [Configuration] Configured SessionFactory: null
                16:21:47,216 INFO [HbmBinder] Mapping subclass: org.jbpm.graph.action.MailAction -> JBPM_ACTION
                16:21:47,216 INFO [HbmBinder] Mapping subclass: org.jbpm.context.def.ContextDefinition -> JBPM_MODULEDEFINITION
                16:21:47,216 INFO [HbmBinder] Mapping collection: org.jbpm.identity.User.memberships -> JBPM_ID_MEMBERSHIP
                16:21:47,216 INFO [HbmBinder] Mapping collection: org.jbpm.identity.Group.children -> JBPM_ID_GROUP
                .
                .
                .
                16:21:47,231 INFO [HbmBinder] Mapping collection: org.jbpm.taskmgmt.exe.TaskInstance.variableInstances -> JBPM_VARIABLEINSTANCE
                16:21:47,231 INFO [HbmBinder] Mapping collection: org.jbpm.taskmgmt.exe.TaskInstance.comments -> JBPM_COMMENT
                16:21:47,231 INFO [HbmBinder] Mapping collection: org.jbpm.taskmgmt.exe.SwimlaneInstance.pooledActors -> JBPM_POOLEDACTOR
                16:21:47,231 INFO [HbmBinder] Mapping collection: org.jbpm.logging.log.CompositeLog.children -> JBPM_LOG
                16:21:47,309 INFO [NamingHelper] JNDI InitialContext properties:{}
                16:21:47,309 INFO [DatasourceConnectionProvider] Using datasource: java:JbpmDS
                16:21:47,325 INFO [SettingsFactory] RDBMS: MySQL, version: 5.1.30-community
                16:21:47,325 INFO [SettingsFactory] JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.0.4 ( $Date: 2006-10-19 17:47:48 +0200 (Thu, 19 Oct 2006) $, $Revision: 5908 $ )
                16:21:47,341 INFO [Dialect] Using dialect: org.hibernate.dialect.MySQLDialect
                16:21:47,341 INFO [TransactionFactoryFactory] Transaction strategy: org.hibernate.transaction.JTATransactionFactory
                16:21:47,356 INFO [NamingHelper] JNDI InitialContext properties:{}
                16:21:47,356 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
                16:21:47,356 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
                16:21:47,356 INFO [SettingsFactory] Automatic flush during beforeCompletion(): disabled
                16:21:47,356 INFO [SettingsFactory] Automatic session close at end of transaction: disabled
                16:21:47,356 INFO [SettingsFactory] JDBC batch size: 15
                16:21:47,356 INFO [SettingsFactory] JDBC batch updates for versioned data: disabled
                16:21:47,356 INFO [SettingsFactory] Scrollable result sets: enabled
                16:21:47,356 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): enabled
                16:21:47,356 INFO [SettingsFactory] Connection release mode: auto
                16:21:47,356 INFO [SettingsFactory] Maximum outer join fetch depth: 2
                16:21:47,356 INFO [SettingsFactory] Default batch fetch size: 1
                16:21:47,356 INFO [SettingsFactory] Generate SQL with comments: enabled
                16:21:47,356 INFO [SettingsFactory] Order SQL updates by primary key: disabled
                16:21:47,356 INFO [SettingsFactory] Order SQL inserts for batching: disabled
                16:21:47,356 INFO [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
                16:21:47,372 INFO [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
                16:21:47,372 INFO [SettingsFactory] Query language substitutions: {}
                16:21:47,372 INFO [SettingsFactory] JPA-QL strict compliance: disabled
                16:21:47,372 INFO [SettingsFactory] Second-level cache: enabled
                16:21:47,372 INFO [SettingsFactory] Query cache: disabled
                16:21:47,372 INFO [SettingsFactory] Cache provider: org.hibernate.cache.HashtableCacheProvider
                16:21:47,372 INFO [SettingsFactory] Optimize cache for minimal puts: disabled
                16:21:47,372 INFO [SettingsFactory] Structured second-level cache entries: disabled
                16:21:47,372 INFO [SettingsFactory] Statistics: disabled
                16:21:47,372 INFO [SettingsFactory] Deleted entity synthetic identifier rollback: disabled
                16:21:47,372 INFO [SettingsFactory] Default entity-mode: pojo
                16:21:47,372 INFO [SettingsFactory] Named query checking : enabled
                16:21:47,434 INFO [SessionFactoryImpl] building session factory
                16:21:48,325 INFO [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured
                16:21:48,341 INFO [NamingHelper] JNDI InitialContext properties:{}
                16:21:49,388 ERROR [GraphSession] org.hibernate.HibernateException: getNamedQuery is not valid without active transaction
                16:21:49,388 INFO [STDOUT] ----->Exception is
                16:21:49,388 INFO [STDOUT] ----->Deploy Failed....
                16:21:49,388 ERROR [STDERR] org.jbpm.JbpmException: could not find process definition 'simple'
                16:21:49,388 ERROR [STDERR] at org.jbpm.db.GraphSession.findLatestProcessDefinition(GraphSession.java:163)
                16:21:49,388 ERROR [STDERR] at org.jbpm.db.GraphSession.deployProcessDefinition(GraphSession.java:69)
                16:21:49,388 ERROR [STDERR] at org.jbpm.JbpmContext.deployProcessDefinition(JbpmContext.java:170)
                16:21:49,388 ERROR [STDERR] at com.sample.dao.JBPMDao.redeployProcess(JBPMDao.java:23)
                16:21:49,388 ERROR [STDERR] at com.sample.JBPMServlet.doGet(JBPMServlet.java:34)
                16:21:49,388 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
                16:21:49,388 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
                16:21:49,388 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)
                
                16:21:49,388 ERROR [STDERR] Caused by: org.hibernate.HibernateException: getNamedQuery is not valid without active transaction
                16:21:49,388 ERROR [STDERR] at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:297)
                16:21:49,388 ERROR [STDERR] at $Proxy50.getNamedQuery(Unknown Source)
                16:21:49,388 ERROR [STDERR] at org.jbpm.db.GraphSession.findLatestProcessDefinition(GraphSession.java:156)
                16:21:49,388 ERROR [STDERR] ... 24 more
                16:21:49,388 INFO [STDOUT] ----->Exception ends
                16:21:49,388 INFO [STDOUT] ----->Closing jBPM Context....
                



                And this is my Hibernate Config file. I removed the mappings & collection-cache.



                <?xml version='1.0' encoding='utf-8'?>

                <!DOCTYPE hibernate-configuration PUBLIC
                "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
                "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

                <hibernate-configuration>
                <session-factory>

                <!-- hibernate dialect -->
                <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>

                <!-- DataSource properties (begin) -->
                <property name="hibernate.connection.datasource">java:JbpmDS</property>

                <property name="hibernate.current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</property>

                <!-- JTA transaction properties (begin) === -->
                <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
                <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
                <property name="jta.UserTransaction">UserTransaction</property>
                <!--==== JTA transaction properties (end) -->

                <!-- Simple memory-only cache -->
                <property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>

                <!-- logging properties -->
                <property name="hibernate.format_sql">true</property>
                <property name="hibernate.use_sql_comments">true</property>


                • 5. Re: Hibernate error while deploying process in a web applica
                  Viki . Newbie

                  oh my god, the forumn didn't parsed my XML tags properly. is there any option to specify it ?