jerryfiunam (61) [Avatar] Offline
#1
Hi again smilie,

This time I just would like to know if is possible to get instances of every *Entity classes, for instance "DeploymentEntity" or "ProcessDefinitionEntity" class. I tried to get that with this code:

DeploymentEntity deployment = Context
.getCommandContext()
.getDeploymentEntityManager()
.findDeploymentById(ruleId);

But Context.getCommandContext() retrieves a NULL object, so I wonder is there is another way to do that, or there is something that I have to do before in order to get it. I know that this is not part of the public API, so I wonder if you can help me with it.

Thanks in advance.

Jerry
jerryfiunam (61) [Avatar] Offline
#2
Re: How to get instances of *Entity classes
In addition to my former post, I realized that this line of code:

Context.getCommandContext();

always retrieves NULL, internally this object is always NULL. This time I wanted to build a CustomePostDeployer for my BusinessRules and when I apply this code:

processEngine
.getProcessEngineConfiguration()
.getDeploymentManager()
.deploy(deployment);


Internally an error occurs as follows:

Caused by: java.lang.NullPointerException at org.activiti.engine.impl.bpmn.deployer.BpmnDeployer.deploy(BpmnDeployer.java:125)
at org.activiti.engine.impl.persistence.deploy.DeploymentManager.deploy(DeploymentManager.java:42)

Which is this line of code in the BpmnDeployer class:

CommandContext commandContext = Context.getCommandContext();
ProcessDefinitionEntityManager processDefinitionManager = commandContext.getProcessDefinitionEntityManager();

I wonder if this is correct, and what can I do in order to avoid this. Is every object retrieved by Context class NULL? Why Context.getCommandContext() is always NULL?

Thanks smilie
tijs.rademakers (494) [Avatar] Offline
#3
Re: How to get instances of *Entity classes
Hi,

When you check all the service implementations in Activiti you see that it's always wrapped in a command executor. That's needed to have a command context and that's why it's null in your case.

Best regards,

Tijs
jerryfiunam (61) [Avatar] Offline
#4
Re: How to get instances of *Entity classes
Hi Tijs,

Thanks a lot for your explanation, I will workaround this with another approach smilie.

Regards,

JERRY