Giter VIP home page Giter VIP logo

camunda-spin's Introduction

camunda-spin

Home | Documentation | Forum | Issues | License | Contribute

Library for simple XML and JSON processing on the JVM (Java Virtual Machine), targeting Java and JVM-based scripting languages such as Groovy, JRuby, Jython, Javascript and Java Expression Language.

Why Spin?

Spin is useful when you need to work with complex, text-based data formats (such as XML or JSON) without mapping to Java Objects.

Spin provides a comprehensible fluent API for working with different data formats through lightweight wrapper objects:

Given the following XML document as String or InputStream:

<?xml version=“1.0“ encoding=“UTF-8“ ?>
<customers>
  <customer id="0001"><name>Jonny P</name></customer>
  <customer id="0002"><name>Bobby G</name></customer>
  <customer id="0003"><name>Mary T</name></customer>
</customers>

It can directly be worked on with Spin:

import static org.camunda.spin.Spin.*;

// get id of first customer
XML( xmlInput ).childElements("customer")
  .get(0)
  .attr("id")
  .value();

// create new customer
SpinXmlTreeElement  kate = XML( "<customer />" )
  .attr("id", "0004")
  .append( XML("<name>Kate S</name>") );

// append to existing list
XML( xmlInput ).append(kate);

// query by Id:
XML( xmlInput ).xPath("/customers/customer[@id='0002']").element();

FAQ

Why should I use Spin instead of the Java DOM API?

Java provides a built-in Dom API along with a Parser. Spin provides a lightweight Wrapper around the Dom API which makes it easier to work with than the Dom API. You can access the underlying Dom object at any time by unwrapping it:

Element e = XML( xmlSource ).childElement("customer").unwrap();

Contributing

Have a look at our contribution guide for how to contribute to this repository.

License:

The source files in this repository are made available under the Apache License Version 2.0.

camunda-spin's People

Contributors

attoken avatar berndruecker avatar cmur2 avatar danielkelemen avatar dependabot-preview[bot] avatar dependabot-support avatar hawky-4s- avatar ingorichtsmeier avatar jomu78 avatar koevskinikola avatar marstamm avatar mboskamp avatar mburke84 avatar menski avatar meyerdan avatar nfehringvhv avatar psavidis avatar rasmusfaber avatar rbraeunlich avatar romansmirnov avatar sdorokhova avatar shannoncolavita avatar stefanzilske avatar tasso94 avatar thorbenlindhauer avatar tmetzke avatar venetrius avatar yanavasileva avatar zambrovski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

camunda-spin's Issues

mapping XML to POJO when elements are fully namespaced

When trying to map this simple XML to a POJO:
String str = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<Response xmlns:cal=\"http://www.calculator.com/CalculateNetAmount\">" + "<cal:field>stringField</cal:field>" + "<cal:error>stringError</cal:error>" + "</Response >";
when using Spin's mapTo method ( Response responseObj = XML(str).mapTo(Response .class) ), the resulting objects fields "field" and "error" are empty/null , but if I use JAXB's unmarshall()
( Response responseObj= JAXB.unmarshal(new StringReader(str), Response.class) ) it works as expected.
Note: if i remove the inner elements namespace both work as expected

Update json-path dependency

spin-dataformat-json-jackson depends on json-path 0.9.1 (from 2013), and the latest version is 2.0.0 can you please update to a newer version? It cannot be overridden due to SPI breakage.

SPIN/DOM-XML-01004 Parsing input into DOM document.

Hi,

I am unable to parse the below XML. To be precise, I've implemented my own DataFormatConfigurator and set NamespaceAware to false to ignore namespaces. It works fine without <a:WorkflowTemplateId i:nil="true" />. From the debug logs, I can confirm that the DocumentBuilderFactory is using the custom configuration to ignore namespace.

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <JobResponse xmlns="http://schemas.example.com/digital/v5.00">
         <JobResult xmlns:a="http://schemas.datacontract.org/DataContracts.BackwardsCompatibility.v500" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
            <a:CostCode>1724</a:CostCode>
            <a:ID>8115548</a:ID>
            <a:State>Completed</a:State>
            <a:Tasks>
               <a:Task>
                  <a:ID>73235022</a:ID>
                  <a:ItemID>1281863</a:ItemID>
                  <a:TypeID>31</a:TypeID>
                  <a:WorkflowTemplateId i:nil="true" />
               </a:Task>
               <a:Task>
                  <a:ID>73235023</a:ID>
                  <a:ItemID>1281864</a:ItemID>
                  <a:TypeID>4</a:TypeID>
                  <a:WorkflowTemplateId i:nil="true" />
               </a:Task>
               <a:Task>
                  <a:ID>73235024</a:ID>
                  <a:ItemID>1281865</a:ItemID>
                  <a:TypeID>4</a:TypeID>
                  <a:WorkflowTemplateId i:nil="true" />
               </a:Task>
            </a:Tasks>
         </JobResult>
      </JobResponse>
   </s:Body>
</s:Envelope>

Attaching sample code to test:

public class SampleClass {
    private static final Logger LOGGER = LoggerFactory.getLogger(SampleClass.class);

