Insert a process definition with SQL

Hi everyone.
I need to store a process definition into the database from a sequence of SQLs. At MySQL I don’t have any problem, just some inserts (into ACT_RE_PROCDEF, ACT_RE_DEPLOYMENT, ACT_GE_BYTEARRAY), but at MsSql I am not able to insert the process into ACT_GE_BYTEARRAY in the correct format. Could you help me?
At mysql insert de XML of the process definition into BYTE_ works OK.

At MsSql nothing work, cast str as VARBINAY(MAX), cast str as IMAGE, etc.

Someone has tried?

Thanks in advance.

Error is:

org.camunda.bpm.engine.ProcessEngineException: ENGINE-03023 Could not load BPMN Model for process definition with id ‘demo:1:3’.
at org.camunda.bpm.engine.impl.db.EnginePersistenceLogger.loadModelException(EnginePersistenceLogger.java:260)
at org.camunda.bpm.engine.impl.persistence.deploy.DeploymentCache.loadAndCacheBpmnModelInstance(DeploymentCache.java:233)
at org.camunda.bpm.engine.impl.persistence.deploy.DeploymentCache.findBpmnModelInstanceForProcessDefinition(DeploymentCache.java:206)
at org.camunda.bpm.engine.impl.ProcessDefinitionQueryImpl.addProcessDefinitionToCacheAndRetrieveDocumentation(ProcessDefinitionQueryImpl.java:318)
at org.camunda.bpm.engine.impl.ProcessDefinitionQueryImpl.executeList(ProcessDefinitionQueryImpl.java:309)
at org.camunda.bpm.engine.impl.AbstractQuery.evaluateExpressionsAndExecuteList(AbstractQuery.java:186)
at org.camunda.bpm.engine.impl.AbstractQuery.execute(AbstractQuery.java:165)
at org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:104)
at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:66)
at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)
at org.camunda.bpm.engine.impl.AbstractQuery.list(AbstractQuery.java:139)
at com.mycompany.testcamunda.MainTest.listProcessDefinitions(MainTest.java:116)
at com.mycompany.testcamunda.MainTest.main(MainTest.java:36)
Caused by: org.camunda.bpm.model.xml.ModelParseException: IOException while parsing input stream
at org.camunda.bpm.model.xml.impl.util.DomUtil.parseInputStream(DomUtil.java:244)
at org.camunda.bpm.model.xml.impl.parser.AbstractModelParser.parseModelFromStream(AbstractModelParser.java:65)
at org.camunda.bpm.model.bpmn.impl.BpmnParser.parseModelFromStream(BpmnParser.java:61)
at org.camunda.bpm.model.bpmn.Bpmn.doReadModelFromInputStream(Bpmn.java:234)
at org.camunda.bpm.model.bpmn.Bpmn.readModelFromStream(Bpmn.java:125)
at org.camunda.bpm.engine.impl.persistence.deploy.DeploymentCache.loadAndCacheBpmnModelInstance(DeploymentCache.java:229)
… 12 more
Caused by: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 2 of 4-byte UTF-8 sequence.
at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(UTF8Reader.java:701)

Make sure the BLOBs that contain the process definition XML are correctly UTF-8-encoded when you insert them. According to the exception this is not the case.

Thanks for you answer.

Well, it seems to be OK (UTF-8). The process content is not in a file, I need it in the same sentence.

This is an example. Do you have some other clue? I keep investigating meanwhile…

