cancel
Showing results for 
Search instead for 
Did you mean: 

diagram viewer - process instance wise diagram - throws null pointer

badrisudheer
Champ in-the-making
Champ in-the-making
I have tried to use diagram viewer index html page to see the diagram for a given process instance created for a process definition using (…/diagram-viewer/index.html?processDefinitionId=<proc-def-id>&processInstanceId=<proc-instance-id> ). It worked well, meaning showed the path of execution flow in RED as long as the process instance is not ended. But, once the process instance is ended, it shows the diagram but, could not redraw (or highlight) the flow in RED. Looking at the logs, it threw NullPointerException  -here is the error log snippet -

java.lang.NullPointerException
   at org.activiti.rest.diagram.services.ProcessInstanceHighlightsResource.getHighlighted(ProcessInstanceHighlightsResource.java:53)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

Thought of checking on the forum to see if there is anything specific I am supposed to do to get the flow path redrawn successfully after the process instance execution ends. Any idea ?
6 REPLIES 6

jbarrez
Star Contributor
Star Contributor
It doesn't work for historic process instances. If you would look at the code line where your exception happens, you'll see it tries to fetch the process instance. which doesn't exist.

badrisudheer
Champ in-the-making
Champ in-the-making
Ok. I thought so but, was just wondering that the code can be enhanced to read process_instance execution steps from ACT_HI_* tables, if we set the level to history, and should be able to redraw (highlight) the execution path in red even after the end of the process, is my thinking right or is there any other complexity associated with respect to history setting which I am not seeing ?

Hi,
try to use audit trail
http://forums.activiti.org/content/audit-trail-diagram

Regards
Martin

I wonder if there is any interest in this anymore?  And if so, maybe this can be a Jira feature request…

If you look at the source under Activiti/modules/activiti-diagram-rest, you can see the service implementation which is used by the diagram-viewer in the Explorer webapp to generate the process-diagram and instance-highlights.

I was able to copy/paste the existing implementations (ProcessInstanceHighlightsResource and ProcessDefinitionDiagramLayoutResource) which use the process runtime service, and tweak them a bit to use the history service instead.  I just prepended "historic-" to the names of the new resources I just created to denote they would use the history service exclusively.  It actually made the code a bit simpler, as the existing implementation was fusing activity states from both history and runtime to generate highlights.

On the one hand, to make it seamless, the implemenation could be made to rely more on the History tables to generate the instance diagram, so that a query can be made for any process instance irrespective of if it is completed or not.  But, it looks like that would require the History logging to be turned up (which is not a requirement).

On the other hand, to accomodate sites which do not use history logging, the diagram-viewer would need to first decide if the process is complete or not (e.g. has been removed from runtime), before calling a "historic-" version of ProcessInstanceHighlightsResource.

ivan_wang
Champ in-the-making
Champ in-the-making
你的问题我也遇到过,解决如下:
对ProcessInstanceHighlightsResource重新改造
1.将runtimeService改为historyService,读取历史HistoricActivityInstanceQuery。
    这样即可以获取运行时流程图,也可以获取历史流程图,而不会出现上述的NullPointerException。
2. 如果有子流程,子流程递归有bug,在子流程结束时没有判断跳出,添加如下代码:
    if (allOutgoingTrans.size()==0) {
            break;
    }
3. 整个改造见附件。

jbarrez
Star Contributor
Star Contributor
Sorry, my chinese (apologies if it's another langauge) is very limited (i.e. not existant) 🙂