    public static void main(String[] args) {
        String str = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
                + "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
                + "   <s:Body>\n"
                + "      <JobResponse xmlns=\"http://schemas.example.com/digital/v5.00\">\n"
                + "         <JobResult xmlns:a=\"http://schemas.datacontract.org/DataContracts.BackwardsCompatibility.v500\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">\n"
                + "            <a:CostCode>0000</a:CostCode>\n"
                + "            <a:ID>8115548</a:ID>\n"
                + "            <a:Notes i:nil=\"true\" />\n"
                + "            <a:State>Completed</a:State>\n"
                + "            <a:Tasks>\n"
                + "               <a:Task>\n"
                + "                  <a:ID>73235022</a:ID>\n"
                + "                  <a:ItemID>1281863</a:ItemID>\n"
                + "                  <a:TypeID>31</a:TypeID>\n"
                + "               <a:WorkflowTemplateId i:nil=\"true\" />\n"
                + "               </a:Task>\n"
                + "               <a:Task>\n"
                + "                  <a:ID>73235023</a:ID>\n"
                + "                  <a:ItemID>1281864</a:ItemID>\n"
                + "                  <a:TypeID>4</a:TypeID>\n"
                + "                  <a:WorkflowTemplateId i:nil=\"true\" />\n"
                + "               </a:Task>\n"
                + "               <a:Task>\n"
                + "                  <a:ID>73235024</a:ID>\n"
                + "                  <a:ItemID>1281865</a:ItemID>\n"
                + "                  <a:TypeID>4</a:TypeID>\n"
                + "                  <a:WorkflowTemplateId i:nil=\"true\" />\n"
                + "               </a:Task>\n"
                + "            </a:Tasks>\n"
                + "         </JobResult>\n"
                + "      </JobResponse>\n"
                + "   </s:Body>\n"
                + "</s:Envelope>";

        SpinXmlElement spinXmlElement = Spin.XML(str).xPath("//JobResponse/JobResult/ID").element();
        LOGGER.info("ID = {}", spinXmlElement.textContent()); // works as expected

        SpinList<SpinXmlElement> spinXmlElementSpinList = Spin.XML(str).xPath("//JobResponse/JobResult/Tasks/Task[TypeID=4]").elementList(); // throws exception. pasting logs below
        LOGGER.info("spinXmlElementSpinList = {}", spinXmlElementSpinList);
    }
}

Logs:

16:27:45.661 [main] INFO org.camunda.spin - SPIN-01010 Discovered Spin data format provider: org.camunda.spin.impl.json.jackson.format.JacksonJsonDataFormatProvider[name = application/json]
16:27:46.053 [main] INFO org.camunda.spin - SPIN-01010 Discovered Spin data format provider: org.camunda.spin.impl.xml.dom.format.DomXmlDataFormatProvider[name = application/xml]
16:27:46.060 [main] DEBUG org.camunda.spin.xml - SPIN/DOM-XML-01003 DocumentBuilderFactory configuration 'namespaceAware' 'true'
16:27:46.060 [main] DEBUG org.camunda.spin.xml - SPIN/DOM-XML-01003 DocumentBuilderFactory configuration 'validating' 'false'
16:27:46.060 [main] DEBUG org.camunda.spin.xml - SPIN/DOM-XML-01003 DocumentBuilderFactory configuration 'ignoringComments' 'true'
16:27:46.060 [main] DEBUG org.camunda.spin.xml - SPIN/DOM-XML-01003 DocumentBuilderFactory configuration 'ignoringElementContentWhitespace' 'false'
16:27:46.066 [main] DEBUG org.camunda.spin.xml - SPIN/DOM-XML-01001 Using document builder factory 'com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl'
16:27:46.072 [main] INFO org.camunda.spin - SPIN-01011 Discovered Spin data format configurator: class com.sample.myworkflow.config.CustomXmlDataFormatter[dataformat = org.camunda.spin.impl.xml.dom.format.DomXmlDataFormat]
16:27:46.073 [main] DEBUG org.camunda.spin.xml - SPIN/DOM-XML-01003 DocumentBuilderFactory configuration 'namespaceAware' 'false'
16:27:46.074 [main] INFO org.camunda.spin - SPIN-01009 Discovered Spin data format: org.camunda.spin.impl.xml.dom.format.DomXmlDataFormat[name = application/xml]
16:27:46.074 [main] INFO org.camunda.spin - SPIN-01009 Discovered Spin data format: org.camunda.spin.impl.json.jackson.format.JacksonJsonDataFormat[name = application/json]
16:27:46.117 [main] DEBUG org.camunda.spin.xml - SPIN/DOM-XML-01002 Successfully created new document builder
16:27:46.117 [main] DEBUG org.camunda.spin.xml - SPIN/DOM-XML-01004 Parsing input into DOM document.
16:27:46.165 [main] INFO com.sample.myworkflow.utils.SampleClass - ID = 8115548
16:27:46.166 [main] DEBUG org.camunda.spin.xml - SPIN/DOM-XML-01002 Successfully created new document builder
16:27:46.166 [main] DEBUG org.camunda.spin.xml - SPIN/DOM-XML-01004 Parsing input into DOM document.
ERROR:  'Namespace for prefix 'i' has not been declared.'
SLF4J: Failed toString() invocation on an object of type [org.camunda.spin.impl.SpinListImpl]
Reported exception:
org.camunda.spin.xml.SpinXmlElementException: SPIN/DOM-XML-01022 Unable to transform element 'null:a:Task'
	at org.camunda.spin.impl.xml.dom.DomXmlLogger.unableToTransformElement(DomXmlLogger.java:127)
	at org.camunda.spin.impl.xml.dom.format.DomXmlDataFormatWriter.writeResult(DomXmlDataFormatWriter.java:56)
	at org.camunda.spin.impl.xml.dom.format.DomXmlDataFormatWriter.writeToWriter(DomXmlDataFormatWriter.java:47)
	at org.camunda.spin.impl.xml.dom.DomXmlElement.writeToWriter(DomXmlElement.java:373)
	at org.camunda.spin.impl.xml.dom.DomXmlElement.toString(DomXmlElement.java:368)
	at java.lang.String.valueOf(String.java:2994)
	at java.lang.StringBuilder.append(StringBuilder.java:131)
	at java.util.AbstractCollection.toString(AbstractCollection.java:462)
	at org.slf4j.helpers.MessageFormatter.safeObjectAppend(MessageFormatter.java:299)
	at org.slf4j.helpers.MessageFormatter.deeplyAppendParameter(MessageFormatter.java:271)
	at org.slf4j.helpers.MessageFormatter.arrayFormat(MessageFormatter.java:233)
	at org.slf4j.helpers.MessageFormatter.arrayFormat(MessageFormatter.java:173)
	at ch.qos.logback.classic.spi.LoggingEvent.getFormattedMessage(LoggingEvent.java:293)
	at ch.qos.logback.classic.spi.LoggingEvent.prepareForDeferredProcessing(LoggingEvent.java:206)
	at ch.qos.logback.core.OutputStreamAppender.subAppend(OutputStreamAppender.java:205)
	at ch.qos.logback.core.OutputStreamAppender.append(OutputStreamAppender.java:100)
	at ch.qos.logback.core.UnsynchronizedAppenderBase.doAppend(UnsynchronizedAppenderBase.java:84)
	at ch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:51)
	at ch.qos.logback.classic.Logger.appendLoopOnAppenders(Logger.java:270)
	at ch.qos.logback.classic.Logger.callAppenders(Logger.java:257)
	at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:421)
	at ch.qos.logback.classic.Logger.filterAndLog_1(Logger.java:398)
	at ch.qos.logback.classic.Logger.info(Logger.java:583)
	at com.sample.myworkflow.utils.SampleClass.main(SampleClass.java:54)
