Simple Decision Deployment query

Hi,
I am trying to deploy a decision table. When I deploy by making the decision as a classpath resource, the decision gets deployed, but when I deploy the decision by adding it as a input stream , it doesnt get deployed and upon evaluating the decision I get an error as follows :

org.camunda.bpm.engine.exception.NotFoundException: no decision definition deployed with key ‘artifactdecision’: decisionDefinition is null

Is there any way to make it work by adding it as an input stream. Code I used :

          InputStream is = new FileInputStream(temp);
          byte [] content = IOUtil.toByteArray(is);

        DeploymentBuilder deploymentBuilder = processEngine.getRepositoryService()
            .createDeployment().tenantId(appId).addInputStream(resourceName, new ByteArrayInputStream(content));

deploymentBuilder.deploy();

Any input will really be helpful, as I am struggling with this.
Thanks.

Try this

    DeploymentBuilder deploymentBuilder = processEngine.getRepositoryService()
        .createDeployment().tenantId(appId).addInputStream(resourceName, new FileInputStream(temp));

addInputStream second params is an instance of FileInputStream where i assume temp is path to the file here. This should work

Hello @Vinodlouis,
Thanks for replying, tried it but unfortunately, this doesnt work. Any other inputs??

Hi @droy
For me this code works fine

        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();

	RepositoryService repositoryService = processEngine.getRepositoryService();
	DeploymentBuilder builder = repositoryService.createDeployment();
	try {
		builder.addInputStream("table.dmn", new FileInputStream("D:/table.dmn"));
	} catch (FileNotFoundException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
   
	org.camunda.bpm.engine.repository.Deployment deployment = builder.deploy();
	System.out.println(" deployed with id - " + deployment.getId());
	System.out.println(deployment.getId());

Can you pass your dmn file ?

Hi @droy,

Make sure your resourceName variable is a String that ends on .dmn or .dmn11.xml. This is required for the engine to recognize the resource as a DMN XML file and parse it accordingly.

Cheers,
Thorben

Hi thorben,
The resource name does end with .dmn or .dmn11.xml. any other inputs please

Can you provide a failing unit test? You can use https://github.com/camunda/camunda-engine-unittest to get started.

Cheers,
Thorben

dmn file : test.dmn (1.6 KB)

Hi @thorben,
Sure. Here is a test case, the deployment goes through but the evaluation throws an exception :

@Test
public void shouldEvaluate(){

String deploymentId = null;
String FileName = "test.dmn";
String FilePathName = "D:/test.dmn";

ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
DecisionService decisionService = processEngine.getDecisionService();
try {
    deploymentId = processEngine.getRepositoryService()
        .createDeployment().addInputStream(FileName, new FileInputStream(FilePathName)).deploy().getId();
}
catch (FileNotFoundException e) {
    e.printStackTrace();
}

VariableMap variables = Variables.createVariables().putValue("artifactType", "DATAFILE");
DmnDecisionTableResult dmnDecisionTableResult = decisionService.evaluateDecisionTableByKey("artifactSearchdecision", variables);
String result = dmnDecisionTableResult.getSingleEntry();
assertNotNull(result);

}

Could you push that test as a runnable maven project to github? That would help to run it locally.

Thanks,
Thorben

Hello @thorben,
Thanks for reminding me the power of unit tests. As I was doing an evaluation, I didnot think about writing some. I could see the exceptions much more clearly and am now able to run the model !!

Thanks again.
Thanks @Vinodlouis for your inputs as well.

Hi @droy,

That’s great to read. Would you mind sharing the solution? That would benefit other users reading this thread.

Cheers,
Thorben

Sure, I got the following errors :
1.Unable to resolve variable ‘DATAFILE’ in expression ‘DATAFILE’ : which points out that there is something wrong with the way the input value has been put in the .dmn file. In this case, I didnt wrap the input values with a “”.
2. DMN-01002 Unable to evaluate expression for language ‘juel’: ‘${artifact_Key}’. This points out something wrong with the input variable value. In my case, a typo:confounded:

Earlier, instead of the above errors I kept getting the error mentioned in the first post. That confused me, once I wrote the test case I could see the errors much more clearly.

Hi @thorben,
The test case I wrote works, but when I put the same thing in the main method, I get the same error as earlier. Any clues? I am stumped.

Hmm, could you share the project with the failing main method?