-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ktor on Native Image - Doesn't work #163
Comments
I uploaded the complete repository: micronaut-ktor-api |
So @atrianac I was able to reproduce the issue as you describe it, however I think we need to elevate this issue to ktor itself. I was also able to reproduce the issue by replacing the So I think likely this is a graal + ktor related issue, and not really related to micronaut. @atrianac would you feel comfortable filing an issue w/ the ktor folks? I'm afraid I don't have a great deal of ktor experience but I can help with filing the issue if needed, just let me know!
|
@willbuck Thanks, I will do! |
The issue in Ktor Project is reported here: https://youtrack.jetbrains.com/issue/KTOR-1307 |
@willbuck The Ktor team answered the question. It is necessary to add [
{
"name": "kotlin.reflect.jvm.internal.ReflectionFactoryImpl",
"allDeclaredConstructors":true
},
{
"name": "kotlin.KotlinVersion",
"allPublicMethods": true,
"allDeclaredFields":true,
"allDeclaredMethods":true,
"allDeclaredConstructors":true
},
{
"name": "kotlin.KotlinVersion[]"
},
{
"name": "kotlin.KotlinVersion$Companion"
},
{
"name": "kotlin.KotlinVersion$Companion[]"
},
{
"name": "kotlin.internal.jdk8.JDK8PlatformImplementations",
"allPublicMethods": true,
"allDeclaredFields":true,
"allDeclaredMethods":true,
"allDeclaredConstructors":true
}
]
I tested and It is already working. Where do we add those change for the |
@atrianac I will take a look later this week! |
@willbuck thanks. I just updated the original repository with the right changes. |
@atrianac I took a look at this and I think this would actually require a change in https://github.com/micronaut-projects/micronaut-starter/ , probably to the apply method of: the Ktor feature: https://github.com/micronaut-projects/micronaut-starter/blob/2.3.x/starter-core/src/main/java/io/micronaut/starter/feature/kotlin/Ktor.java#L99 and/or the GraalVM feature (maybe? not sure this is the right spot): https://github.com/micronaut-projects/micronaut-starter/blob/2.3.x/starter-core/src/main/java/io/micronaut/starter/feature/graalvm/GraalVM.java I'm fairly engaged w/ client work at present so I don't know that I can get to it anytime soon, but contributions would be welcome if you'd like to give it a shot! |
I don’t believe it needs any of that. The reflection config and native image args can exist in this project in a file in the src/main/resources/META-INF/native-image directory |
The reflection json needs to be in a file called reflect-config.json in the same directory |
My mistake @atrianac , thanks for correcting me Graeme! |
@timyates can you verify if this issue is still present? |
@sdelamo @graemerocher I believe this issue is still present At least, I cannot get a native Ktor application to return any content (even with the above changes) |
Steps to Reproduce
docker build . -t micronaut-api
The output looks like this:
01:24:18.763 [main] INFO Application - No ktor.deployment.watch patterns specified, automatic reload is not active 01:24:18.766 [main] INFO Application - Responding at http://0.0.0.0:8080 01:24:18.768 [main] INFO io.micronaut.runtime.Micronaut - Startup completed in 4378ms. Server Running: http://0.0.0.0:8080
curl
:An empty response from the server is returned.
Expected Behaviour
Using the same code project, but on Hotspot runtime, the server returns a response:
Actual Behaviour
An empty response from the server is returned.
Environment Information
Example Application
The text was updated successfully, but these errors were encountered: