cancel
Showing results for 
Search instead for 
Did you mean: 

ProcessDiagramGenerator error

ahmetkara
Champ in-the-making
Champ in-the-making
Hi guys,

I try to use ProcessDiagramGenerator to generate the png of a process but I couldn't yet.
I am getting the error below.

Caused by: java.awt.image.RasterFormatException: (x + width) is outside raster
at sun.awt.image.IntegerInterleavedRaster.createWritableChild(Unknown Source)
at java.awt.image.BufferedImage.getSubimage(Unknown Source)
at org.activiti.engine.impl.bpmn.deployer.ProcessDiagramCanvas.generateImage(ProcessDiagramCanvas.java:161)
at org.activiti.engine.impl.bpmn.deployer.ProcessDiagramGenerator.generateDiagram(ProcessDiagramGenerator.java:205)
at org.activiti.engine.impl.bpmn.deployer.ProcessDiagramGenerator.generatePngDiagram(ProcessDiagramGenerator.java:184

Do you have any idea, what is the reason?
21 REPLIES 21

ahmetkara
Champ in-the-making
Champ in-the-making
The activiti-webapp-rest module uses the following code to get the ProcessDefinitionEntity:
ProcessDefinitionEntity pde = (ProcessDefinitionEntity) ((RepositoryServiceImpl) getRepositoryService())
        .getDeployedProcessDefinition(pi.getProcessDefinitionId());
Such process definition entity seems to have the activities initialized.


I did like you posted but unfortunately again the failure.

The error is below.

Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -2
at java.lang.String.substring(Unknown Source)
at org.activiti.engine.impl.bpmn.deployer.ProcessDiagramCanvas.fitTextToWidth(ProcessDiagramCanvas.java:327)
at org.activiti.engine.impl.bpmn.deployer.ProcessDiagramCanvas.drawTask(ProcessDiagramCanvas.java:317)
at org.activiti.engine.impl.bpmn.deployer.ProcessDiagramCanvas.drawTask(ProcessDiagramCanvas.java:294)
at org.activiti.engine.impl.bpmn.deployer.ProcessDiagramCanvas.drawUserTask(ProcessDiagramCanvas.java:338)
at org.activiti.engine.impl.bpmn.deployer.ProcessDiagramGenerator$5.draw(ProcessDiagramGenerator.java:77)
at org.activiti.engine.impl.bpmn.deployer.ProcessDiagramGenerator.drawActivity(ProcessDiagramGenerator.java:211)
at org.activiti.engine.impl.bpmn.deployer.ProcessDiagramGenerator.generateDiagram(ProcessDiagramGenerator.java:198)
at org.activiti.engine.impl.bpmn.deployer.ProcessDiagramGenerator.generateDiagram(ProcessDiagramGenerator.java:205)
at org.activiti.engine.impl.bpmn.deployer.ProcessDiagramGenerator.generatePngDiagram(ProcessDiagramGenerator.java:184)

walterjs
Champ in-the-making
Champ in-the-making
This might be because you don't have any bpmndi information in your BPMN xml. Recreate your bpmn with the 0.7 version of the designer.

teinacher
Champ in-the-making
Champ in-the-making
Thank you, h.ter.schuur.

Your hint solved the problem. I can now display the diagrams.

frederikherema1
Star Contributor
Star Contributor
Hi,

This is an issue that occurs when an activity/gateway/… is found without any width/height info for it. Can you check your XML to check that all activities have a corresponding DI-counterpart (containing x y width height). Also set all "name" properties on activities as well (if not already the case).

ahmetkara
Champ in-the-making
Champ in-the-making
Hi,

This is an issue that occurs when an activity/gateway/… is found without any width/height info for it. Can you check your XML to check that all activities have a corresponding DI-counterpart (containing x y width height). Also set all "name" properties on activities as well (if not already the case).


I did what you wrote and I can get the image of my process with the code below, but again I have a question Smiley Very Happy. The image only displays the process, but active task is not highlighted, how I can highlight the active task??

ProcessDefinitionEntity pde = (ProcessDefinitionEntity) ((RepositoryServiceImpl) getProcessEngine().getRepositoryService())
        .getDeployedProcessDefinition(selecetedProcessInstance.getProcessDefinitionId());

InputStream imageStream = ProcessDiagramGenerator.generatePngDiagram(pde);

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
Look at the code in the probe webapp. It has been done there.

h_ter_schuur
Champ in-the-making
Champ in-the-making
You can use the more generic generateDiagram(processDefinition, imageTime, highlightedActivities)

For example:ProcessDiagramGenerator.generateDiagram(pde, "png", getRuntimeService().getActiveActivityIds(selecetedProcessInstance.getId()))Best regards,

ahmetkara
Champ in-the-making
Champ in-the-making
Thank you very very much, I did with your helpss, thanks to you especially Hinse ter Schuur.

future_makers
Champ in-the-making
Champ in-the-making
HI,

I USED THIS CODE AND IT WORKING WITH ME

ActivitiServiceImpl activitiService = (ActivitiServiceImpl) ServiceFinder.getContext(request).getBean("activitiService");
RepositoryService repositoryService = activitiService.getRepositoryService();
ProcessDefinition processDef=repositoryService.createProcessDefinitionQuery().deploymentId(processId).
orderByProcessDefinitionVersion().desc().singleResult();
ProcessInstance processInstance=activitiService.getRuntimeService().startProcessInstanceById(processDef.getId());
ProcessDefinitionEntity pde = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(processDef.getId());
activitiService.getRuntimeService().getActiveActivityIds(processInstance.getId());
   if(pde!=null){
    InputStream imageStream=ProcessDiagramGenerator.generateDiagram(pde, "png", activitiService.getRuntimeService().getActiveActivityIds(processInstance.getId()));
    //InputStream imageStream=ProcessDiagramGenerator.generatePngDiagram(pde);
   
    BufferedInputStream input = null;
          BufferedOutputStream output = null;

          try {
              // Open streams.
              input = new BufferedInputStream(imageStream );
              output = new BufferedOutputStream(response.getOutputStream() );

              // Write file contents to response.
              byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
              int length;
              while ((length = input.read(buffer)) > 0) {
                  output.write(buffer, 0, length);
              }

          } finally {
              // Gently close streams.
              close(output);
              close(input);
          }

burn83
Champ in-the-making
Champ in-the-making
Hello to everybody…

I try to render a diagram with current status of my process highlited!!

But i have found same problem:

java.awt.image.RasterFormatException: (x + width) is outside raster
sun.awt.image.IntegerInterleavedRaster.createWritableChild(IntegerInterleavedRaster.java:467)
java.awt.image.BufferedImage.getSubimage(BufferedImage.java:1173)
org.activiti.engine.impl.bpmn.diagram.ProcessDiagramCanvas.generateImage(ProcessDiagramCanvas.java:173)
org.activiti.engine.impl.bpmn.diagram.ProcessDiagramGenerator.generateDiagram(ProcessDiagramGenerator.java:302)
org.apache.jsp.index_jsp._jspService(index_jsp.java:263)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)

etc….

My code is the follow:
//first part
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
                                                         .processDefinitionId(process_definition)
                                                         .singleResult();

List<String> s = runtimeService.getActiveActivityIds(processelected);

//now the second part..the line with the problem mentioned above..
InputStream imageStream_agg = ProcessDiagramGenerator.generateDiagram((ProcessDefinitionEntity)processDefinition, "png", s);

My version of Activiti is 5.10 … anybody can help me?!

Ps: the first part of this code is functionally, it loads correctly the image with no highlight…