cancel
Showing results for 
Search instead for 
Did you mean: 

Deployment on Activiti Workflow Engine: NullPointerException Error

activiti_5_14
Champ in-the-making
Champ in-the-making
currently I am working with Activiti Workflow Engine and I am trying to deploy the process programmitically by using Eclipse. However everytime I tried to run the class file as Java Application, I always get following error

<blockcode>Exception in thread "main" java.lang.NullPointerException at createEngine.main(createEngine.java:9)</blockcode>

Here is my Code for the Deployment:



import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;

public class createEngine {
    public static void main(String[] args)
    {
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        RepositoryService repositoryService = processEngine.getRepositoryService();

        repositoryService.createDeployment()
          .addClasspathResource("accidentForm.bpmn20.xml")
          .deploy();

        System.out.println("Number of process definitions: " + repositoryService.createProcessDefinitionQuery().count());
    }
}



Moreover, after get this error I tried to print the value of <blockcode>processEngine</blockcode> by using bellow code:



import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;

public class createEngine {
    public static void main(String[] args)
    {
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        System.out.println(processEngine);
    }
}



And it return <blockcode>null</blockcode> value (I don't know whether it is normal or not).

Additional info: The Activiti Workflow Engine running above Tomcat 7 and within Windows 7 environment. Also, for your information, I have also tried to deploy the process by using activiti explorer and it is working without problem, so I am sure there is nothing wrong with my xml file.

I have tried to find some information regarding this problem, but I could not find anything that can be used to solve this problem. Any idea about this problem? Thanks in advance
4 REPLIES 4

activiti_5_14
Champ in-the-making
Champ in-the-making
I have found the problem. It because I forgot to add my activiti.cfg.xml to my classpath environment. However, I got a new error.

The error is:

<blockcode>

[main] INFO org.activiti.engine.ProcessEngines - Initializing process engine using configuration 'file:/D:/Tomcat/webapps/mobileformular/bin/activiti.cfg.xml'
[main] INFO org.activiti.engine.ProcessEngines - initializing process engine for resource file:/D:/Tomcat/webapps/mobileformular/bin/activiti.cfg.xml
Mrz 27, 2014 10:48:35 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from resource loaded through InputStream
[main] ERROR org.activiti.engine.ProcessEngines - Exception while initializing process engine: Error while building ibatis SqlSessionFactory: Error creating document instance.  Cause: java.net.UnknownHostException: mybatis.org
org.activiti.engine.ActivitiException: Error while building ibatis SqlSessionFactory: Error creating document instance.  Cause: java.net.UnknownHostException: mybatis.org
at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.initSqlSessionFactory(ProcessEngineConfigurationImpl.java:649)
at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.init(ProcessEngineConfigurationImpl.java:386)
at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.buildProcessEngine(ProcessEngineConfigurationImpl.java:362)
at org.activiti.engine.ProcessEngines.buildProcessEngine(ProcessEngines.java:194)
at org.activiti.engine.ProcessEngines.initProcessEnginFromResource(ProcessEngines.java:167)
at org.activiti.engine.ProcessEngines.init(ProcessEngines.java:98)
at org.activiti.engine.ProcessEngines.getProcessEngine(ProcessEngines.java:224)
at org.activiti.engine.ProcessEngines.getDefaultProcessEngine(ProcessEngines.java:217)
at createEngine.main(createEngine.java:8)
Caused by: org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: java.net.UnknownHostException: mybatis.org
at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:136)
at org.apache.ibatis.parsing.XPathParser.<init>(XPathParser.java:32)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.<init>(XMLConfigBuilder.java:45)
at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.initSqlSessionFactory(ProcessEngineConfigurationImpl.java:640)
… 8 more
Caused by: java.net.UnknownHostException: mybatis.org
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:134)
… 11 more
Exception in thread "main" java.lang.NullPointerException
at createEngine.main(createEngine.java:9)

</blockcode>

I have read several question about this problem, which it says that there is a problem either with my internet connection or I am behind a firewall. And yes, It is true, currently I am working behind company's firewall.  But, is there any ways to deploy the process without internet connection? Thanks.

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

How did you configure DB connections in activiti.cfg.xml?
(mybatis.org should be somewhere there)

Regards
Martin

activiti_5_14
Champ in-the-making
Champ in-the-making
Here is my DB configuration on activiti.cfg.xml value:

<code>

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans.xsd">
      
       <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
           <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/activiti?autoReconnect=true" />
           <property name="jdbcDriver" value="com.mysql.jdbc.Driver" />
           <property name="jdbcUsername" value="root" />
           <property name="jdbcPassword" value="" />
          
           <property name="databaseSchemaUpdate" value="true" />
          
           <property name="jobExecutorActivate" value="false" />
          
           <property name="mailServerHost" value="mail.my-company.com" />
           <property name="mailServerPort" value="25" />   
       </bean>

</beans>

</code>

Is there any problem with my configuration? Thanks for your help.