GraalVM does not discover DMN Camunda resources

264 views Asked by At

I am developing an application in Quarkus Framework that uses the embedded Camunda DMN engine, but I have problems in the native compilation using GraalVM.

The problem is that at runtime it is not able to find some XSD files that the camunda library does not place in the resources folder, it places them in a package as seen in the image.

Files XSD Camunda DMN

I used the command so that it will generate the configuration files during the execution of the application to be able to compile in native. $JAVA_HOME/bin/java -agentlib:native-image-agent=config-output-dir=native-config -jar target/quarkus-app/quarkus-run.jar

This generated the following structure in the resources-config.json file

{
    "resources":{
            "includes":[
                    {"pattern":"\\QMETA-INF/services/io.smallrye.config.ConfigSourceFactory\\E"}, 
                    {"pattern":"\\QMETA-INF/services/io.smallrye.config.SmallRyeConfigFactory\\E"}, 
                    {"pattern":"\\QMETA-INF/services/io.vertx.core.spi.BufferFactory\\E"}, 
                    {"pattern":"\\QMETA-INF/services/io.vertx.core.spi.FutureFactory\\E"}, 
                    {"pattern":"\\QMETA-INF/services/javax.script.ScriptEngineFactory\\E"}, 
                    {"pattern":"\\QMETA-INF/services/org.eclipse.microprofile.config.spi.ConfigSource\\E"}, 
                    {"pattern":"\\QMETA-INF/services/org.eclipse.microprofile.config.spi.Converter\\E"}, 
                    {"pattern":"\\Qapplication.properties\\E"}, 
                    {"pattern":"\\Qorg/camunda/bpm/model/dmn/schema/DMN11.xsd\\E"}, 
                    {"pattern":"\\Qorg/camunda/bpm/model/dmn/schema/DMN11_Alternative.xsd\\E"}, 
                    {"pattern":"\\Qorg/camunda/bpm/model/dmn/schema/DMN12.xsd\\E"}, 
                    {"pattern":"\\Qorg/camunda/bpm/model/dmn/schema/DMN13.xsd\\E"}, 
                    {"pattern":"\\Qorg/jboss/threads/Version.properties\\E"}
    ]},
    "bundles":[{"name":"com.sun.org.apache.xerces.internal.impl.xpath.regex.message"}]
}

As you can see, the access to resources is deduced with the pattern "\\Qorg/camunda/bpm/model/dmn/schema/DMN13.xsd\\E".

My resource configuration file looks like this

      {
    "bundles": [
      {
        "name": "com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages"
      },
      {
        "name":"com.sun.org.apache.xerces.internal.impl.xpath.regex.message"
      }
    ],
    "resources": {
      "includes": [
        {"pattern":"\\QMETA-INF/services/io.smallrye.config.ConfigSourceFactory\\E"},
        {"pattern":"\\QMETA-INF/services/io.smallrye.config.SmallRyeConfigFactory\\E"},
        {"pattern":"\\QMETA-INF/services/io.vertx.core.spi.FutureFactory\\E"},
        {"pattern":"\\QMETA-INF/services/javax.script.ScriptEngineFactory\\E"},
        {"pattern":"\\QMETA-INF/services/org.eclipse.microprofile.config.spi.ConfigSource\\E"},
        {"pattern":"\\QMETA-INF/services/org.eclipse.microprofile.config.spi.Converter\\E"},
        {"pattern":"\\Qapplication.properties\\E"},
        {"pattern":"\\Qorg/camunda/bpm/model/dmn/schema/DMN11.xsd\\E"},
        {"pattern":"\\Qorg/camunda/bpm/model/dmn/schema/DMN11_Alternative.xsd\\E"},
        {"pattern":"\\Qorg/camunda/bpm/model/dmn/schema/DMN12.xsd\\E"},
        {"pattern":"\\Qorg/camunda/bpm/model/dmn/schema/DMN13.xsd\\E"},
        {"pattern":"\\Qorg/jboss/threads/Version.properties\\E"}
      ]
    }
  }

When compiling the quarkus application natively with the command ./mvnw package -Pnative.

This generates the native executable and perform the deployment well, but when I make a request which uses camunda it generates the error

    Caused by: org.camunda.bpm.model.dmn.DmnModelException: Unable to parse model
  at org.camunda.bpm.model.dmn.impl.DmnParser.parseModelFromStream(DmnParser.java:79)
  at org.camunda.bpm.model.dmn.Dmn.doReadModelFromInputStream(Dmn.java:245)
  at org.camunda.bpm.model.dmn.Dmn.readModelFromStream(Dmn.java:158)
  at org.camunda.bpm.dmn.engine.impl.transform.DefaultDmnTransform.setModelInstance(DefaultDmnTransform.java:111)
  ... 33 more
Caused by: org.camunda.bpm.model.xml.ModelParseException: SAXException while parsing input stream
  at org.camunda.bpm.model.xml.impl.util.DomUtil.parseInputStream(DomUtil.java:245)
  at org.camunda.bpm.model.xml.impl.parser.AbstractModelParser.parseModelFromStream(AbstractModelParser.java:131)
  at org.camunda.bpm.model.dmn.impl.DmnParser.parseModelFromStream(DmnParser.java:76)
  ... 36 more
