it-at-m / digiwf-core

central workflow automation and integration platform based on the free process framework Camunda.
MIT License
19 stars 7 forks source link

GraalVM Integration #1703

Closed markostreich closed 3 months ago

markostreich commented 4 months ago

Is your feature request related to a problem? Please describe.

Als Plattformbetreiber möchte ich die Kosten der Plattform möglichst reduzieren. Dafür testen wir die Einsetzbarkeit von GraalVM an einem Integrationsservice aus.

Describe the solution you'd like

Acceptance Criteria

Time Box

3 PT

Addition Context

github-actions[bot] commented 4 months ago

👋 Thanks for reporting! The maintainers have been notified and will get back to you.

simonhir commented 3 months ago

There a two ways to build a native image/executable under Spring:

Via spring-boot-maven-plugin

Builds complete docker image.

By extending the already existing build step with spring-boot-maven-plugin like following:

``` org.springframework.boot spring-boot-maven-plugin ${spring-boot.version} true --initialize-at-build-time=org.slf4j.LoggerFactory --initialize-at-build-time=ch.qos.logback --initialize-at-build-time=org.bouncycastle --initialize-at-build-time=org.apache.catalina.connector --initialize-at-build-time=org.apache.catalina.util --initialize-at-build-time=org.apache.juli.logging --initialize-at-build-time=org.apache.xerces --initialize-at-build-time=org.glassfish.jaxb --initialize-at-build-time=com.ctc.wstx --initialize-at-build-time=jakarta.xml --initialize-at-build-time=com.sun.istack --initialize-at-build-time=com.sun.xml px-internetweb.muenchen.de:80 px-internetweb.muenchen.de:80 .muenchen.de ... ... https://index.docker.io/v1/ repackage process-aot process-aot ```

Via native-maven-plugin

Builds native executable.

Add additional following build step: Requires GraalVM to be set up.

``` org.graalvm.buildtools native-maven-plugin --initialize-at-build-time=org.slf4j.LoggerFactory --initialize-at-build-time=ch.qos.logback --initialize-at-build-time=org.bouncycastle --initialize-at-build-time=org.apache.catalina.connector --initialize-at-build-time=org.apache.catalina.util --initialize-at-build-time=org.apache.juli.logging --initialize-at-build-time=org.apache.xerces --initialize-at-build-time=org.glassfish.jaxb --initialize-at-build-time=com.ctc.wstx --initialize-at-build-time=jakarta.xml --initialize-at-build-time=com.sun.istack --initialize-at-build-time=com.sun.xml ```

Lessons learned

Tested Integrations

digiwf-dms-integration

Can build with above config but fails at startup as classpath:/_.wsdl is not resolvable

Caused by: jakarta.xml.ws.WebServiceException: Ung³ltige WSDL-URL: classpath:/fabasoft.wsdl

digiwf-emai-integration

Can build with above config but fails at startup with following error

``` 2024.06.17 06:31:26.859 | ERROR | [main] | SpringApplication | [SpringApplication.java : 835] - Application run failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'digiwfEmailApi': Instantiation of supplied bean failed at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1218) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1156) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:558) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:518) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:973) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:952) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:615) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:738) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:440) at org.springframework.boot.SpringApplication.run(SpringApplication.java:324) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1317) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) at de.muenchen.oss.digiwf.email.integration.DigiwfEmailIntegrationApplication.main(DigiwfEmailIntegrationApplication.java:10) Caused by: java.lang.Error: java.lang.InstantiationException: org.owasp.shim.ForJava9AndLater at org.owasp.shim.Java8Shim.(Java8Shim.java:27) at org.owasp.html.HtmlPolicyBuilder.(HtmlPolicyBuilder.java:168) at org.owasp.html.Sanitizers.(Sanitizers.java:58) at de.muenchen.oss.digiwf.email.impl.DigiwfEmailApiImpl.(DigiwfEmailApiImpl.java:39) at de.muenchen.oss.digiwf.email.configuration.DigiwfEmailAutoConfiguration.digiwfEmailApi(DigiwfEmailAutoConfiguration.java:51) at de.muenchen.oss.digiwf.email.configuration.DigiwfEmailAutoConfiguration__BeanDefinitions.lambda$getDigiwfEmailApiInstanceSupplier$2(DigiwfEmailAutoConfiguration__BeanDefinitions.java:57) at org.springframework.util.function.ThrowingBiFunction.apply(ThrowingBiFunction.java:68) at org.springframework.util.function.ThrowingBiFunction.apply(ThrowingBiFunction.java:54) at org.springframework.beans.factory.aot.BeanInstanceSupplier.lambda$get$2(BeanInstanceSupplier.java:202) at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:58) at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:46) at org.springframework.beans.factory.aot.BeanInstanceSupplier.invokeBeanSupplier(BeanInstanceSupplier.java:214) at org.springframework.beans.factory.aot.BeanInstanceSupplier.get(BeanInstanceSupplier.java:202) at org.springframework.beans.factory.support.DefaultListableBeanFactory.obtainInstanceFromSupplier(DefaultListableBeanFactory.java:947) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1212) ... 17 common frames omitted Caused by: java.lang.InstantiationException: org.owasp.shim.ForJava9AndLater at java.base@17.0.11/java.lang.Class.newInstance(DynamicHub.java:639) at org.owasp.shim.Java8Shim.(Java8Shim.java:21) ... 31 common frames omitted Caused by: java.lang.NoSuchMethodException: org.owasp.shim.ForJava9AndLater.() at java.base@17.0.11/java.lang.Class.checkMethod(DynamicHub.java:1042) at java.base@17.0.11/java.lang.Class.getConstructor0(DynamicHub.java:1208) at java.base@17.0.11/java.lang.Class.newInstance(DynamicHub.java:626) ... 32 common frames omitted ```

digiwf-engine-rest

Caused by: java.lang.NoSuchMethodException: org.camunda.bpm.engine.impl.ProcessEngineLogger.<init>()

Result

When testing the native image builds one error after the other occurred and it was never really clear whether the recommended solution, such as adding the --initialize-at-build-time argument, was really the right way to go. The much more practical way would be to try the whole thing with a much smaller Refarch project.

darenegade commented 3 months ago

Hab das intern aufgenommen:

https://git.muenchen.de/ccse/refarch-archetype/refarch-archetype-backend/-/issues/76

Für mich passt das, wenn wir wegen der Probleme hier die Komplexität erstmal reduzieren

simonhir commented 2 months ago

As part of the internal ticket refarch-archetype/refarch-archetype-backend!76, it was noticed that the custom Maven build config of DigiWF was the main cause of errors. With adjustments, the implementation should therefore be feasible, taking into account the problems documented in the issue above.