Caused by: javax.xml.transform.TransformerException: java.lang.RuntimeException: Namespace for prefix 'i' has not been declared.
	at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:746)
	at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:351)
	at org.camunda.spin.impl.xml.dom.format.DomXmlDataFormatWriter.writeResult(DomXmlDataFormatWriter.java:54)
	... 22 more
Caused by: java.lang.RuntimeException: Namespace for prefix 'i' has not been declared.
	at com.sun.org.apache.xml.internal.serializer.SerializerBase.getNamespaceURI(SerializerBase.java:915)
	at com.sun.org.apache.xml.internal.serializer.SerializerBase.addAttribute(SerializerBase.java:431)
	at com.sun.org.apache.xml.internal.serializer.ToUnknownStream.addAttribute(ToUnknownStream.java:316)
	at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:201)
	at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:230)
	at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:94)
	at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:693)
	at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:737)
	... 24 more
16:27:46.178 [main] INFO com.sample.myworkflow.utils.SampleClass - spinXmlElementSpinList = [FAILED toString()]

SPIN/DOM-XML-01035 - SpinXmlElement.elementList() fails on empty xml list

Used packages:
camunda-spin-core:1.3.1
camunda-spin-dataformat-all:1.3.1

When I call elementList() on an empty XML tag I expect the get an empty list.

In the following you find 4 calls:

XML("<?xml version=\"1.0\" encoding=\"UTF-8\"?><List><Item/></List>").xPath("//List/node()").elementList();
XML("<?xml version=\"1.0\" encoding=\"UTF-8\"?><List> </List>").xPath("//List/node()").elementList();
XML("<?xml version=\"1.0\" encoding=\"UTF-8\"?><List></List>").xPath("//List/node()").elementList();
XML("<?xml version=\"1.0\" encoding=\"UTF-8\"?><List/>").xPath("//List/node()").elementList();

The first is my reference and returns 1 element in the list.
Calls 2-4 are equal in XML semantics. The only difference is that Call 2 contains a whitespace between the tags.
However, only the second call returns an empty list. Call 3 & 4 throw a SpinXPath expression, even though the xPath call itself does not throw the error - elementList() throws the error.

org.camunda.spin.xml.SpinXPathException: SPIN/DOM-XML-01035 Unable to find XPath expression '//List/node()'

at org.camunda.spin.impl.xml.dom.DomXmlLogger.unableToFindXPathExpression(DomXmlLogger.java:176)
at org.camunda.spin.impl.xml.dom.util.DomXmlEnsure.ensureXPathNotEmpty(DomXmlEnsure.java:83)
at org.camunda.spin.impl.xml.dom.query.DomXPathQuery.elementList(DomXPathQuery.java:79)
at [my code]

