-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Quarkus, Jackson and Kotlin 1.4 #11549
Comments
/cc @evanchooly |
Can you please add the output of the failed test run? |
@geoand I added the logs to my example git-repo: |
@RotBolt do you think this might be similar to the native resources thing you were looking at? |
@kny78: I think you pull some artefacts with the kotlin version 1.3.72 since that is the version in the current quarkus bom. When you do not explicitly specify the 1.4 version for all kotlin artefacts, I think you get mixed versions. Maybe have a look at the dependency tree to verify the versions are all 1.4. |
@andreas-eberle I have explicitly added dependencies with 1.4.0 for these. Please see the output of mvn dependency:tree in: |
I think jackson-module-kotlin is not Kotlin 1.4 compatible yet: FasterXML/jackson-module-kotlin#356 |
@geoand resource classpath is added properly. Probably Resource is not there itself in Kotlin 1.4 Resource works fine on JVM tests. It was the problem with Native resources only. |
I have not. Hopefully some time next week, currently I don't have enough time |
I will try to run tests on your producer. |
This doesn't really look like a Quarkus bug... My bet is that it's some obscure Kotlin issue |
Yet it only manifests it self if I add the @QuarkusTest. Without it, it runs as it should. I can also go up in the stack in the debugger, and it works. |
Yeah I saw that, but still, Quarkus isn't coming into play in any way for this test - except for being started. |
@geoand Does it change the class path? If so it could be that it adds / does not add certain jars to the classpath on a parent, and that causes the issue? |
The classpath is changed for QuarkusTest and that probably does uncovers the issue. But at this point it looks so low level in Kotlin and 1.4 is so new, so I am reluctant to look further into at this stage |
I see if I can find the differences in the classpath. Then we might have a startingpoint for either fix Quarkus, og report an upstream bug to the Kotlin project :-) |
I appear to have run into a possibly related issue investigating a problem with Kotlin based library (Pact consumer) which also results in Kotlin's standard library and Pact both use a similar mechanism to determine their versions at runtime: While debugging, I noticed that Without QuarkusTest: With QuarkusTest This change causes sun.net.www.protocol.jar.JarUrlConnection::getInputStream to get invoked instead which fails on account of a null Also, JarInputSream expects its input to be a inputstream from a jar rather than a single entry inside the jar. Edit: Forgot to mention, I've tried this using Quarkus 1.7.0.Final and 1.6.0.Final as well as several versions of Pact Consumer, with no improvement in behavior. |
@pwongv that is very useful information, thanks! Do you think you can isolate this into a small code snippet? That should make easy to reproduce the problem and fix what looks like a bug in the |
Sure thing. 0001-Splicing-in-Pact-test-example-to-demonstrate-11549.patch.TXT If you set a breakpoint in |
Does anyone know the status on this? Is the problem reported to the people who work with the classloader? |
I would be one of those people but unfortunately I haven't had time to look into it yet. |
I know the feeling :-) |
Hopefully sometime this week 😎 |
Looks like fun :) |
Took a super quick look at this and didn't get far... If someone with knowledge of Kotlin internals want to take a stab at this, be my guest :) Or if someone that at least knows where Kotlin Rrflect does any sort of ClassLoading and provide those hints I can take another look. |
I tried to debug this for a short time, but my breakpoints were never hit in the tests. Maybe I'll find some time on the weekend to understand kotlin internals here. Meanwhile I made another observation: when I remove the "reflect" dependency and Gradle pulls the 1.3.72 version from jackson-module-kotlin, my tests work again on Quarkus 1.8.0.Final. On Quarkus 1.7.3.Final hibernate-types fails to deserialize a JSON field because it gets confused by the class hierarchy of that field (serialized as I'm not sure who to blame now: Quarkus, Kotlin, Jackson, ... so I'll go back to kotlin 1.3.72 and wait for the jackson module update. |
Did anyone have any time to dig any further into this? |
Unfortunately not enough to get an deep understanding of the things happening there :-/. |
Tried with jackson 2.11.3, but it still fails. |
I have tried Quarkus 1.9.0, and it also includes Jackson 2.11.3, but still get the same error. @geoand Did you have any time to look into this? |
Unfortunately no. My time is on very short supply lately... |
I have also having Jackson 2.11.3 with Quarkus 1.9.1 and Kotlin 1.4.10 JUnit tests are green. Running simple The reason for me jackson-module-kotlin depends on Kotlin 1.3.72 Currently 2.12 for Kotlin 1.4.10 is not yet released 😢 Maybe that's the problem... |
@pflorek I have tested with 2.12.0-rc1, and the same issue appeared. I also tried to upgrade Kotlin to 1.4.20-RC, but to no avail. Also the same code runs without @QuarkusTest , but not with it. See: |
Filed issue to Kotlin team, perhaps they can shed some light on it: https://youtrack.jetbrains.com/issue/KT-43438 |
@hrensgory @geoand It has already been reported to Kotlin, but they have said:
And if we remove @QuarkusTest, then it runs as it should. Is it possible to easily check if the classloader that calls the test-code has kotlin-stdlib on the classpath? |
Did anyone clone the test-repo, and try to run the code? It is updated with Quarkus 1.9.2! |
@kny78 - as for now bug isn't declined, so vote for it ;-) !
I added quarkus-bootstrap-maven plugin and called quarkus-bootstrap-maven-plugin:dev-mode-tree as well as quarkus-bootstrap-maven-plugin:build-tree but I didn't find anything suspicious in the output. Could you check it as well, please, I can miss something. |
It's getting a bit urgent now: with 1.10.CR1 Kotlin 1.4.10 is pulled into the dependencies when one uses With my limited time right now and my lack of understanding the Quarkus class loading, my efforts have not shown much success for now. |
I'm actively looking in to this for what it's worth but it's leading in to parts of quarkus I'm not super familiar with so it's taking time. |
Maybe a stupid, and out of place question, but does Quarkus / Jboss really need a special ClassLoader for Quarkus? Quarkus is meant for microservices, and not as a "Application Server". Is it possible to disable the custom ClassLoader? |
In test mode and dev mode, the special ClassLoader is absolutely necessary |
@geoand @evanchooly I see that in IntelliJ, it adds a special "Quarkus Deployment" under dependencies. Here these libs are added:
Is the quarkus-maven-plugin or some other code modifying the dependencies? |
Hi! Here's a bit of info from Kotlin's point of view. I'm not sure how much of this is useful but it might help in tracking down the issue. The main relevant change in Kotlin from 1.3.72 to 1.4.0 was that now we're bundling Java module system's module-info files into stdlib, reflect and other libraries (KT-21266). Prior to 1.4.0, if main Kotlin libraries were used in the modular world, i.e. in the Java module path, they were loaded as automatic modules. So starting from 1.4.0, kotlin-stdlib and kotlin-reflect now have Here are the module-info definitions of: kotlin-stdlib, kotlin-reflect. The main parts here are that kotlin-reflect The error you're seeing is saying that kotlin-reflect tries to load a resource and fails. The resource in question is For JDKs < 9, we invoke So it might be the case that the special class loader you're using in Quarkus is somehow not creating the module structure correctly, which either leads to One other major note: we had a bug in 1.4.0 where kotlin-reflect did not work at all if it was used in the Java module path with the standard Java module system's class loader (KT-40842). It was fixed in Kotlin 1.4.10. It shouldn't necessarily affect this issue, but it makes sense to test only 1.4.10 just in case. |
There is a really simple fix here to just make Kotlin be parent first, so it is loaded from the system CL rather than the QuarkusClassLoader. I have not been able to figure out exactly what is going on here though. As far as I can tell QuarkusClassLoader.getResourceAsStream is not actually invoked. |
Also change to 1.4 Fixes quarkusio#11549
Also change to 1.4 Fixes quarkusio#11549
I came to the same conclusion yesterday as Stuart and he has a fix/PR in place that shows it working. There's a tweak or two to make on it but i'm running those final tests now. Thanks for the explainer @udalov. I've spent a fair bit of time over the last few days in that code and it's ... dense. :) |
Also change to 1.4 Fixes quarkusio#11549
Describe the bug
Se repository: https://github.com/kny78/quarkus-kotlin14-jackson-fail
See failure output: https://github.com/kny78/quarkus-kotlin14-jackson-fail/tree/master/failure-logs
Expected behavior
Both tests should run ok:
Actual behavior
The test im.kny.DeSerializeQuarkusTest fail.s
To Reproduce
Steps to reproduce the behavior:
The text was updated successfully, but these errors were encountered: