3 Replies Latest reply on Dec 18, 2008 5:17 PM by juanignaciosl

    Error: hibernate.cfg.xml not found when l launch a test

    juanignaciosl

      I had post this to another, probably wrong, forum. I'm sure you can help me with this :)


      I've created a Seam web project with JBoss Tools. I've made the following test:


      public class ProyectosTest extends SeamTest {
           @Logger
           Log log;
      
           @Test
           public void testProcesoProyecto() throws Exception {
                new ComponentTest() {
                     protected void testComponents() throws Exception {
                          ProyectoHome proyectoHome = (ProyectoHome) getValue("proyectoHome");
                          log.debug("{1}", proyectoHome);
                     }
                }.run();
           }
      }
      

           


      When I launch it with the TestNG plugin it throws the following exception:


      FAILED CONFIGURATION: @BeforeSuite startSeam
      org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.bpm.jbpm
      
           at org.jboss.seam.Component.newInstance(Component.java:2105)
           at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
           at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
           at org.jboss.seam.contexts.ServletLifecycle.endInitialization(ServletLifecycle.java:112)
           at org.jboss.seam.init.Initialization.init(Initialization.java:734)
           at org.jboss.seam.mock.AbstractSeamTest.startSeam(AbstractSeamTest.java:920)
           at org.jboss.seam.mock.SeamTest.startSeam(SeamTest.java:58)
      Caused by: java.lang.RuntimeException: could not deploy a process definition
           at org.jboss.seam.bpm.Jbpm.installProcessDefinitions(Jbpm.java:300)
           at org.jboss.seam.bpm.Jbpm.startup(Jbpm.java:80)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
           at org.jboss.seam.Component.callComponentMethod(Component.java:2210)
           at org.jboss.seam.Component.callCreateMethod(Component.java:2133)
           at org.jboss.seam.Component.newInstance(Component.java:2093)
           ... 21 more
      Caused by: org.hibernate.HibernateException: hibernate.cfg.xml not found
           at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:147)
           at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1405)
           at org.hibernate.cfg.Configuration.configure(Configuration.java:1427)
           at org.jbpm.db.hibernate.HibernateHelper.createConfiguration(HibernateHelper.java:91)
           at org.jbpm.persistence.db.DbPersistenceServiceFactory.getConfiguration(DbPersistenceServiceFactory
      .java:69)
           at org.jbpm.persistence.db.DbPersistenceServiceFactory.getSessionFactory(DbPersistenceServiceFactor
      y.java:91)
           at org.jbpm.persistence.db.DbPersistenceService.getSessionFactory(DbPersistenceService.java:95)
           at org.jbpm.persistence.db.DbPersistenceService.getSession(DbPersistenceService.java:99)
           at org.jbpm.persistence.db.DbPersistenceService.getGraphSession(DbPersistenceService.java:341)
           at org.jbpm.JbpmContext.getGraphSession(JbpmContext.java:571)
           at org.jbpm.JbpmContext.deployProcessDefinition(JbpmContext.java:173)
           at org.jboss.seam.bpm.Jbpm.deployProcess(Jbpm.java:316)
           at org.jboss.seam.bpm.Jbpm.installProcessDefinitions(Jbpm.java:294)
           ... 31 more
      ... Removed 19 stack frames
      SKIPPED CONFIGURATION: @BeforeClass setupClass
      SKIPPED CONFIGURATION: @BeforeMethod begin
      SKIPPED CONFIGURATION: @AfterMethod end
      SKIPPED CONFIGURATION: @AfterClass cleanupClass
      SKIPPED: testProcesoProyecto
      
      ===============================================
          es.cexc.reincide.test.ProyectosTest
          Tests run: 1, Failures: 0, Skips: 1
          Configuration Failures: 1, Skips: 4
      ===============================================
      
      
      ===============================================
      reincide-test
      Total tests run: 1, Failures: 0, Skips: 1
      Configuration Failures: 1, Skips: 5
      ===============================================



      The app works fine with a normal deployment, but the embedded JBoss for the test throws that exception. What might I have done wrong?

        • 1. Re: Error: hibernate.cfg.xml not found when l launch a test
          juanignaciosl

          I've created hibernate.cfg.xml (although I don't know why should it be needed):


          <?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>
                    <property name="connection.datasource">java:/reincideDatasource</property>
               </session-factory>
          
          </hibernate-configuration>



          I think it's right, because replacing 'java:/reincideDatasource' with 'xx' throws a not found like error.


          Now I have another strange (at least for me) error:


          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:1260)
          ...
          ERROR [org.jbpm.db.GraphSession] org.hibernate.MappingException: Named query not known: GraphSession.findLatestProcessDefinitionQuery
          FAILED CONFIGURATION: @BeforeSuite startSeam
          org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.bpm.jbpm
               at org.jboss.seam.Component.newInstance(Component.java:2105)
               at org.jboss.seam.contexts.Contexts.startup(Contexts.java:30
          ...
               at org.jboss.seam.mock.SeamTest.startSeam(SeamTest.java:58)
          Caused by: java.lang.RuntimeException: could not deploy a process definition
               at org.jboss.seam.bpm.Jbpm.installProcessDefinitions(Jbpm.java:300)
               at org.jboss.seam.bpm.Jbpm.startup(Jbpm.java:80)
               at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
               at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
               at org.jboss.seam.Component.callComponentMethod(Component.java:2210)
               at org.jboss.seam.Component.callCreateMethod(Component.java:2133)
               at org.jboss.seam.Component.newInstance(Component.java:2093)
               ... 21 more
          Caused by: org.jbpm.JbpmException: couldn't find process definition 'proyecto'
               at org.jbpm.db.GraphSession.findLatestProcessDefinition(GraphSession.java:170)
               at org.jbpm.db.GraphSession.deployProcessDefinition(GraphSession.java:67)
               at org.jbpm.JbpmContext.deployProcessDefinition(JbpmContext.java:173)
               at org.jboss.seam.bpm.Jbpm.deployProcess(Jbpm.java:316)
               at org.jboss.seam.bpm.Jbpm.installProcessDefinitions(Jbpm.java:294)
               ... 31 more
          Caused by: 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:1260)
               at org.jbpm.db.GraphSession.findLatestProcessDefinition(GraphSession.java:150)
               ... 35 more
          ... Removed 19 stack frames
          SKIPPED CONFIGURATION: @BeforeClass setupClass
          SKIPPED CONFIGURATION: @BeforeMethod begin
          SKIPPED CONFIGURATION: @AfterMethod end
          SKIPPED CONFIGURATION: @AfterClass cleanupClass
          SKIPPED: testProcesoProyecto
          
          ===============================================
              es.cexc.reincide.test.ProyectosTest
              Tests run: 1, Failures: 0, Skips: 1
              Configuration Failures: 1, Skips: 4
          ===============================================


          • 2. Re: Error: hibernate.cfg.xml not found when l launch a test
            juanignaciosl

            Auto reply. Adding

            <mapping resource="org/jbpm/db/hibernate.queries.hbm.xml" />

            removes that error.

            • 3. Re: Error: hibernate.cfg.xml not found when l launch a test
              juanignaciosl

              Still stuck:


              Caused by: java.lang.IllegalArgumentException: Parameter name does not exist as a named parameter in [
                  
                   select pd
                   from org.jbpm.graph.def.ProcessDefinition as pd
                   where pd.name = :name
                   order by pd.version desc    
                  
                ]