Caused by: org.xml.sax.SAXException: Error: URI=null Line=1: schema_reference.4: Failed to read schema document 'jar:file:/home/jonathanch/Documents/workspace/trabajo/servicio-motor/target/servicio-motor-1.0.0-SNAPSHOT-native-image-source-jar/lib/org.camunda.bpm.model.camunda-dmn-model-7.14.0.jar!/org/camunda/bpm/model/dmn/schema/DMN13.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
  at org.camunda.bpm.model.xml.impl.util.DomUtil$DomErrorHandler.error(DomUtil.java:202)
  at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:138)
  at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396)
  at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:306)
  at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaErr(XSDHandler.java:4257)
  at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaError(XSDHandler.java:4240)
  at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument1(XSDHandler.java:2531)
  at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument(XSDHandler.java:2238)
  at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:588)
  at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.processJAXPSchemaSource(XMLSchemaLoader.java:844)
  at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:606)
  at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.findSchemaGrammar(XMLSchemaValidator.java:2710)
  at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:2069)
  at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:829)
  at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:374)
  at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:613)
  at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3063)
  at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:836)
  at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605)
  at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)
  at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:534)
  at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:888)
  at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:824)
  at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
  at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:246)
  at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
  at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:122)
  at org.camunda.bpm.model.xml.impl.util.DomUtil.parseInputStream(DomUtil.java:240)

Checking the path to the file, I see that in the jar are the files. What is the error? Here I get into the confusion of how GraalVM discovers resources and how the pattern should be written to include resources at compile time.

I have also tried with the pattern {"pattern":".*/DMN1.*xsd$"}, but the problem persists.

Note:

This is the trace of accesses to those resources generated in the execution of the application with the command $JAVA_HOME/bin/java -agentlib:native-image-agent=trace-output=native-config/trace-file.json -jar target/quarkus-app/quarkus-run.jar

      [...{"caller_class":"java.util.Arrays", "result":true, "args":["[Ljava.lang.Class;"], "function":"newInstance", "tracer":"reflect", "class":"java.lang.reflect.Array"},
  {"caller_class":"java.lang.invoke.InnerClassLambdaMetafactory", "result":true, "args":["get$Lambda",["java.io.File"]], "function":"findMethodHandle", "tracer":"reflect", "class":"jdk.xml.internal.SecuritySupport$$Lambda$258/0x0000000840325840"},
  {"caller_class":"org.camunda.bpm.model.xml.impl.util.ReflectUtil", "result":true, "args":["org/camunda/bpm/model/dmn/schema/DMN13.xsd"], "function":"getResource", "tracer":"reflect", "class":"io.quarkus.bootstrap.runner.RunnerClassLoader"},
  {"caller_class":"java.lang.ClassLoader", "result":false, "args":["org/camunda/bpm/model/dmn/schema/DMN13.xsd"], "function":"getResource", "tracer":"reflect", "class":"jdk.internal.loader.ClassLoaders$AppClassLoader"},
  {"caller_class":"java.lang.ClassLoader", "result":false, "args":["org/camunda/bpm/model/dmn/schema/DMN13.xsd"], "function":"getResource", "tracer":"reflect", "class":"jdk.internal.loader.ClassLoaders$PlatformClassLoader"},
  {"caller_class":"org.camunda.bpm.model.xml.impl.util.ReflectUtil", "result":true, "args":["org/camunda/bpm/model/dmn/schema/DMN12.xsd"], "function":"getResource", "tracer":"reflect", "class":"io.quarkus.bootstrap.runner.RunnerClassLoader"},
  {"caller_class":"java.lang.ClassLoader", "result":false, "args":["org/camunda/bpm/model/dmn/schema/DMN12.xsd"], "function":"getResource", "tracer":"reflect", "class":"jdk.internal.loader.ClassLoaders$AppClassLoader"},
  {"caller_class":"java.lang.ClassLoader", "result":false, "args":["org/camunda/bpm/model/dmn/schema/DMN12.xsd"], "function":"getResource", "tracer":"reflect", "class":"jdk.internal.loader.ClassLoaders$PlatformClassLoader"},
  {"caller_class":"org.camunda.bpm.model.xml.impl.util.ReflectUtil", "result":true, "args":["org/camunda/bpm/model/dmn/schema/DMN11.xsd"], "function":"getResource", "tracer":"reflect", "class":"io.quarkus.bootstrap.runner.RunnerClassLoader"},
  {"caller_class":"java.lang.ClassLoader", "result":false, "args":["org/camunda/bpm/model/dmn/schema/DMN11.xsd"], "function":"getResource", "tracer":"reflect", "class":"jdk.internal.loader.ClassLoaders$AppClassLoader"},
  {"caller_class":"java.lang.ClassLoader", "result":false, "args":["org/camunda/bpm/model/dmn/schema/DMN11.xsd"], "function":"getResource", "tracer":"reflect", "class":"jdk.internal.loader.ClassLoaders$PlatformClassLoader"},
  {"caller_class":"org.camunda.bpm.model.xml.impl.util.ReflectUtil", "result":true, "args":["org/camunda/bpm/model/dmn/schema/DMN11_Alternative.xsd"], "function":"getResource", "tracer":"reflect", "class":"io.quarkus.bootstrap.runner.RunnerClassLoader"},
  {"caller_class":"java.lang.ClassLoader", "result":false, "args":["org/camunda/bpm/model/dmn/schema/DMN11_Alternative.xsd"], "function":"getResource", "tracer":"reflect", "class":"jdk.internal.loader.ClassLoaders$AppClassLoader"},
  {"caller_class":"java.lang.ClassLoader", "result":false, "args":["org/camunda/bpm/model/dmn/schema/DMN11_Alternative.xsd"], "function":"getResource", "tracer":"reflect", "class":"jdk.internal.loader.ClassLoaders$PlatformClassLoader"},
  {"caller_class":"java.util.Arrays", "result":true, "args":["[Ljava.lang.Class;"], "function":"newInstance", "tracer":"reflect", "class":"java.lang.reflect.Array"}...]

This is how amunda accesses resources: Acces 1

Acces 2

I clarify that GraalVM is reading the configuration file created because it takes the configuration of "bundles".

0

There are 0 answers