Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

java.lang.NoClassDefFoundError Caused by: java.lang.ClassNotFoundException: io.sentry.Sentry$OptionsConfiguration #3237

Answered by adinauer
Miracusa asked this question in Q&A
Discussion options

I'm a little stuck and in hope someone ist able to help with this. I'm new to sentry and followed what was shown when creating a new project.
My goal is to integrate Sentry into a Spigot-Plugin, but there seems to be a problem with that.

When running the server I get the error:

2024年02月29日T03:37:12.205654214Z java.lang.NoClassDefFoundError: io/sentry/Sentry$OptionsConfiguration
2024年02月29日T03:37:12.205672696Z 	at de.miracusa.plugin.plugin.onEnable(plugin.java:31) ~[plugin-cd.jar:?]
2024年02月29日T03:37:12.205677439Z 	at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:287) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
2024年02月29日T03:37:12.205680963Z 	at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.enablePlugin(PaperPluginInstanceManager.java:188) ~[paper-1.20.4.jar:git-Paper-436]
2024年02月29日T03:37:12.205684567Z 	at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.enablePlugin(PaperPluginManagerImpl.java:104) ~[paper-1.20.4.jar:git-Paper-436]
2024年02月29日T03:37:12.205688020Z 	at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:507) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
2024年02月29日T03:37:12.205691220Z 	at org.bukkit.craftbukkit.v1_20_R3.CraftServer.enablePlugin(CraftServer.java:639) ~[paper-1.20.4.jar:git-Paper-436]
2024年02月29日T03:37:12.205694588Z 	at org.bukkit.craftbukkit.v1_20_R3.CraftServer.enablePlugins(CraftServer.java:550) ~[paper-1.20.4.jar:git-Paper-436]
2024年02月29日T03:37:12.205697639Z 	at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:671) ~[paper-1.20.4.jar:git-Paper-436]
2024年02月29日T03:37:12.205700573Z 	at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:431) ~[paper-1.20.4.jar:git-Paper-436]
2024年02月29日T03:37:12.205704184Z 	at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:309) ~[paper-1.20.4.jar:git-Paper-436]
2024年02月29日T03:37:12.205707659Z 	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1131) ~[paper-1.20.4.jar:git-Paper-436]
2024年02月29日T03:37:12.205711206Z 	at net.minecraft.server.MinecraftServer.lambda$spin0ドル(MinecraftServer.java:319) ~[paper-1.20.4.jar:git-Paper-436]
2024年02月29日T03:37:12.205714761Z 	at java.lang.Thread.run(Unknown Source) ~[?:?]
2024年02月29日T03:37:12.205718163Z Caused by: java.lang.ClassNotFoundException: io.sentry.Sentry$OptionsConfiguration
2024年02月29日T03:37:12.205721929Z 	at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:197) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
2024年02月29日T03:37:12.205730861Z 	at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:164) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
2024年02月29日T03:37:12.205735293Z 	at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:?]
2024年02月29日T03:37:12.205774216Z 	... 13 more

The code witch causes this is (its located within the onEnable() if thats relevant):

Sentry.init(options -> {
 options.setDsn("THE-DSN");
 // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
 // We recommend adjusting this value in production.
 options.setTracesSampleRate(1.0);
 // When first trying Sentry it's good to see what the SDK is doing:
 options.setDebug(true);
 });

Thats the pom I use:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>de.miracusa</groupId>
 <artifactId>plugin</artifactId>
 <version>0.1.1</version>
 <repositories>
 <repository>
 <id>jitpack.io</id>
 <url>https://jitpack.io</url>
 </repository>
 <repository>
 <id>spigotmc-repo</id>
 <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
 </repository>
 </repositories>
 <dependencies>
 <dependency>
 <groupId>org.spigotmc</groupId>
 <artifactId>spigot-api</artifactId>
 <version>1.20.2-R0.1-SNAPSHOT</version>
 <scope>provided</scope>
 </dependency>
 <dependency>
 <groupId>com.mysql</groupId>
 <artifactId>mysql-connector-j</artifactId>
 <version>8.2.0</version>
 </dependency>
 
 <dependency>
 <groupId>io.sentry</groupId>
 <artifactId>sentry</artifactId>
 <version>7.4.0</version>
 </dependency>
 </dependencies>
 <build>
 <plugins>
 <plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-compiler-plugin</artifactId>
 <version>3.8.0</version>
 <configuration>
 <source>1.8</source>
 <target>1.8</target>
 </configuration>
 </plugin>
 <plugin>
 <groupId>io.sentry</groupId>
 <artifactId>sentry-maven-plugin</artifactId>
 <version>0.0.4</version>
 <extensions>true</extensions>
 <configuration>
 <!-- for showing output of sentry-cli -->
 <debugSentryCli>true</debugSentryCli>
 <org>sentry</org>
 <project>plugin</project>
 <!-- in case you're self hosting, provide the URL here -->
 <url>THE-URL</url>
 <!-- provide your auth token via SENTRY_AUTH_TOKEN environment variable -->
 <authToken>AUTH-TOKEN</authToken>
 </configuration>
 <executions>
 <execution>
 <goals>
 <!--
 Generates a JVM (Java, Kotlin, etc.) source bundle and uploads your source code to Sentry.
 This enables source context, allowing you to see your source
 code as part of your stack traces in Sentry.
 -->
 <goal>uploadSourceBundle</goal>
 </goals>
 </execution>
 </executions>
 </plugin>
 </plugins>
 </build>
