ClassNotFoundException when Using Tyrus and Grizzly with PyCharm Plugin
Hi everyone,
I'm working on a PyCharm plugin where I'm trying to use Tyrus and Grizzly for WebSockets. The dependencies seem to resolve correctly, and they are included in the `build/distributions` folder within the zip archive. Here are the relevant parts of my setup:
Dependencies in build.gradle.kts:implementation("jakarta.websocket:jakarta.websocket-api:2.2.0")// https://mvnrepository.com/artifact/jakarta.servlet/jakarta.servlet-apiimplementation("jakarta.servlet:jakarta.servlet-api:6.1.0")// https://mvnrepository.com/artifact/org.glassfish.tyrus/tyrus-serverimplementation("org.glassfish.tyrus:tyrus-server:2.1.5")// https://mvnrepository.com/artifact/org.glassfish.tyrus/tyrus-container-grizzly-serverimplementation("org.glassfish.tyrus:tyrus-container-grizzly-server:2.1.5")
Despite these dependencies being correctly included, I encounter a `ClassNotFoundException` when running the `runIde` task:java.lang.RuntimeException: java.lang.ClassNotFoundException: org.glassfish.tyrus.container.grizzly.server.GrizzlyServerContainer at org.glassfish.tyrus.spi.ServerContainerFactory.createServerContainer(ServerContainerFactory.java:62) at org.glassfish.tyrus.server.Server.start(Server.java:199)
I also tried to install the plugin manually via zip-archive.
libs.versions.toml:# pluginskotlin = "2.0.0"changelog = "2.2.0"gradleIntelliJPlugin = "1.17.4"qodana = "2024.1.5"kover = "0.8.2"
gradle.properties:pluginSinceBuild = 223pluginUntilBuild = 241.*
# IntelliJ Platform PropertiesplatformType = PCplatformVersion = 2022.3.3
# Plugin DependenciesplatformPlugins = python-ce
# Gradle ReleasesgradleVersion = 8.8
Environment Details:IntelliJ IDEA 2024.1 (Ultimate Edition)Build #IU-241.14494.240, built on March 28, 2024
Runtime version: 17.0.10+8-b1207.12 aarch64VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.macOS 14.5GC: G1 Young Generation, G1 Old GenerationMemory: 2048MCores: 10Metal Rendering is ONRegistry: ide.experimental.ui=trueNon-Bundled Plugins: com.jetbrains.space (241.14494.150) Pythonid (241.14494.314) DevKit (241.14494.247) com.intellij.ml.llm (241.14494.320)Kotlin: 241.14494.240-IJ
Has anyone encountered a similar issue or can provide any insight on how to resolve this ClassNotFoundException? Any help or pointers would be greatly appreciated! Maybe I have a fundamental misunderstanding of the IntelliJ Dependency Management as I am new to Plugin Development. I read the docs but couldn't resolve my problem.
Thanks in advance!
Please sign in to leave a comment.
Hi Julian,
Could you please make sure the class is actually in one of the JARs? On the internet I can see similar issues with exactly the same class, and it seems to be a dependency problem.
Hi Karol Lewandowski,
in which jar it should actually be? I see the “missing” library inside the .zip-archive in the build/distributions folder. But I don't find any external library inside one of my Plugin jar-Files.
Thanks for your help!
Hi Julian,
I don't know in which library JAR it should be (not a plugin JAR). I don't know this library and class. The error says that class cannot be found, and I don't see any issues in your configuration, so the first step is to ensure the class is actually delivered in your plugin distribution. Please make sure that the class is contained by one of the library JARs.
Hi Karol Lewandowski,
the following jar-File are inside the .zip-archive in the build/distributions folder. (For the picture, i unzipped it → build/distributions/$PLUGIN-NAME$/lib → )
The missing class is in tyrus-container-grizzly-server-2.1.5.jar which is inside the zip-archive. I also unzipped this jar-file and found the class inside.
Any ideas?
Best regards
Julian
Thanks for checking.
Looking at the implementation:
https://github.com/eclipse-ee4j/tyrus/blob/master/spi/src/main/java/org/glassfish/tyrus/spi/ServerContainerFactory.java#L47-L70
it seems that
ServiceLoaderis used. Please try to set context class loader to the plugin's class loader as described in the documentation:https://plugins.jetbrains.com/docs/intellij/plugin-class-loaders.html#using-serviceloader
Dear Karol Lewandowski,
that was the issue, thanks! :-)
Best regards,
Julian