java.lang.NoClassDefFoundError: Could not initialize class org.camunda.spin.SpinFactory

Hi

I try do use this, but I get in every case the error java.lang.NoClassDefFoundError: Could not initialize class org.camunda.spin.SpinFactory when I parse a json.

Code

package org.camunda.demo;

import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.camunda.spin.json.SpinJsonNode;
import static org.camunda.spin.Spin.*;

public class CheckWeatherDelegate implements JavaDelegate
{
    @Override
    public void execute(DelegateExecution execution) throws Exception
    {
        SpinJsonNode json = JSON("{\"customer\": \"Kermit\"}");
    }
}

Error

java.lang.NoClassDefFoundError: Could not initialize class org.camunda.spin.SpinFactory
	at org.camunda.spin.Spin.JSON(Spin.java:94)
	at org.camunda.demo.CheckWeatherDelegate.execute(CheckWeatherDelegate.java:13)
	at org.camunda.bpm.engine.impl.bpmn.delegate.JavaDelegateInvocation.invoke(JavaDelegateInvocation.java:40)
	at org.camunda.bpm.engine.impl.delegate.DelegateInvocation.proceed(DelegateInvocation.java:58)
	at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocationInContext(DefaultDelegateInterceptor.java:92)
	at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:63)
	at org.camunda.bpm.engine.impl.bpmn.behavior.ServiceTaskJavaDelegateActivityBehavior.execute(ServiceTaskJavaDelegateActivityBehavior.java:55)
	at org.camunda.bpm.engine.impl.bpmn.behavior.ServiceTaskJavaDelegateActivityBehavior.performExecution(ServiceTaskJavaDelegateActivityBehavior.java:44)
	at org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior.execute(TaskActivityBehavior.java:69)
	at org.camunda.bpm.engine.impl.bpmn.behavior.ClassDelegateActivityBehavior$1.call(ClassDelegateActivityBehavior.java:68)
	at org.camunda.bpm.engine.impl.bpmn.behavior.ClassDelegateActivityBehavior$1.call(ClassDelegateActivityBehavior.java:65)
	at org.camunda.bpm.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior.executeWithErrorPropagation(AbstractBpmnActivityBehavior.java:90)
	at org.camunda.bpm.engine.impl.bpmn.behavior.ClassDelegateActivityBehavior.execute(ClassDelegateActivityBehavior.java:65)
	at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute$2.callback(PvmAtomicOperationActivityExecute.java:61)
	at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute$2.callback(PvmAtomicOperationActivityExecute.java:50)
	at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.continueIfExecutionDoesNotAffectNextOperation(PvmExecutionImpl.java:2036)
	at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute.execute(PvmAtomicOperationActivityExecute.java:42)
	at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute.execute(PvmAtomicOperationActivityExecute.java:31)
	at org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:99)
	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:131)
	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:111)
	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:86)
	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:628)
	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:602)
	at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl$6.callback(PvmExecutionImpl.java:1975)
	at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl$6.callback(PvmExecutionImpl.java:1972)
	at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.continueExecutionIfNotCanceled(PvmExecutionImpl.java:2042)
	at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.dispatchDelayedEventsAndPerformOperation(PvmExecutionImpl.java:1991)
	at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.dispatchDelayedEventsAndPerformOperation(PvmExecutionImpl.java:1972)
	at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(PvmAtomicOperationTransitionNotifyListenerStart.java:60)
	at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(PvmAtomicOperationTransitionNotifyListenerStart.java:30)
	at org.camunda.bpm.engine.impl.core.operation.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:66)
	at org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:99)
	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:131)
	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:111)
	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:86)
	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:76)
	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:637)
	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:612)
	at org.camunda.bpm.engine.impl.core.operation.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:62)
	at org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:99)
	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:131)
	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:111)
	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:86)
	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:76)
	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:637)
	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:612)
	at org.camunda.bpm.engine.impl.core.operation.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:62)
	at org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:99)
	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:131)
	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:111)
	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:86)
	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:76)
	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:637)
	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:612)
	at org.camunda.bpm.engine.impl.core.operation.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:62)
	at org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:99)
	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:131)
	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:111)
	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:86)
	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:628)
	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:602)
	at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionCreateScope.scopeCreated(PvmAtomicOperationTransitionCreateScope.java:38)
	at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationCreateScope.execute(PvmAtomicOperationCreateScope.java:54)
	at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationCreateScope.execute(PvmAtomicOperationCreateScope.java:28)
	at org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:99)
	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:131)
	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:118)
	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext$1.call(CommandInvocationContext.java:102)
	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext$1.call(CommandInvocationContext.java:100)
	at org.camunda.bpm.engine.impl.context.ProcessApplicationClassloaderInterceptor.call(ProcessApplicationClassloaderInterceptor.java:48)
	at org.camunda.bpm.application.AbstractProcessApplication.execute(AbstractProcessApplication.java:121)
	at org.camunda.bpm.application.AbstractProcessApplication.execute(AbstractProcessApplication.java:132)
	at org.camunda.bpm.engine.impl.context.Context.executeWithinProcessApplication(Context.java:206)
	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:100)
	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:86)
	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:76)
	at org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler.execute(AsyncContinuationJobHandler.java:81)
	at org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler.execute(AsyncContinuationJobHandler.java:40)
	at org.camunda.bpm.engine.impl.persistence.entity.JobEntity.execute(JobEntity.java:133)
	at org.camunda.bpm.engine.impl.cmd.ExecuteJobsCmd.execute(ExecuteJobsCmd.java:110)
	at org.camunda.bpm.engine.impl.cmd.ExecuteJobsCmd.execute(ExecuteJobsCmd.java:43)
	at org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:28)
	at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:110)
	at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:70)
	at org.camunda.bpm.engine.impl.interceptor.CommandCounterInterceptor.execute(CommandCounterInterceptor.java:35)
	at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
	at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobHelper.executeJob(ExecuteJobHelper.java:57)
	at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobsRunnable.executeJob(ExecuteJobsRunnable.java:110)
	at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:71)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)

