Not able to generate the process instnace from external java class

Latest response

Hi Redhat Team,

I am not able to generate the process instance from external java class.I am getting the below exception
Exception in thread "main" org.kie.server.api.exception.KieServicesHttpException: Unexpected HTTP response code when requesting URI 'http://localhost:8080/kie-server/services/rest/server/containers/Store_Transfer_KR_MultiItem_1.0.0/processes/Store_Transfer_KR2.Store_Transfer_KR/instances'! Error code: 500, message: "Unable to create response: null"
at org.kie.server.client.impl.AbstractKieServicesClientImpl.createExceptionForUnexpectedResponseCode(AbstractKieServicesClientImpl.java:617)
at org.kie.server.client.impl.AbstractKieServicesClientImpl.makeHttpPostRequestAndCreateCustomResponse(AbstractKieServicesClientImpl.java:320)
at org.kie.server.client.impl.AbstractKieServicesClientImpl.makeHttpPostRequestAndCreateCustomResponse(AbstractKieServicesClientImpl.java:300)
at org.kie.server.client.impl.ProcessServicesClientImpl.startProcess(ProcessServicesClientImpl.java:262)
at com.poc.esteel.elcMain.main(elcMain.java:108)

I follow the below steps:
1)In my business process ,after user task completion .I wrote script task,where i place the ms sql database update java code.
like:
--------------Sript task
System.out.println("Rejected at first level");
System.out.println("Reject 1st level"+Inventory.getApproverName());
System.out.println("Document id"+Inventory.getDocumentId());

java.lang.String DB_URL = "url";
java.lang.String USER = "abc";
java.lang.String PASS = "abc";
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
System.out.println("Connecting to database");
java.sql.Connection conn = java.sql.DriverManager.getConnection(DB_URL,USER,PASS);

System.out.println("Creating statement");
java.sql.Statement stmt = conn.createStatement();
java.lang.String sql = "UPDATE [RETAIL PORTAL].dbo.INVENTORY_CONTROL " +
"SET OVERALL_APPROVAL_STATUS='REJECTED' WHERE DOCUMENT_ID='"+Inventory.getDocumentId()+"'";
int n=stmt.executeUpdate(sql);
System.out.println("rs is:"+n);
stmt.close();
conn.close();
}catch (Exception e) {
e.printStackTrace();
}
---End task

2)Created java class for get the process instnace for :
Java class-------------
public class elcMain {

public static void main(String[] args) {

    Long processInstanceId = null;
    // TODO Auto-generated method stub


    String SERVER_URL = "http://localhost:8080/kie-server/services/rest/server";

    String USERNAME = "kieserver";

    String PASSWORD = "kieserver1!";



    String PROCESS_ID = "Store_Transfer_KR2.Store_Transfer_KR";*/
    /*String CONTAINER_ID = "Store_Transfer_KR_1.0.0";

    String PROCESS_ID = "Store_Transfer_KR2.Store_Transfer_KR";*/
    String CONTAINER_ID ="Store_Transfer_KR_MultiItem_1.0.0";

    String PROCESS_ID="Store_Transfer_KR2.Store_Transfer_KR";
    System.out.println("Initiating the process : " + PROCESS_ID);

    KieServicesConfiguration config = KieServicesFactory.newRestConfiguration(SERVER_URL, USERNAME, PASSWORD);

    Set<Class<?>> allClasses = new HashSet<Class<?>>();

    allClasses.add(Inventory.class);

    allClasses.add(Item.class);


    config.addJaxbClasses(allClasses);

    KieServicesClient client = KieServicesFactory.newKieServicesClient(config);

    ProcessServicesClient processServices = client.getServicesClient(ProcessServicesClient.class);

    Map<String, Object> params = new HashMap<String, Object>();
    Inventory in = new DBConnectWithMultiItem().getData();

    processInstanceId = processServices.startProcess(CONTAINER_ID, PROCESS_ID, params);

        System.out.println("Started New AFFILIATE_DIVISION process " + processInstanceId);


}

}

3)If i add the maven dependency for ms sql server at RHPAM project setting section and try to generate the process instance from java class,in that case above exception.
4)If i dont add the maven dependecy for ms sql database,process instance is generated successfully but databse is not update,it displays ClassNotFoundException for ms sql server class.

Please team help me out.

Responses