I’d like to use jaxb2 to create my own BPMN xml and I’m having a small issue:
There are a number of XSDs referenced by the BPMN diagrams:
I’m able to generate the POJOs, except when I add in
activiti-bpmn-extensions-5.4.xsd (depending on which library I pull these out of there seem to be no difference)
When I add the extensions xsd to my list of XSDs to be picked up by jaxb2-maven (xjc)
I get the following exception when generating the pojos:
[ERROR] file:/C:/path/to/project/src/main/resources/flowable_xsd/activiti-bpmn-extensions-5.4.xsd [221,60]
com.sun.istack.SAXParseException2: Property "Expression" is already defined. Use <jaxb:property> to resolve this conflict.
and a little further down, it says:
[ERROR] file:/C:/path/to/project/src/main/resources/flowable_xsd/activiti-bpmn-extensions-5.4.xsd [225,76]
com.sun.istack.SAXParseException2: The following location is relevant to the above error
Has anyone done this before/any advice on resolving the issue?
Does this imply that I would have to build the entire flowable engine project in order to acess the features of this BPMNModel class?
No, the BpmnModel classes are part of the transitive dependencies of the flowable-engine module. So for example when using Maven, adding flowable-engine will automatically add these classes to your classpath.
Thanks, this helped a lot, after asking the question I looked into it a little bit more, for my purposes I’ll need to write the model back to XML after I’ve finished creating it.
This is when I found this method here: https://github.com/flowable/flowable-engine/blob/9af12c0df51ef9cb29e1cd05a1fb015f1a80a021/modules/flowable-bpmn-converter/src/test/java/org/flowable/editor/language/xml/AbstractConverterTest.java#L46
Which references https://github.com/flowable/flowable-engine/blob/master/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/BpmnXMLConverter.java
With that, I simply added a dependency for the BPMN Converter, which pulls BPMN model in as a compile dependency…https://mvnrepository.com/artifact/org.flowable/flowable-bpmn-converter/6.4.2
Now I have a test that looks like the following, where method createTwoTasksTestProcess() comes from the link you provided initially:
BpmnModel bpmnModel = createTwoTasksTestProcess();
byte xml = new BpmnXMLConverter().convertToXML(bpmnModel);
String stringXml = new String(xml);
I think I can work with this much easier from here unless you have any additional feedback or suggestions?