UTF-8 BOM in xml response causes SPIN-01004 No matching data format detected

Given an xml document that starts with a UTF-8 BOM the S(response) function is unable to detect the data format as xml. Using the XML(response) also fails. I tried S(response, "application/xml") in Groovy scripting context based on Java documentation but that failed with a different error indicating that no matching function with 2 arguments could be found.

I've fixed the service in question that was returning responses with a BOM but wanted to make you aware of this. Small example and partial stack trace from Camunda below with "PROCESSING RESPONSE" being me just doing println response. The BOM unicode code point is displayed as <U+FEFF> here but the raw byte representation is \xEB\xBB\xBF (which is correct for UTF-8)

PROCESSING RESPONSE: <U+FEFF><?xml version="1.0" encoding="utf-8"?><atom:entry xmlns:atom="http://www.w3.org/2005/Atom"><atom:id>3a61f702-f324-4966-ad65-7b1241aa4e2a</atom:id><atom:title>test</atom:title></atom:entry>
26-Oct-2018 14:43:58.544 SEVERE [http-nio-8080-exec-10] org.camunda.commons.logging.BaseLogger.logError ENGINE-16006 BPMN Stack Trace:
        Task_0994ntm (activity-execute, ProcessInstance[8fe78383-d92d-11e8-ad80-0242c0a80004])
        Task_0994ntm
          ^
          |
        StartEvent_1
          ^
          |
        Task_1hh1sqk, name=Create file set
          ^
          |
        Task_1ecoaqb
          ^
          |
        StartEvent_1

26-Oct-2018 14:43:58.545 SEVERE [http-nio-8080-exec-10] org.camunda.commons.logging.BaseLogger.logError ENGINE-16004 Exception while closing command context: Unable to evaluate script: org.camunda.spin.spi.SpinDataFormatException: SPIN-01004 No matching data format detected
 org.camunda.bpm.engine.ScriptEvaluationException: Unable to evaluate script: org.camunda.spin.spi.SpinDataFormatException: SPIN-01004 No matching data format detected
        at org.camunda.bpm.engine.impl.scripting.CompiledExecutableScript.evaluate(CompiledExecutableScript.java:57)
        at org.camunda.bpm.engine.impl.scripting.SourceExecutableScript.evaluate(SourceExecutableScript.java:57)
        at org.camunda.bpm.engine.impl.scripting.ExecutableScript.execute(ExecutableScript.java:59)

SpinJsonNode.lastIndexOf() does not work as documented when object is not found

I would like to check whether an element is present in a json-array.

SpinJsonNode.indexOf() is documented to throw if the object is not found, but SpinJsonNode.lastIndexOf() is documented to return -1 if the object is not found (in my opinion a much more usable behavior, but I guess there might be compatibility reasons to keep the other behavior?).

But
Spin.JSON("[\"foo\", \"bar\"]").lastIndexOf("baz");
throws with org.camunda.spin.json.SpinJsonPropertyException: SPIN/JACKSON-JSON-01004 Unable to find 'STRING', just like indexOf().

Spin ignores Jackson annotations

SSCCE:

package de.telekom.som.order.management;

import com.fasterxml.jackson.annotation.JsonProperty;
import org.assertj.core.api.Assertions;
import org.camunda.spin.Spin;
import org.junit.jupiter.api.Test;

public class SpinNotSupportingJacksonAnnotationsTest {

    @Test
    void why() {
        Dto dto = new Dto();
        dto.text = "value";
        String json = Spin.JSON(dto).toString();

        Assertions.assertThat(json).isEqualTo("{\"text\":\"value\"}");
    }
}

class Dto {
    @JsonProperty("i_want_to_rename_this")
    String text;

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }
}

When I use spinjar.com.fasterxml.jackson.annotation.JsonProperty then it works
Why do you shade Jackson?

Two packages for the same class ObjectMapper

I am trying to configure spin to serialize java.util.Date into the ISO 8601 format. During implementation I discoverd that the class ObjectMapper exists in two different packages:

  • spinjar.com.fasterxml.jackson.databind.ObjectMapper coming from camunda-spin-dataformat-all
  • com.fasterxml.jackson.databind.ObjectMapper coming from jackson-databind

