Search code examples
spring-bootcamundabpmnbusiness-process-management

Assigning the desired folder to read and deploy BPMN files in Camunda7 Spring boot


By default, Camunda7 engine reads NPMN files through a folder: reads src/main/resources and deploys in Spring boot Projects. Now, if in large projects that have many packages and modules and the Camunda is only one of them, we intend to consider a desired folder for this purpose and introduce its address to the Camunda engine, how is this written through Java code?

@Bean
  CommandLineRunner run(RepositoryService repositoryService){
    return args -> {

          repositoryService.createDeployment()
            .addClasspathResource("src/main/java/com/example/workflow/processes/*.bpmn")
            .deploy();


    };

  }

In the code above, an error is encountered that says the source was not found!

Caused by: org.camunda.bpm.engine.exception.NullValueException: resource 'src/main/java/com/example/workflow/processes/*.bpmn' not found: inputStream is null

I have applied almost all kinds of addressing in this string but I guessed that maybe my solution is wrong. How can we apply these settings with Java code?


Solution

  • The method addClasspathResource expects one concrete resource to deploy and therefore doesn't allowed wildcards. You could scan the classpath yourself and then add all found resources. Spring provides the ResourcePatternResolver for this. https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/core/io/support/ResourcePatternResolver.html