Error on use bmpn-js With Primefaces

Please guys,

I’m getting this error:

VM5197:73 could not import BPMN 2.0 diagram Error: invalid element specified
    at Overlays.add (<anonymous>:20845:12)
    at openDiagram (<anonymous>:61:22)
    at <anonymous>:81:9
    at p (<anonymous>:2:523)
    at Ja (<anonymous>:3:15829)
    at r.fn.init.append (<anonymous>:3:17100)
    at r.fn.init.<anonymous> (<anonymous>:3:18204)
    at T (<anonymous>:3:398)
    at r.fn.init.html (<anonymous>:3:17882)
    at Object.updateBody (core.js.xhtml?ln=primefaces&v=6.2:3)

When I try to put the modeler in my app.
Can anyone help me ?

The error in this part of code:

 overlays.add('SCAN_OK', 'note', {
		            position: {
		              bottom: 0,
		              right: 0
		            html: '<div class="diagram-note">Mixed up the labels?</div>'


Hi @Rodrigo_Borges and welcome to this forum!

When running

 overlays.add('SCAN_OK', 'note', {
		            position: {
		              bottom: 0,
		              right: 0
		            html: '<div class="diagram-note">Mixed up the labels?</div>'

=> this will try to add an overlay to the SCAN_OK element. In the diagram that you are rendering, is there actually an element with an ID SCAN_OK?


Hi Max,

In fact there is not an element named ‘SCAN_OK’.
It just have the div tag with “CANVAS” id, I think that all the content inside it would be created by the bpmn-js functions, but for some reason the element ‘SCAN_OK’ is not created.

Here is the full code:

<div id="canvas"></div>
		<script type="text/javascript">

				var diagramUrl = '';

		      // modeler instance
		      var bpmnModeler = new BpmnJS({
		        container: '#canvas',
		        keyboard: {
		          bindTo: window
		       * Save diagram contents and print them to the console.
		      async function exportDiagram() {
		        try {
		          var result = await bpmnModeler.saveXML({ format: true });
		          alert('Diagram exported. Check the developer tools!');
		          console.log('DIAGRAM', result.xml);
		        } catch (err) {
		          console.error('could not save BPMN 2.0 diagram', err);
		       * Open diagram in our modeler instance.
		       * @param {String} bpmnXML diagram to display
		      function openDiagram(bpmnXML) {
		        // import diagram
		        try {
		          // access modeler components
		          var canvas = bpmnModeler.get('canvas');
		          var overlays = bpmnModeler.get('overlays');
		          // zoom to fit full viewport
		          // attach an overlay to a node
		          overlays.add('SCAN_OK', 'note', {
		            position: {
		              bottom: 0,
		              right: 0
		            html: '<div class="diagram-note">Mixed up the labels?</div>'
		          // add marker
		          canvas.addMarker('SCAN_OK', 'needs-discussion');
		        } catch (err) {
		          console.error('could not import BPMN 2.0 diagram', err);
		      // load external diagram file via AJAX and open it
		      // wire save button

Thanks for the help!

There are some issue in the code:

  1. You need to fetch the XML from the diagram url first. (see an example here)
  2. bpmnModeler.importXML(...) returns a Promise and should be handled accordingly (ie. use await or .then
  3. As stated before, there is no element with ID=SCAN_OK, so the framework cannot add an overlay.

I fixed these issues briefly, please see here:


Thanks for your help,

I was making like that, but the the process just didnt show, and no error or alert in the console.

E change the code again and now its getting this error:

could not import BPMN 2.0 diagram Error: unparsable content detected
	line: 0
	column: 0
	nested error: missing start tag
    at error$1 (bpmn-modeler.development.js.xhtml?ln=assets:7976)
    at handleError (bpmn-modeler.development.js.xhtml?ln=assets:8618)
    at handleError (bpmn-modeler.development.js.xhtml?ln=assets:7028)
    at parse (bpmn-modeler.development.js.xhtml?ln=assets:7604)
    at Parser.parse (bpmn-modeler.development.js.xhtml?ln=assets:7133)
    at bpmn-modeler.development.js.xhtml?ln=assets:8786
    at new Promise (<anonymous>)
    at Reader.fromXML (bpmn-modeler.development.js.xhtml?ln=assets:8781)
    at BpmnModdle.fromXML (bpmn-modeler.development.js.xhtml?ln=assets:9722)
    at bpmn-modeler.development.js.xhtml?ln=assets:14142

Appears that its not reading the content of the bpmn diagram. How can it happens ?
The diagram is ok and accessible.
The project jquery version is v3.2.1, can it be the problem ?



you need to pass the actual BPMN XML as string to the import function. It appears that you are just passing it the link to it.
You need to first read the actual BPMN XML from that url. See this example: or this snippet (without any error handling whatsoever, just to show the idea):

const response = await fetch('');
const diagramXML = await response.text();



1 Like


It Works like a charm!