Is there still a need for the spinjar version of the class? My IDE didn't find any usages of the class in the complete workspace.

Camunda spin doesn't recognise primitives in Javascript mode

According to the docs, camunda-spin should recognize primitives like booleans:

String values that represent JSON primitive values can also be read. For example, JSON("true") returns a SpinJsonNode that represents the boolean value true.

A bit down it states that in Javascript, you don't need to specify that it is a json, but you can just use S() to do this.

JSON can be read from script languages in the same way as from Java. Since script languages use dynamic typing, you do not need to hint the data format but you can use autodetection. The following example demonstrates how to read JSON in Javascript:
var customer = S('{"customer": "Kermit"}');

I'm using spin to parse the return value of a REST call in a camunda connector, this works fine if I return an object, but not when I return a primitive like a string or a boolean.

S('true')

I get the following error:

ENGINE-16004 Exception while closing command context: SPIN-01004 No matching data format detected

Stacktrace:

camunda_1         | 21-Mar-2018 16:09:45.896 SEVERE [http-nio-8080-exec-2] org.camunda.commons.logging.BaseLogger.logError ENGINE-16004 Exception while closing command context: SPIN-01004 No matching data format detected
camunda_1         |  org.camunda.spin.spi.SpinDataFormatException: SPIN-01004 No matching data format detected
camunda_1         | 	at org.camunda.spin.impl.logging.SpinCoreLogger.unrecognizableDataFormatException(SpinCoreLogger.java:53)
camunda_1         | 	at org.camunda.spin.impl.SpinFactoryImpl.createSpinFromReader(SpinFactoryImpl.java:127)
camunda_1         | 	at org.camunda.spin.impl.SpinFactoryImpl.createSpin(SpinFactoryImpl.java:50)
camunda_1         | 	at org.camunda.spin.impl.SpinFactoryImpl.createSpinFromString(SpinFactoryImpl.java:103)
camunda_1         | 	at org.camunda.spin.impl.SpinFactoryImpl.createSpin(SpinFactoryImpl.java:47)
camunda_1         | 	at org.camunda.spin.Spin.S(Spin.java:64)
camunda_1         | 	at jdk.nashorn.internal.scripts.Script$9$\^eval\_.:program(<eval>:18)
camunda_1         | 	at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:637)
camunda_1         | 	at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
camunda_1         | 	at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
camunda_1         | 	at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:449)
camunda_1         | 	at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:406)
camunda_1         | 	at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:402)
camunda_1         | 	at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155)
camunda_1         | 	at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:233)
camunda_1         | 	at org.camunda.bpm.engine.impl.scripting.SourceExecutableScript.evaluateScript(SourceExecutableScript.java:114)
camunda_1         | 	at org.camunda.bpm.engine.impl.scripting.SourceExecutableScript.evaluate(SourceExecutableScript.java:60)
camunda_1         | 	at org.camunda.bpm.engine.impl.scripting.ResourceExecutableScript.evaluate(ResourceExecutableScript.java:43)
camunda_1         | 	at org.camunda.bpm.engine.impl.scripting.ExecutableScript.execute(ExecutableScript.java:56)
camunda_1         | 	at org.camunda.bpm.engine.impl.scripting.env.ScriptingEnvironment.execute(ScriptingEnvironment.java:97)
camunda_1         | 	at org.camunda.bpm.engine.impl.scripting.env.ScriptingEnvironment.execute(ScriptingEnvironment.java:83)
camunda_1         | 	at org.camunda.bpm.engine.impl.delegate.ScriptInvocation.invoke(ScriptInvocation.java:40)
camunda_1         | 	at org.camunda.bpm.engine.impl.delegate.DelegateInvocation.proceed(DelegateInvocation.java:54)
camunda_1         | 	at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocationInContext(DefaultDelegateInterceptor.java:87)
camunda_1         | 	at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:59)
camunda_1         | 	at org.camunda.bpm.engine.impl.scripting.ScriptValueProvider.getValue(ScriptValueProvider.java:39)
camunda_1         | 	at org.camunda.bpm.engine.impl.core.variable.mapping.OutputParameter.execute(OutputParameter.java:43)
camunda_1         | 	at org.camunda.bpm.engine.impl.core.variable.mapping.IoParameter.execute(IoParameter.java:47)
camunda_1         | 	at org.camunda.bpm.engine.impl.core.variable.mapping.IoMapping.executeOutputParameters(IoMapping.java:41)
camunda_1         | 	at org.camunda.connect.plugin.impl.ServiceTaskConnectorActivityBehavior.applyOutputParameters(ServiceTaskConnectorActivityBehavior.java:84)
camunda_1         | 	at org.camunda.connect.plugin.impl.ServiceTaskConnectorActivityBehavior$1.call(ServiceTaskConnectorActivityBehavior.java:58)
camunda_1         | 	at org.camunda.connect.plugin.impl.ServiceTaskConnectorActivityBehavior$1.call(ServiceTaskConnectorActivityBehavior.java:51)
camunda_1         | 	at org.camunda.bpm.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior.executeWithErrorPropagation(AbstractBpmnActivityBehavior.java:108)
camunda_1         | 	at org.camunda.connect.plugin.impl.ServiceTaskConnectorActivityBehavior.execute(ServiceTaskConnectorActivityBehavior.java:51)
camunda_1         | 	at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute$2.callback(PvmAtomicOperationActivityExecute.java:57)
camunda_1         | 	at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute$2.callback(PvmAtomicOperationActivityExecute.java:46)
camunda_1         | 	at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.continueIfExecutionDoesNotAffectNextOperation(PvmExecutionImpl.java:1935)
camunda_1         | 	at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute.execute(PvmAtomicOperationActivityExecute.java:38)
camunda_1         | 	at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute.execute(PvmAtomicOperationActivityExecute.java:27)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:89)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:125)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:104)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:79)
camunda_1         | 	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:611)
camunda_1         | 	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:587)
camunda_1         | 	at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl$5.callback(PvmExecutionImpl.java:1874)
camunda_1         | 	at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl$5.callback(PvmExecutionImpl.java:1871)
camunda_1         | 	at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.continueExecutionIfNotCanceled(PvmExecutionImpl.java:1941)
camunda_1         | 	at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.dispatchDelayedEventsAndPerformOperation(PvmExecutionImpl.java:1890)
camunda_1         | 	at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.dispatchDelayedEventsAndPerformOperation(PvmExecutionImpl.java:1871)
camunda_1         | 	at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(PvmAtomicOperationTransitionNotifyListenerStart.java:57)
camunda_1         | 	at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(PvmAtomicOperationTransitionNotifyListenerStart.java:27)
camunda_1         | 	at org.camunda.bpm.engine.impl.core.operation.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:65)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:89)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:125)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:104)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:79)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:69)
camunda_1         | 	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:622)
camunda_1         | 	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:597)
camunda_1         | 	at org.camunda.bpm.engine.impl.core.operation.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:58)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:89)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:125)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:104)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:79)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:69)
camunda_1         | 	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:622)
camunda_1         | 	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:597)
camunda_1         | 	at org.camunda.bpm.engine.impl.core.operation.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:58)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:89)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:125)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:104)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:79)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:69)
camunda_1         | 	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:622)
camunda_1         | 	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:597)
camunda_1         | 	at org.camunda.bpm.engine.impl.core.operation.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:58)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:89)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:125)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:104)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:79)
camunda_1         | 	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:611)
camunda_1         | 	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:587)
camunda_1         | 	at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionCreateScope.scopeCreated(PvmAtomicOperationTransitionCreateScope.java:34)
camunda_1         | 	at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationCreateScope.execute(PvmAtomicOperationCreateScope.java:50)
camunda_1         | 	at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationCreateScope.execute(PvmAtomicOperationCreateScope.java:24)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:89)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:125)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:112)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext$1.call(CommandInvocationContext.java:95)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext$1.call(CommandInvocationContext.java:93)
camunda_1         | 	at org.camunda.bpm.engine.impl.context.ProcessApplicationClassloaderInterceptor.call(ProcessApplicationClassloaderInterceptor.java:44)
camunda_1         | 	at org.camunda.bpm.application.AbstractProcessApplication.execute(AbstractProcessApplication.java:114)
camunda_1         | 	at org.camunda.bpm.application.AbstractProcessApplication.execute(AbstractProcessApplication.java:125)
camunda_1         | 	at org.camunda.bpm.engine.impl.context.Context.executeWithinProcessApplication(Context.java:192)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:93)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:79)
camunda_1         | 	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:611)
camunda_1         | 	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:587)
camunda_1         | 	at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.start(PvmExecutionImpl.java:231)
camunda_1         | 	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.start(ExecutionEntity.java:432)
camunda_1         | 	at org.camunda.bpm.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:59)
camunda_1         | 	at org.camunda.bpm.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:31)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:104)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:66)
camunda_1         | 	at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)
camunda_1         | 	at org.camunda.bpm.engine.impl.ProcessInstantiationBuilderImpl.executeWithVariablesInReturn(ProcessInstantiationBuilderImpl.java:162)
camunda_1         | 	at org.camunda.bpm.engine.rest.sub.repository.impl.ProcessDefinitionResourceImpl.startProcessInstanceAtActivities(ProcessDefinitionResourceImpl.java:168)
camunda_1         | 	at org.camunda.bpm.engine.rest.sub.repository.impl.ProcessDefinitionResourceImpl.startProcessInstance(ProcessDefinitionResourceImpl.java:118)
camunda_1         | 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
camunda_1         | 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
camunda_1         | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
camunda_1         | 	at java.lang.reflect.Method.invoke(Method.java:498)
camunda_1         | 	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167)
camunda_1         | 	at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:257)
camunda_1         | 	at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:222)
camunda_1         | 	at org.jboss.resteasy.core.ResourceLocator.invokeOnTargetObject(ResourceLocator.java:159)
camunda_1         | 	at org.jboss.resteasy.core.ResourceLocator.invoke(ResourceLocator.java:107)
camunda_1         | 	at org.jboss.resteasy.core.ResourceLocator.invokeOnTargetObject(ResourceLocator.java:154)
camunda_1         | 	at org.jboss.resteasy.core.ResourceLocator.invoke(ResourceLocator.java:92)
camunda_1         | 	at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:542)
camunda_1         | 	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524)
camunda_1         | 	at org.jboss.resteasy.core.SynchronousDispatcher.invokePropagateNotFound(SynchronousDispatcher.java:169)
camunda_1         | 	at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:212)
camunda_1         | 	at org.jboss.resteasy.plugins.server.servlet.FilterDispatcher.doFilter(FilterDispatcher.java:59)
camunda_1         | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
camunda_1         | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
camunda_1         | 	at org.camunda.bpm.engine.rest.filter.CacheControlFilter.doFilter(CacheControlFilter.java:41)
camunda_1         | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
camunda_1         | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
camunda_1         | 	at org.camunda.bpm.engine.rest.filter.EmptyBodyFilter.doFilter(EmptyBodyFilter.java:95)
camunda_1         | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
camunda_1         | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
camunda_1         | 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
camunda_1         | 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
camunda_1         | 	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
camunda_1         | 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
camunda_1         | 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
camunda_1         | 	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
camunda_1         | 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
camunda_1         | 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
camunda_1         | 	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
camunda_1         | 	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
camunda_1         | 	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1527)
camunda_1         | 	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1484)
camunda_1         | 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
camunda_1         | 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
camunda_1         | 	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
camunda_1         | 	at java.lang.Thread.run(Thread.java:748)

