Cannot kotlinc-native compile restful service with Spring - spring-boot

Quick Question: Is it possible to convert a Kotlin + Spring restful web service to a linux native application?
It works properly when run on the JVM, but I get compilation errors when I try to build it using kotlinc-native for linux.
I cannot find any definitive statement about whether I am trying to do something that is unsupported. Am I trying to swim upstream, here?
Thank you for your comments and help!
Mike
Here are some details...
Ubuntu 18.04
Latest versions of stable dependencies

You can not link a jvm library with kotlin-native. You must have a C library to be able to link it or convert the java code to kotlin.
If what you need is a embedded server executable you could check the ktor project.
The project have some client native examples and a embedded native http2-push.

Related

Can we run karate tests on GraalVM JDK?

I have a REST API running on Springboot 3 and I test it using the karate framework.
As native is a new feature of springboot 3 I tried to run the API on GraalVM.
My app can run but when it comes to running tests I get this error :
java.lang.IllegalArgumentException: Could not find option with name js.ecmascript-version.
at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotEngineException.illegalArgument(PolyglotEngineException.java:131)
at org.graalvm.truffle/com.oracle.truffle.polyglot.OptionValuesImpl.failNotFound(OptionValuesImpl.java:274)
at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotEngineImpl.parseOptions(PolyglotEngineImpl.java:736)
at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotEngineImpl.<init>(PolyglotEngineImpl.java:313)
at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotImpl.buildEngine(PolyglotImpl.java:288)
at org.graalvm.sdk/org.graalvm.polyglot.Engine$Builder.build(Engine.java:625)
I use GraalVM 22.3.0 and karate-junit5 1.1.0 (I also tried more recent versions but it does not work).
Is there a compatibility problem between the Karate framework and the graalVM since the karate core already uses graaljs dependencies ?
Thank you in advance
Yes, can you first try 1.4.0.RC3 and refer this thread - or comment there also with your findings: https://github.com/karatelabs/karate/issues/2148
But if you want to use the GraalVM instead of a normal JVM, I don't think that's supported. But a PR is welcome.

Null pointer exception from ODataApplicationInitializer in SpringBoot jar

I created my project by using S/4HANA SDK (spring boot archetype), now I need the functionality to provision some ODATA services so I also introduce the dependency com.sap.cloud.servicesdk.provodatav4 to my project and then create metadata file and odata service implementation class. However, after packaging my project into jar file and run it, I get null pointer exception from the class com.sap.cloud.sdk.service.prov.v4.rt.core.web.ODataApplicationInitializer. After seeing the source code of this class, it seems it use "File" object to get metadata file from classpath, but this way doesn't work in a jar file. My question is: does it mean I have to change the packaging way to "war" in order to use this SDK for odata service development? Thanks very much.
The unfortunate answer is that, as of today, the Service SDK (not the S/4HANA Cloud SDK) is only compatible with pure Tomcat environments and assumes the Servlet standard as well as surrounding mechanisms as the default mean. The reasons for this is that the Service SDK is an integral part (the runtime) of the SAP Cloud Application Programming Model which is self-contained and may not be combined with arbitrary frameworks such as Spring Boot.
Adding to Philipp's answer that this is not supported, you may be able to use the traditional deployment here. However, since this is likely not supported officially, I would encourage to consider an alternative approach.

Build a Java Rest API with Intellij

I need help developing a Basic Java Rest API using IntelliJ and terminal on my mac. I also have docker installed. I want to run a hello world on local host using the REST API Style
There's a ton of different java web frameworks that will help you build a REST endpoint. Here's some of those frameworks:
http://spring.io/
https://vertx.io/
https://www.playframework.com/
if you want to build it from scratch (not recommended) then checkout
https://www.tutorialspoint.com/servlets/servlets-first-example.htm

Apache Spark and gRPC

I'm writing an application that uses Apache Spark. For communicating with a client, I would like to use gRPC.
In my Gradle build file, I use
dependencies {
compile('org.apache.spark:spark-core_2.11:1.5.2')
compile 'org.apache.spark:spark-sql_2.11:1.5.2'
compile 'io.grpc:grpc-all:0.13.1'
...
}
When leaving out gRPC, everything works fine. However, when gRPC is used, I can create the build, but not execute it, as various versions of netty are used by the packages. Spark seems to use netty-all, which contains the same methods (but with potentially different signatures) than what gRPC uses.
I tried shadowing (using com.github.johnrengelman.shadow) , but somehow it still does not work. How can I approach this problem?
The general solution to this sort of thing is shading with relocation. See the answer to a similar problem with protobuf dependencies: https://groups.google.com/forum/#!topic/grpc-io/ABwMhW9bU34
I think the problem is that spark uses netty 4.0.x and gRPC 4.1.0 .

how to register plugins to java registery

How we can register any kind of plugin or java libs to java registry. I want to execute my application in Apache service mix and facing issue of unsupported image type. I have been using TwelveMonkeys libs but still facing same issue. As per Twelvemonkeys guidelines it is said that this TwelveMonkeys plugins are discovered automatically at run time, but its not the case when deploying project into service mix.
Any help would be great and thankful..

Resources