NPE during REST deployment

Hi all,
I downloaded 7.7.0, activated the authentication filter in the rest-engine webapp and started the application. Now I’m trying to deploy [1] a simple model (see attachment) over the REST API but I’m getting an NPE [3]. What am I doing wrong?

[1]

String plainCreds = "demo:demo";
        byte[] plainCredsBytes = plainCreds.getBytes();
        byte[] base64CredsBytes = Base64.getEncoder().encode(plainCredsBytes);
        String base64Creds = new String(base64CredsBytes);
        HttpHeaders headers = new HttpHeaders();
        headers.add("Authorization", "Basic " + base64Creds);
        headers.add("Host", "localhost:8080");
        headers.add("Accept", "application/json");
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        InputStream in = getClass().getResourceAsStream("/test.bpmn");
        IOUtils.copy(in, baos);
        ByteArrayResource bar = new ByteArrayResource(baos.toByteArray(),"test.pbmn");

        headers.setContentType(MediaType.MULTIPART_FORM_DATA);
        RestTemplate restTemplate = new RestTemplate();
        MultiValueMap<String, Object> parts = new LinkedMultiValueMap<String, Object>();
        parts.add("deployment-name", "test.bpmn");
        parts.add("deployment-source", "test.bpmn");
        parts.add("enable-duplicate-filtering", "true");
        parts.add("deployment-name", "test-deployment");
        //parts.add("tenant-id", "camunda-admin");
        parts.add("data", bar);

        HttpEntity<MultiValueMap<String, Object>> request = new HttpEntity<>(parts, headers);
        try{
        String result = restTemplate.postForObject(
                "http://localhost:8080/engine-rest/deployment/create", request, String.class);
        System.out.println(result);
        }
        catch (HttpServerErrorException e){
            System.err.println(e.getResponseBodyAsString());
        }

[3]

java.lang.NullPointerException
	org.camunda.bpm.engine.impl.AbstractDefinitionDeployer.isResourceHandled(AbstractDefinitionDeployer.java:81)
	org.camunda.bpm.engine.impl.AbstractDefinitionDeployer.parseDefinitionResources(AbstractDefinitionDeployer.java:70)
	org.camunda.bpm.engine.impl.AbstractDefinitionDeployer.deploy(AbstractDefinitionDeployer.java:61)
	org.camunda.bpm.engine.impl.persistence.deploy.cache.CacheDeployer$1.call(CacheDeployer.java:50)
	org.camunda.bpm.engine.impl.persistence.deploy.cache.CacheDeployer$1.call(CacheDeployer.java:47)
	org.camunda.bpm.engine.impl.interceptor.CommandContext.runWithoutAuthorization(CommandContext.java:473)
	org.camunda.bpm.engine.impl.persistence.deploy.cache.CacheDeployer.deploy(CacheDeployer.java:47)
	org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache.deploy(DeploymentCache.java:63)
	org.camunda.bpm.engine.impl.persistence.entity.DeploymentManager.insertDeployment(DeploymentManager.java:51)
	org.camunda.bpm.engine.impl.cmd.DeployCmd.deploy(DeployCmd.java:479)
	org.camunda.bpm.engine.impl.cmd.DeployCmd$1.call(DeployCmd.java:138)
	org.camunda.bpm.engine.impl.cmd.DeployCmd$1.call(DeployCmd.java:126)

test.bpmn (4.1 KB)

Hi @gowiththeflow,

According to the stacktrace and consulting the engine source code, you have added a resource to the deployment which doesn’t have a name.

Could it be you misspelled the bpmn?

Cheers,
Christian

1 Like

@hawky4s - you could change your nick to Hawkeys. Good catch :slight_smile:
Unfortunatelly it didn’t work:

ByteArrayResource bar = new ByteArrayResource(baos.toByteArray(),“test.bpmn”);

still leads to the same NPE. I also checked the camunda code and found the reference to resources and suffixes, I’m just not sure where it gets the resource name from.

Could you put the src code on GitHub so I can debug it quickly.

You were right about the resource name. The ByteArrayResource I was using didn’t have a name (afaik it’s not possible to do that with a ByteArrayResource) which lead to the multipart form data post not giving the model a name. Changing that to a ClassPathResource did the trick:

ClassPathResource bar = new ClassPathResource("/test.bpmn");

Oh yeah, this is a Spring/client issue by the way and not related in any way to Camunda.