[BUG] NullPointerException when trying to return variables

Hi,

When we try to get variables and one of them are of type List with null value(s), the engine throws a NullPointerException, leading to the impossibility of returning any variable.

The problem is happening in the following line:

This happens every time we save some variable with the value [null].

Could you guys add the validation to check if object is null before trying to get its class type?
Or instead add some validation to prevent persisting variables in that situation?

Thanks in advance,
Pedro Silva

Integration with groovy JsonSlurper

Hey, let me know if I should post this on the forum instead.

I would like to ask if it would be possible to to have groovy-specific integration with its JsonSlurper and possibly XMLSlurper as well?

Current syntax for manipulating json is very akward, all of this prop and xxxValue get in the way. This became extremely painful when we tried to use groovy string interpolation for templating with a json object.

Integration could look like simple .slurp method on the json object.

JDK 16 incompatibilities

I was quite used to seeing these type of messages with JDK 11,12,13,14,15 etc...

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by spinjar.com.sun.xml.bind.v2.runtime.reflect.opt.Injector$1 (file:/[snip]/.m2/repository/org/camunda/spin/camunda-spin-dataformat-all/1.10.0/camunda-spin-dataformat-all-1.10.0.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int)
WARNING: Please consider reporting this to the maintainers of spinjar.com.sun.xml.bind.v2.runtime.reflect.opt.Injector$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