</project>

Maybe someone has encountered a similiar problem and found a solution?

You must be logged in to vote

You might get more qualified help from Spigot people but I'm guessing you either have to do some maven setup to get Sentry included in your JAR or there already is another JAR, you're building that includes it.

Edit:
Maybe something like the following could work, but you'll probably have to do some more tweaking:

 <build>
 <plugins>
 <plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-assembly-plugin</artifactId>
 <configuration>
 <archive>
 <manifest>
 <mainClass>
 io.sentry.samples.maven.SampleApplicati...

Replies: 3 comments 1 reply

Comment options

Hello @Miracusa I've never created a Spigot-Plugin. I'm assuming you're building your plugin as a JAR file. Can you look into that JAR file and check if Sentry is in there?

You must be logged in to vote
0 replies
Comment options

Yes, it's a .jar File. I don't see sentry in it. There is a sentry-debug-meta.properties wich, going by the name, has something to do with sentry, but there is no additional .jar oder anything else looking like it has something to do with sentry.

Addition. I don't know if that help, but this is the build-job:

java-build:
 image: maven:3-openjdk-17
 stage: build
 cache:
 key: "maven-$CI_COMMIT_REF_SLUG"
 paths:
 - .m2/repository
 script:
 - mvn $MAVEN_CLI_OPTS package -DskipTests=true
 - mkdir -p /root/ext-keys
 - echo "$SSH_PRIVATE_KEY" > /root/ext-keys/deploy_key
 - chmod 600 /root/ext-keys/deploy_key
 - find "$CI_PROJECT_DIR/target/" -name "*.jar" -exec scp -q -C -o StrictHostKeyChecking=no -i /root/ext-keys/deploy_key {} root@some-ip:/home/gitlab-temp/$CI_PIPELINE_ID.jar \;
 artifacts:
 name: "foxarchiv"
 paths:
 - "**/target"
You must be logged in to vote
1 reply
Comment options

You might get more qualified help from Spigot people but I'm guessing you either have to do some maven setup to get Sentry included in your JAR or there already is another JAR, you're building that includes it.

Edit:
Maybe something like the following could work, but you'll probably have to do some more tweaking:

 <build>
 <plugins>
 <plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-assembly-plugin</artifactId>
 <configuration>
 <archive>
 <manifest>
 <mainClass>
 io.sentry.samples.maven.SampleApplication
 </mainClass>
 </manifest>
 </archive>
 <descriptorRefs>
 <descriptorRef>jar-with-dependencies</descriptorRef>
 </descriptorRefs>
 </configuration>
 <executions>
 <execution>
 <phase>package</phase>
 <goals>
 <goal>single</goal>
 </goals>
 </execution>
 </executions>
 </plugin>
 </plugins>
 </build>

Edit2: If there's multiple JAR files that are built into your target dir by maven, you might also have to adjust your find + scp command.

Edit3: Maybe this page helps. It seems to suggest shading your dependency.

Answer selected by Miracusa
Comment options

Yes, this kind of was the answer. I used a little different configuration, but I know have a .jar with everything in it that needs to be in it to have it not throw errors :)

Thats what i use now:

 <plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-assembly-plugin</artifactId>
 <executions>
 <execution>
 <id>create-my-bundle</id>
 <phase>package</phase>
 <goals>
 <goal>single</goal>
 </goals>
 <configuration>
 <descriptorRefs>
 <descriptorRef>jar-with-dependencies</descriptorRef>
 </descriptorRefs>
 </configuration>
 </execution>
 </executions>
 </plugin>

Looks pretty similar to me. I get 2 .jars (one with and one without the dependencys, but the find command in the pipeline-job will do the trick to get me the right one)

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /