3 Replies Latest reply on Feb 21, 2006 4:07 AM by Purvi Shah

    At time of DEPLOYMENT-Connection could not open error.

    Purvi Shah Newbie

      HI
      I tried to deploy one process(First Process) through TestClass.
      I am working on Eclipse,I have installed Startupkit 3.0.2.


      I got following error at time of running FirstTest class with Junit.

      *********************************Process Name:First Process
      ***************************JBPM SESSION***********org.jbpm.db.JbpmSession@c272bc
      11:38:38,516 WARN JDBCExceptionReporter : SQL Error: 0, SQLState: null
      11:38:38,516 ERROR JDBCExceptionReporter : com.mchange.v2.c3p0.PoolBackedDataSource@1bde4 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@1478a43 [ acquireIncrement -> 1, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, idleConnectionTestPeriod -> 0, initialPoolSize -> 1, maxIdleTime -> 0, maxPoolSize -> 3, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 1, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@ba5bdb [ description -> null, driverClass -> null, factoryClassLocation -> null, jdbcUrl -> jdbc:hsqldb:hsql://localhost:1701, properties -> {user=******, password=******} ] , preferredTestQuery -> null, propertyCycle -> 300, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, usesTraditionalReflectiveProxies -> false ] , factoryClassLocation -> null, numHelperThreads -> 3, poolOwnerIdentityToken -> 1bde4 ] has been closed() -- you can no longer use it.
      11:38:38,516 ERROR JbpmSession : org.hibernate.exception.GenericJDBCException: Cannot open connection





      First Test class code mentioned below.

      package com.First;

      import java.io.IOException;
      import java.io.InputStream;
      import java.util.Iterator;
      import java.util.Properties;

      import junit.framework.TestCase;

      import org.jbpm.db.JbpmSession;
      import org.jbpm.db.JbpmSessionFactory;
      import org.jbpm.graph.def.ProcessDefinition;
      import org.jbpm.graph.exe.ProcessInstance;
      import org.jbpm.instantiation.ClassLoaderUtil;
      import org.jbpm.jpdl.xml.*;
      import org.hibernate.Transaction;
      import org.hibernate.cfg.Configuration;
      public class FirstTest extends TestCase {
      /*static JbpmSessionFactory jbpmSessionFactory =
      JbpmSessionFactory.buildJbpmSessionFactory();*/

      public void testProcess()throws Exception{
      try {
      Configuration configuration = getTestConfiguration();

      JbpmSessionFactory jbpmSessionFactory = JbpmSessionFactory.buildJbpmSessionFactory(configuration);

      ProcessDefinition definition =
      ProcessDefinition.parseXmlResource("First.par/processdefinition.xml");
      assertNotNull("Definition should not be null", definition);


      System.out.println("*********************************Process Name:"+definition.getName());


      // Let's open a new persistence session
      JbpmSession jbpmSession = jbpmSessionFactory.openJbpmSession();
      System.out.println("***************************JBPM SESSION***********"+jbpmSession);
      jbpmSession.beginTransaction();
      // ... and begin a transaction on the persistence session
      // jbpmSession.getJbpmSessionFactory()


      // Transaction tx =jbpmSession.getTransaction();
      // Save the process definition in the database

      jbpmSession.getGraphSession().saveProcessDefinition(definition);
      //System.out.println("Process definition:"+jbpmSession.getGraphSession().findLatestProcessDefinition("First.par/processdefinition.xml"));

      // Commit the transaction
      jbpmSession.commitTransaction();

      System.out.println("Process definition:After Proces definition***********"+jbpmSession.getGraphSession().findLatestProcessDefinition("First Process"));

      // And close the jbpmSession.
      jbpmSession.close();

      JbpmSession jbpmSession1 = jbpmSessionFactory.openJbpmSession();
      // ... and begin a transaction on the persistence session.
      jbpmSession1.beginTransaction();

      // Now we can query the database for the process definition that we
      // deployed above.
      ProcessDefinition definition1 =
      jbpmSession1
      .getGraphSession()
      .findLatestProcessDefinition("First Process");
      // Create an instance of the process definition.
      ProcessInstance instance = new ProcessInstance(definition1);
      assertEquals(
      "Instance is in start state",
      instance.getRootToken().getNode().getName(),
      "start");
      assertNull(
      "Message variable should not exist yet",
      instance.getContextInstance().getVariable("message"));

      // Move the process instance from its start state to the first state.
      // The configured action should execute and the appropriate message
      // should appear in the message process variable.
      instance.signal();
      assertEquals(
      "Instance is in first state",
      instance.getRootToken().getNode().getName(),
      "auction");


      // Move the process instance to the end state. The configured action
      // should execute again. The message variable contains a new value.
      instance.signal();
      assertEquals(
      "Instance is in end state",
      instance.getRootToken().getNode().getName(),
      "end");
      assertTrue("Instance has ended", instance.hasEnded());
      } catch (RuntimeException e) {
      e.printStackTrace();

      }

      }
      public void firstActionHandler() throws Exception{

      ProcessDefinition definition =
      ProcessDefinition.parseXmlResource("First.par/processdefinition.xml");
      ProcessInstance instance = new ProcessInstance(definition);
      assertNull("The greeting varible does not exist.",instance.getContextInstance().getVariable("greeting"));
      instance.signal();
      assertEquals("The greeting variable is created.",instance.getContextInstance().getVariable("greeting"),"Heelo from Action Handler");
      }

      private static Configuration getTestConfiguration() {
      Configuration configuration = JbpmSessionFactory.createConfiguration();
      InputStream is = ClassLoaderUtil.getStream("hibernate.properties");
      if (is!=null) {
      Properties properties = new Properties();

      try {
      properties.load(is);
      System.out.println("############################ "+properties);
      } catch (IOException e) {
      throw new RuntimeException("couldn't load jbpm.dbtest.hibernate.properties", e);
      }
      Iterator iter = properties.keySet().iterator();
      while (iter.hasNext()) {
      String key = (String) iter.next();
      String value = properties.getProperty(key);
      System.out.println("#############################################overwriting jbpm.test.hibernate.properties: "+key+"="+value);
      configuration.setProperty(key, value);
      }
      }
      return configuration;
      }
      }



      Hibernate configuration file has been mentioned below.

      hibernate.dialect=org.hibernate.dialect.HSQLDialect
      hibernate.connection.driver_class=org.hsqldb.jdbcDriver
      hibernate.connection.url=jdbc:hsqldb:hsql://localhost:1701
      hibernate.connection.username=sa
      hibernate.connection.password=

      hibernate.show_sql=true
      hibernate.c3p0.min_size=1
      hibernate.c3p0.max_size=3
      hibernate.hbm2ddl.auto=update

        • 1. Re: At time of DEPLOYMENT-Connection could not open error.
          Alejandro Guizar Master

          Hypersonic comes with a database management tool that you can run as a Java application with the following command:

          java -cp hsqldb.jar org.hsqldb.DatabaseManager

          Do you get connectivity with this tool when you use the connection properties you specify? In particular, I think you are missing a database name in the connection URL:
          hibernate.connection.url=jdbc:hsqldb:hsql://localhost:1707/dbname


          • 2. Re: At time of DEPLOYMENT-Connection could not open error.
            Alejandro Guizar Master

            Oops, the database manager class is org.hsqldb.util.DatabaseManager. Hypersonic also offers an alternate version based on Swing instead of AWT: org.hsqldb.util.DatabaseManagerSwing

            • 3. Re: At time of DEPLOYMENT-Connection could not open error.
              Purvi Shah Newbie

              Hi Alex,
              Thanks for response.
              Now I able to connect to HSQL Datamanager ,the way you mentioend.
              I could not find my schema.
              When I add Database name in Hibernate.config file, I got error
              Database not found.
              BUt server\data folder localDb(My database name-i have not achanged anything-it come by defalut) is exist.

              Now I tried to run First Test class,without db name in hibernate config file.
              I* got successful message.
              I found process instance started message in console.
              BUt though I am not able to find this process with version 1 on webconsole.
              I found Process with version -1 on webconsole(jBPM).

              For WebSale process I am able to start process instance form webconsole an d task list also appeared on webconsole,.
              Sameway I also want to do for My process.
              BUt I am not able to start process instance from webconsole.

              I am new to jBPM.
              I do not know If anything is missing for display on webconsole.

              Can you share any basic mateirla on jBPM other than user guide and gettign started docuemnt.
              I read hat but I could not find comprehensive.

              Regards
              Thank you.