but testing on JDK 16 it appears the threat in the last line about a "future release" appears to be this one, and the default has changed to deny rather than warn

Exception is now

Caused by: java.lang.ExceptionInInitializerError
	at spinjar.com.sun.xml.bind.v2.runtime.reflect.opt.AccessorInjector.prepare(AccessorInjector.java:83)
	at spinjar.com.sun.xml.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory.get(OptimizedAccessorFactory.java:125)
	at spinjar.com.sun.xml.bind.v2.runtime.reflect.Accessor$GetterSetterReflection.optimize(Accessor.java:399)
	at spinjar.com.sun.xml.bind.v2.runtime.property.SingleElementLeafProperty.<init>(SingleElementLeafProperty.java:87)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:78)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
	at spinjar.com.sun.xml.bind.v2.runtime.property.PropertyFactory.create(PropertyFactory.java:128)
	at spinjar.com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.<init>(ClassBeanInfoImpl.java:181)
	at spinjar.com.sun.xml.bind.v2.runtime.JAXBContextImpl.getOrCreate(JAXBContextImpl.java:509)
	at spinjar.com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.<init>(ClassBeanInfoImpl.java:168)
	at spinjar.com.sun.xml.bind.v2.runtime.JAXBContextImpl.getOrCreate(JAXBContextImpl.java:509)
	at spinjar.com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.<init>(ClassBeanInfoImpl.java:168)
	at spinjar.com.sun.xml.bind.v2.runtime.JAXBContextImpl.getOrCreate(JAXBContextImpl.java:509)
	at spinjar.com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:326)
	at spinjar.com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:141)
	at spinjar.com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1157)
        ...
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @4de4b452
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
	at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
	at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
	at spinjar.com.sun.xml.bind.v2.runtime.reflect.opt.Injector$1.run(Injector.java:177)
	at spinjar.com.sun.xml.bind.v2.runtime.reflect.opt.Injector$1.run(Injector.java:174)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
	at spinjar.com.sun.xml.bind.v2.runtime.reflect.opt.Injector.<clinit>(Injector.java:172)
	... 176 more

Tested with

% java --version
openjdk 16 2021-03-16
OpenJDK Runtime Environment (build 16+36-2231)
OpenJDK 64-Bit Server VM (build 16+36-2231, mixed mode, sharing)

To get Spin to work with JDK 16 now requires the following cli parameter

--add-opens java.base/java.lang=ALL-UNNAMED 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.