did anyone faced this error with the swaggerUI plu...
# ktor
m
did anyone faced this error with the swaggerUI plugin?
Copy code
ERROR io.ktor.server.Application - Unhandled: GET - /swagger
java.lang.ClassCastException: class kotlinx.html.DIV cannot be cast to class kotlinx.html.CoreAttributeGroupFacade (kotlinx.html.DIV and kotlinx.html.CoreAttributeGroupFacade are in unnamed module of loader 'app')
	at io.ktor.server.plugins.swagger.SwaggerKt$swaggerUI$5$2.invokeSuspend$lambda$9(Swagger.kt:103) [...] etc
I’m not doing anything misterious, just followed the doccumentation steps πŸ˜•
s
Hey Marc! Seems like a dependency issue. Have you checked
./gradlew dependencies
?
πŸ‘€ 1
a
Can you please try to disable the development mode?
πŸ‘€ 1
m
@simon.vergauwen the dependencies tasks is the very first thing I ran, It looks like swagger tool is using the latest html version not transitively changed. @Aleksei Tirman [JB] disabling the developer mode does not change the output πŸ™πŸ»
a
Can you please share a sample project to reproduce the exception?
m
its private because it. a real project I’m working on but I have no issues on inviting you to check, would it be fine @Aleksei Tirman [JB]?
a
Yes, it's fine.
m
could you facilitate me your github handle please?
a
Stexxe
πŸ™πŸ» 1
m
you should have a pending invitation already πŸ‘ŒπŸ»
a
What steps shall I take to reproduce the exception?
m
jus runnig the project (should be one click on the IDE) and then opening the localhost:8080/swagger should be enough
env variables have been defined for local development already so you should not find any issue
the swaggerUI is deifned in
HTTP.kt
a
It give the following error on the server startup:
Copy code
Failed to initialize pool: Connection to localhost:5434 refused
After running
docker compose up
it reports the following error:
Copy code
Error: Database is uninitialized and superuser password is not specified.
       You must specify POSTGRES_PASSWORD to a non-empty value for the
       superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run".

       You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all
       connections without a password. This is *not* recommended.

       See PostgreSQL documentation about "trust":
       <https://www.postgresql.org/docs/current/auth-trust.html>
πŸ‘€ 1
m
could you update master and try now? I refactored some env variables and forgot to update them in the script that initializes the database. it should work now
a
Thank you. I've reproduced the exception.
πŸ™πŸ» 1
Looks like there are incompatible versions of
org.jetbrains.kotlinx:kotlinx-html-jvm
in the project (0.7.5 and 0.12.0). The version 0.7.5 comes from
org.jetbrains.dokka:dokka-base
which is a dependency of
io.github.nikitok:exposed-postgis
. Ktor depends on the newer version of the library 0.12.0.
m
but the dependency used by the swagger one is 0.12.0 right? we would see is downgraded in the :dependencies task otherwise
or am I mistaken?
a
That's right
m
then do you still think is this the mistake? πŸ€”
a
What do you mean by mistake?
m
the fact that we see the crash from swagger at
/swagger
I would understand if swagger fails because its somehow using the version 0.7.5 but it looks its using the correct one (0.12.0)
a
You're right. The only version used at runtime is 0.12.0. The problem is in the
features/propertyscrapper/jars/skrapit-shadowed.jar
which contains a different version of the kotlinx-html library (
krapit-shadowed.jar!/kotlinx/html
). No exception is thrown without that JAR in the classpath.
😫 1
m
fortunately this is a library that i had to cerate to shadow ktor xD so i can shadow html as well, hahah. let me try
thank you very much for the help. very insightful indeed. 🀘🏻
I confirm it worked. thanks for helping out troubleshooting it. And sorry for opening a question that was my fault πŸ˜