T
TBD•8mo ago
ALR

NoClassDefFoundError on PfiStructureTest

NoClassDefFoundError on PfiStructureTest PR 🧵
8 Replies
ALR
ALR•8mo ago
@chrisgiglio I'm still working through this for you. It's delayed because it's not simple and I'm looking at why. You're getting:
java.lang.NoClassDefFoundError: io/ktor/server/plugins/contentnegotiation/ContentNegotiationKt
at website.tbd.developer.site.docs.tbdex.pfi.PfiStructureTest.PFI initializes server(PfiStructureTest.kt:66)
Caused by: java.lang.ClassNotFoundException: io.ktor.server.plugins.contentnegotiation.ContentNegotiationKt
at website.tbd.developer.site.docs.tbdex.pfi.PfiStructureTest.PFI initializes server(PfiStructureTest.kt:66)
java.lang.NoClassDefFoundError: io/ktor/server/plugins/contentnegotiation/ContentNegotiationKt
at website.tbd.developer.site.docs.tbdex.pfi.PfiStructureTest.PFI initializes server(PfiStructureTest.kt:66)
Caused by: java.lang.ClassNotFoundException: io.ktor.server.plugins.contentnegotiation.ContentNegotiationKt
at website.tbd.developer.site.docs.tbdex.pfi.PfiStructureTest.PFI initializes server(PfiStructureTest.kt:66)
OK, fine, so this signals to me that some other dependency is referencing the class io.ktor.server.plugins.contentnegotiation.ContentNegotiationKt and not finding it on the --classpath But your test has --classpath where I clearly see: /Users/alr/.m2/repository/io/ktor/ktor-client-content-negotiation-jvm/2.3.7/ktor-client-content-negotiation-jvm-2.3.7.jar And in that JAR:
ls -laR |grep ContentNegotiationKt -B15
./io/ktor/client/plugins/contentnegotiation:
total 176
drwxr-xr-x@ 16 alr staff 512 Feb 1 1980 .
drwxr-xr-x@ 4 alr staff 128 Feb 28 14:17 ..
-rw-r--r--@ 1 alr staff 953 Feb 1 1980 ContentConverterException.class
-rw-r--r--@ 1 alr staff 2088 Feb 1 1980 ContentNegotiation$Config$ConverterRegistration.class
-rw-r--r--@ 1 alr staff 1545 Feb 1 1980 ContentNegotiation$Config$defaultMatcher$1.class
-rw-r--r--@ 1 alr staff 6386 Feb 1 1980 ContentNegotiation$Config.class
-rw-r--r--@ 1 alr staff 4322 Feb 1 1980 ContentNegotiation$Plugin$install$1.class
-rw-r--r--@ 1 alr staff 6256 Feb 1 1980 ContentNegotiation$Plugin$install$2.class
-rw-r--r--@ 1 alr staff 4725 Feb 1 1980 ContentNegotiation$Plugin.class
-rw-r--r--@ 1 alr staff 2147 Feb 1 1980 ContentNegotiation$convertRequest$1.class
-rw-r--r--@ 1 alr staff 2372 Feb 1 1980 ContentNegotiation$convertRequest$serializedContent$2.class
-rw-r--r--@ 1 alr staff 2049 Feb 1 1980 ContentNegotiation$convertResponse$1.class
-rw-r--r--@ 1 alr staff 18251 Feb 1 1980 ContentNegotiation.class
-rw-r--r--@ 1 alr staff 1750 Feb 1 1980 ContentNegotiationKt.class
ls -laR |grep ContentNegotiationKt -B15
./io/ktor/client/plugins/contentnegotiation:
total 176
drwxr-xr-x@ 16 alr staff 512 Feb 1 1980 .
drwxr-xr-x@ 4 alr staff 128 Feb 28 14:17 ..
-rw-r--r--@ 1 alr staff 953 Feb 1 1980 ContentConverterException.class
-rw-r--r--@ 1 alr staff 2088 Feb 1 1980 ContentNegotiation$Config$ConverterRegistration.class
-rw-r--r--@ 1 alr staff 1545 Feb 1 1980 ContentNegotiation$Config$defaultMatcher$1.class
-rw-r--r--@ 1 alr staff 6386 Feb 1 1980 ContentNegotiation$Config.class
-rw-r--r--@ 1 alr staff 4322 Feb 1 1980 ContentNegotiation$Plugin$install$1.class
-rw-r--r--@ 1 alr staff 6256 Feb 1 1980 ContentNegotiation$Plugin$install$2.class
-rw-r--r--@ 1 alr staff 4725 Feb 1 1980 ContentNegotiation$Plugin.class
-rw-r--r--@ 1 alr staff 2147 Feb 1 1980 ContentNegotiation$convertRequest$1.class
-rw-r--r--@ 1 alr staff 2372 Feb 1 1980 ContentNegotiation$convertRequest$serializedContent$2.class
-rw-r--r--@ 1 alr staff 2049 Feb 1 1980 ContentNegotiation$convertResponse$1.class
-rw-r--r--@ 1 alr staff 18251 Feb 1 1980 ContentNegotiation.class
-rw-r--r--@ 1 alr staff 1750 Feb 1 1980 ContentNegotiationKt.class
OHHHHH, wrong package - it's in io.ktor.server.plugins not io.ktor.client.plugins, one sec This is why I write shit out BTW, it forces thought. @chrisgiglio I have a short window to turn this around for you - sent huddle OK, I've issued a couple commits into the pfi-structure-test branch to unblock Chris. Found the underlying issue too. It's not about version mismatch; it's because tbdex-server doesn't export out the dependency io.ktor:ktor-server-content-negotiation-jvm required to run TbdexHttpServer.start(). @jiyoontbd @frankhinek - is that correct? Shouldn't consumers get ktor-server-content-negotiation-jvm on their runtime --classpath when they depend on tbdex-server? Here are my recommended text steps for @chrisgiglio: https://github.com/TBD54566975/developer.tbd.website/pull/1290/commits/cb1bc3c7efeb1b7f470487bfd960f0e36229d2f0 My note 1) there may be a little outdated; it looks from the tbdex-kt team that they don't intend for devs to directly run TbdexHttpServer.start(), but rather wrap it in a ktor TestApplication. Example of how they do test setup is here: https://github.com/TBD54566975/tbdex-kt/blob/main/httpserver/src/test/kotlin/ServerTest.kt Note that this is lifecycle setup for starting the server on each test class. The test itself should be issuing requests to the server and checking the responses, running assertions on them. What's weird @jiyoontbd is I'm expecting this to be exported, and it's not? https://github.com/TBD54566975/tbdex-kt/blob/main/httpserver/build.gradle.kts#L62 Maybe because the Dev Site isn't on an updated version of tbDEX? AHA I see why; it's because: https://github.com/TBD54566975/tbdex-kt/blob/main/gradle/libs.versions.toml#L44 We have io.ktor:ktor-server-content-negotiation and it needs to be io.ktor:ktor-server-content-negotiation-jvm I'll make a PR.
Unknown User
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
ALR
ALR•8mo ago
Well, without ktor-server-content-negotiation-jvm we got:
[ERROR] PFI initializes server Time elapsed: 0.029 s <<< ERROR!
java.lang.NoClassDefFoundError: io/ktor/server/plugins/contentnegotiation/ContentNegotiationKt
at website.tbd.developer.site.docs.tbdex.pfi.PfiStructureTest.PFI initializes server(PfiStructureTest.kt:66)
Caused by: java.lang.ClassNotFoundException: io.ktor.server.plugins.contentnegotiation.ContentNegotiationKt
at website.tbd.developer.site.docs.tbdex.pfi.PfiStructureTest.PFI initializes server(PfiStructureTest.kt:66)
[ERROR] PFI initializes server Time elapsed: 0.029 s <<< ERROR!
java.lang.NoClassDefFoundError: io/ktor/server/plugins/contentnegotiation/ContentNegotiationKt
at website.tbd.developer.site.docs.tbdex.pfi.PfiStructureTest.PFI initializes server(PfiStructureTest.kt:66)
Caused by: java.lang.ClassNotFoundException: io.ktor.server.plugins.contentnegotiation.ContentNegotiationKt
at website.tbd.developer.site.docs.tbdex.pfi.PfiStructureTest.PFI initializes server(PfiStructureTest.kt:66)
So something in there is expecting it to be there If you look inside ktor-server-content-negotiation-jvm you see classes. Inside ktor-server-content-negotiation: no classes. So that makes sense.
/Users/alr/Downloads/ktor-server-content-negotiation-2.3.7 $> ls -la
total 16
drwx------@ 6 alr staff 192 Feb 28 14:27 .
drwx------+ 8 alr staff 256 Feb 28 14:27 ..
-rw-r--r--@ 1 alr staff 6148 Feb 28 14:28 .DS_Store
drwxr-xr-x@ 4 alr staff 128 Feb 1 1980 META-INF
drwxr-xr-x@ 3 alr staff 96 Feb 1 1980 jvmAndNixMain
drwxr-xr-x@ 3 alr staff 96 Feb 1 1980 nixMain
/Users/alr/Downloads/ktor-server-content-negotiation-2.3.7 $> ls -la
total 16
drwx------@ 6 alr staff 192 Feb 28 14:27 .
drwx------+ 8 alr staff 256 Feb 28 14:27 ..
-rw-r--r--@ 1 alr staff 6148 Feb 28 14:28 .DS_Store
drwxr-xr-x@ 4 alr staff 128 Feb 1 1980 META-INF
drwxr-xr-x@ 3 alr staff 96 Feb 1 1980 jvmAndNixMain
drwxr-xr-x@ 3 alr staff 96 Feb 1 1980 nixMain
Unknown User
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
ALR
ALR•8mo ago
Right. The JVM one does I’ll have to look more later, but you got us good direction on its intended use so I can make PRs to fix stuff up. You see things inside tbdex a little differently because that’s the project you’re working in, not importing. 🙂 Internal testsuites can lie for that reason, which is why @chrisgiglio work is so great as an external acceptance suite to catch things Yeah it’s totally cool to call it @techgirl1908 but it’s a blocking operation - so the intended use is to wrap it in TestApplication so that the server will boot in another thread while returning the calling stack to continue. Totally cool to call this API; you would just need to set up your own threading so the test doesn’t hang sitting in that “start” line
Unknown User
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
ALR
ALR•8mo ago
Hard agree
Unknown User
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server