Creating and deploying a simple WAR with Camunda on Tomcat

Hi. First I apologize if this is a naive question.

I’ve been asked to look into the possibility of deploying a simple File Validation service with Camunda, ideally as a servlet that sits with Camunda. A colleague has been working on a BPMN workflow, which we build and deploy as a ServletProcessApplication WAR and it works great.

The issue we ran into, is during the new Task creation step we need to accept a CSV file which is intended to be the definition against which other files submitted using the task workflow will be referenced against. We’re very concerned that that submitted CSV file could be invalid or simply not a CSV file. This is an existing file that the manual process already works with and we can’t change that process just yet, so we have to with it.

A simple solution is to just write a servlet that accepts a basic POST request, validates the file every which way, then responds with 200, or 500 with an appropriate error message. The new task form we have can post the file to the servlet via a JS call, then if the form is good/bad, display the acceptance before the user can click the submit button and the task gets created.

I wrote a simple servlet to test if I could just access it. I copied the war to the camunda /webapps directory, it was deployed and the logs show as much, but I can’t access the webservlet URL: I realize that would be the correct URL, but I’m not sure where it would be hosted under. Should I be adding a to the server.xml configuration?

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class CsvValidator extends HttpServlet {
   private static final long serialVersionUID = 1L;
   protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
         throws ServletException, IOException {
      resp.getWriter().write("Hello World! Maven Web Project Example.");

I figured I just ask a dumb question out wright instead of trying to guess. Any help is greatly appreciated. Thanks.

It looks like you are familiar with Java. How do you currently create your Camunda deployment/server? In a Spring (Boot) setup you can very easily add a servlet/REST service to a Camunda app in this way:

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

public class TestService {

    @GetMapping(value = "/testo/csv")
    public String printHello(String param) {
                return "hello " + param;

and then access it via: http://localhost:8080/testo/csv?param=csv3

If you are using a pre-built camunda distribution and just adding your own WAR to it, then this web app will be unrelated to Camunda. Your servlet path will reside under this web application’s root. The defaults and options to change it are described here; paragraph Naming

When autoDeploy or deployOnStartup operations are performed by a Host, the name and context path of the web application are derived from the name(s) of the file(s) that define(s) the web application.[…]

1 Like