AnsweredAssumed Answered

How to Start ProcessEngine of Activiti from Servlet

Question asked by amitccet on Mar 22, 2013
Latest reply on Jul 20, 2015 by vasile.dirla
Hello Experts,

I am new in Activiti and I got stuck in one issue since last two days.

I have configured Activiti Explore 5.12 in Mysql Database by changing the activiti-standalone-context.xml


<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
  <property name="url" value="jdbc:mysql://localhost:3306/activiti" />
  <property name="username" value="root" />
  <property name="password" value="root" />
    <property name="defaultAutoCommit" value="false" />
  </bean>


And it is working fine.

But Now I have created one process and deployed that file in the Activiti Explorer.

And with the help of Servlet, I want to start the process.

So I written below code in the servlet.


protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      // TODO Auto-generated method stub
      PrintWriter out = response.getWriter();
       System.out.println("Inside DO GET()");
       ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
       RuntimeService runtimeService = processEngine.getRuntimeService();
      ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("expenseProcess");
         out.println("Started Process instance id " +processInstance.getProcessInstanceId());
     
   }


But It gives me error as below, I am not getting as I configured explorer as mysql then why it is pointing to the H2 DB.


013-03-22 14:39:03 INFO  [http-9090-1    ] - o.s.b.f.x.XmlBeanDe~          - Loading XML bean definitions from resource loaded through InputStream
Inside DO GET()
2013-03-22 14:39:04 ERROR [http-9090-1    ] - o.a.c.c.C.[.[.[.[He~          - Servlet.service() for servlet HelloWorldTest threw exception
org.apache.ibatis.datasource.DataSourceException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: org.h2.Driver
   at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.initializeDriver(UnpooledDataSource.java:179)
   at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.getConnection(UnpooledDataSource.java:57)
   at org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:349)
   at org.apache.ibatis.datasource.pooled.PooledDataSource.getConnection(PooledDataSource.java:55)
   at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.initDatabaseType(ProcessEngineConfigurationImpl.java:586)
   at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.initDataSource(ProcessEngineConfigurationImpl.java:548)
   at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.init(ProcessEngineConfigurationImpl.java:393)
   at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.buildProcessEngine(ProcessEngineConfigurationImpl.java:371)
   at com.hersheys.test.HelloWorldTest.doGet(HelloWorldTest.java:51)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
   at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: org.h2.Driver
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1493)
   at java.lang.Class.forName0(Native Method)
   at java.lang.Class.forName(Class.java:247)
   at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.initializeDriver(UnpooledDataSource.java:173)
   … 22 more

Please help. It's Urgent.

Outcomes