JBoss Community

Re: A question about rule task in jBPM5

created by dalgwen in jBPM - View the full discussion

Hello,

 

Did you get to manage your issue?

I got exactly the same stack trace, with the same situation (call to completeWorkItem() from a different thread, and with JPA persistence). Don't know if is of some value, but the code of my WorkItemHandler looks like this :

 

 

@Override
public void executeWorkItem(final WorkItem workItem, final WorkItemManager manager) {
 
 
new Thread(new Runnable() {
public void run() {
 
try {
//some code (...)
manager.completeWorkItem(workItem.getId(), null);
}
catch (Exception ex) {
// some code (...)
}
}
}).start();
 
}

 

Curious fact : this error is triggerered in the second WorkItemHandler of my workflow, despite the fact that the first one use the same kind of code.

When I debug, i see that :

 

PersistenceContext context = ((PersistenceContextManager) env.get( EnvironmentName.PERSISTENCE_CONTEXT_MANAGER )).getCommandScopedPersistenceContext();
context.persist( workItemInfo );
 
((WorkItemImpl) workItem).setId(workItemInfo.getId());

 

"workitemInfo" is ok, but its id is null, so the nullPointerException.

 

I also debugged with the first WorkItem of my workflow, and then the id is ok after the context.persist(...) call.

Don't know why it works the first time and not after.

 

Thanks for reading me.

 

(Sorry for my english, it's not my mother langage ;-) !)

Reply to this message by going to Community

Start a new discussion in jBPM at Community