update ACT_GE_BYTEARRAY  set bytes_ = 
    CAST('<?xml version="1.0" encoding="UTF-8"?> <bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.7.2"> <bpmn:process id="demo" name="Demo" isClosed="false" isExecutable="true" camunda:versionTag="1"> <bpmn:startEvent id="inicio" name="Inicio"> <bpmn:outgoing>SequenceFlow_18t0i75</bpmn:outgoing> </bpmn:startEvent> <bpmn:userTask id="enEjecucion" name="En ejecución" camunda:candidateGroups="10000,10001"> <bpmn:incoming>SequenceFlow_18t0i75</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1mk2slu</bpmn:outgoing> </bpmn:userTask> <bpmn:sequenceFlow id="SequenceFlow_18t0i75" sourceRef="inicio" targetRef="enEjecucion" /> <bpmn:exclusiveGateway id="ExclusiveGateway_0qmslys"> <bpmn:incoming>SequenceFlow_1mk2slu</bpmn:incoming> <bpmn:outgoing>rechazar</bpmn:outgoing> <bpmn:outgoing>aceptar</bpmn:outgoing> </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_1mk2slu" sourceRef="enEjecucion" targetRef="ExclusiveGateway_0qmslys" /> <bpmn:endEvent id="aceptado" name="Aceptado"> <bpmn:incoming>SequenceFlow_12ktbww</bpmn:incoming> </bpmn:endEvent> <bpmn:endEvent id="rechazado" name="Rechazado"> <bpmn:incoming>SequenceFlow_0gd6rpt</bpmn:incoming> <bpmn:errorEventDefinition errorRef="Error_07g0lf5" /> </bpmn:endEvent> <bpmn:sequenceFlow id="rechazar" name="Rechazar" sourceRef="ExclusiveGateway_0qmslys" targetRef="Task_0knb9w2"> <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${action == ''rechazar''}]]></bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:sequenceFlow id="aceptar" name="Aceptar" sourceRef="ExclusiveGateway_0qmslys" targetRef="Task_0xnr1oc"> <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${action == ''aceptar''}]]></bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:serviceTask id="Task_0xnr1oc" camunda:class="com.technisys.omnichannel.core.bpm.servicetasks.FinishTransaction"> <bpmn:incoming>aceptar</bpmn:incoming> <bpmn:outgoing>SequenceFlow_12ktbww</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_12ktbww" sourceRef="Task_0xnr1oc" targetRef="aceptado" /> <bpmn:serviceTask id="Task_0knb9w2" camunda:class="com.technisys.omnichannel.core.bpm.servicetasks.CancelTransaction"> <bpmn:incoming>rechazar</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0gd6rpt</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0gd6rpt" sourceRef="Task_0knb9w2" targetRef="rechazado" /> </bpmn:process> <bpmn:error id="Error_07g0lf5" name="Rechazado" errorCode="rechazado" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="demo"> <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="inicio"> <dc:Bounds x="167" y="110" width="36" height="36" /> <bpmndi:BPMNLabel> <dc:Bounds x="172" y="146" width="26" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="UserTask_1vng2m0_di" bpmnElement="enEjecucion"> <dc:Bounds x="363" y="88" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_18t0i75_di" bpmnElement="SequenceFlow_18t0i75"> <di:waypoint xsi:type="dc:Point" x="203" y="128" /> <di:waypoint xsi:type="dc:Point" x="286" y="128" /> <di:waypoint xsi:type="dc:Point" x="286" y="128" /> <di:waypoint xsi:type="dc:Point" x="363" y="128" /> <bpmndi:BPMNLabel> <dc:Bounds x="301" y="121.5" width="0" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ExclusiveGateway_0qmslys_di" bpmnElement="ExclusiveGateway_0qmslys" isMarkerVisible="true"> <dc:Bounds x="598" y="103" width="50" height="50" /> <bpmndi:BPMNLabel> <dc:Bounds x="623" y="156" width="0" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1mk2slu_di" bpmnElement="SequenceFlow_1mk2slu"> <di:waypoint xsi:type="dc:Point" x="463" y="128" /> <di:waypoint xsi:type="dc:Point" x="598" y="128" /> <bpmndi:BPMNLabel> <dc:Bounds x="530.5" y="106" width="0" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_0f4uktx_di" bpmnElement="aceptado"> <dc:Bounds x="865" y="44" width="36" height="36" /> <bpmndi:BPMNLabel> <dc:Bounds x="860" y="83" width="47" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_0xy6go4_di" bpmnElement="rechazado"> <dc:Bounds x="865" y="191" width="36" height="36" /> <bpmndi:BPMNLabel> <dc:Bounds x="855" y="230" width="56" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_18qjkrc_di" bpmnElement="rechazar"> <di:waypoint xsi:type="dc:Point" x="623" y="153" /> <di:waypoint xsi:type="dc:Point" x="623" y="205" /> <di:waypoint xsi:type="dc:Point" x="713" y="207" /> <bpmndi:BPMNLabel> <dc:Bounds x="638.2947862313379" y="215.87721759206383" width="48" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_01odod8_di" bpmnElement="aceptar"> <di:waypoint xsi:type="dc:Point" x="623" y="103" /> <di:waypoint xsi:type="dc:Point" x="623" y="62" /> <di:waypoint xsi:type="dc:Point" x="713" y="62" /> <bpmndi:BPMNLabel> <dc:Bounds x="638.8373914469487" y="37.00002784612868" width="39" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0rqf8n9_di" bpmnElement="Task_0xnr1oc"> <dc:Bounds x="713" y="22" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_12ktbww_di" bpmnElement="SequenceFlow_12ktbww"> <di:waypoint xsi:type="dc:Point" x="813" y="62" /> <di:waypoint xsi:type="dc:Point" x="865" y="62" /> <bpmndi:BPMNLabel> <dc:Bounds x="839" y="40.5" width="0" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_044rx2r_di" bpmnElement="Task_0knb9w2"> <dc:Bounds x="713" y="169" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0gd6rpt_di" bpmnElement="SequenceFlow_0gd6rpt"> <di:waypoint xsi:type="dc:Point" x="813" y="209" /> <di:waypoint xsi:type="dc:Point" x="865" y="209" /> <bpmndi:BPMNLabel> <dc:Bounds x="839" y="187" width="0" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions>' 
    AS IMAGE)

I tried varbinary(max) too, same result.

You were right thorben. There is one invalid char at XML (á). Thanks for your time

Greetings