0

I'm making a spigot plugin and in the onDisable function (which gets called when the server shuts down) I have it save my data. The problem is is that when it disables for some reason it cannot find one of the classes (ObjectWriter) that I use to save the data.Traceback of the error, says that the class cannot be found

However as shown in the following screenshot that class is very much there and very much present, which can also be proven by the fact that I can save it normally and it works just fine. It is only when the plugin disables that I have this issue.Shows the inside of the jar file, the path on the top shows where the class is located and it shows the class in the correct package

I've been trying to fix this issue for months. Yes, I have tried running mvn clean. Yes, I have tried deleting the dependency jar in case it's corrupted. I have scoured SO since I had the problem and tried every. single. post. None of them have worked. I don't think this is a problem with maven more than it is a problem with the dependencies closing before the plugin finishes, because sometimes it does work and doesn't error. It's extremely confusing to me and I have no idea what to do.

Here is my pom.xml if anyone wants to review it:

<?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>com.uhmily</groupId>
    <artifactId>scovilleplugin</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>ScovillePlugin</name>

    <description>The Main Plugin for the Scoville Parkour Server</description>
    <properties>
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.nms.path>C:/Users/depia/Documents/My_Stuff/Programs/Minecraft/spigot-1.12.jar</project.nms.path>
        <project.mainClass>ScovillePlugin</project.mainClass>
        <jackson.version>2.13.1</jackson.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.3.1-SNAPSHOT</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <createDependencyReducedPom>false</createDependencyReducedPom>
                            <artifactSet>
                                <includes>
                                    <!-- <include>com.fasterxml.jackson.core:jackson-databind</include>
                                    <include>com.fasterxml.jackson.core:jackson-core</include>
                                    <include>com.fasterxml.jackson.core:jackson-annotations</include> -->
                                    <include>com.fasterxml.jackson.*:*</include>
                                    <include>de.tr7zw:*</include>
                                </includes>
                            </artifactSet>
                            <relocations>
                                <!-- <relocation>
                                    <pattern>com.fasterxml.jackson.core</pattern>
                                    <shadedPattern>${project.groupId}.${project.artifactId}.shaded.com.fasterxml.jackson.core</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>com.fasterxml.jackson.databind</pattern>
                                    <shadedPattern>${project.groupId}.${project.artifactId}.shaded.com.fasterxml.jackson.databind</shadedPattern> -->
                                <relocation>
                                    <pattern>com.fasterxml.jackson</pattern>
                                    <shadedPattern>${project.groupId}.${project.artifactId}.shaded.com.fasterxml.jackson</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>de.tr7zw.changeme.nbtapi</pattern>
                                    <shadedPattern>${project.groupId}.${project.artifactId}.shaded.de.tr7zw.changeme.nbtapi</shadedPattern>
                                </relocation>
                            </relocations>
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/**</exclude>
                                        <exclude>module-info.class</exclude>
                                        <exclude>LICENSE</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <manifestEntries>
                                        <Main-Class>${project.groupId}.${project.artifactId}.${project.mainClass}</Main-Class>
                                        <Build-Number>${project.version}</Build-Number>
                                    </manifestEntries>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>

    <repositories>
        <repository>
            <id>spigotmc-repo</id>
            <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
        </repository>
        <repository>
            <id>sonatype</id>
            <url>https://oss.sonatype.org/content/groups/public/</url>
        </repository>
        <repository>
            <id>enginehub</id>
            <url>https://maven.enginehub.org/repo/</url>
        </repository>
        <repository>
            <id>plotsquared</id>
            <url>https://plotsquared.com/mvn/</url>
        </repository>
        <repository>
            <id>placeholderapi</id>
            <url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
        </repository>
        <repository>
            <id>codemc-repo</id>
            <url>https://repo.codemc.org/repository/maven-public/</url>
            <layout>default</layout>
        </repository>
        <repository>
            <id>sk89q-repo</id>
            <url>https://maven.enginehub.org/repo/</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>maven-snapshot</id>
            <url>https://repository.apache.org/content/repositories/snapshots</url>
        </pluginRepository>
    </pluginRepositories>

    <dependencies>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.12-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jetbrains</groupId>
            <artifactId>annotations</artifactId>
            <version>23.0.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>net.minecraft</groupId>
            <artifactId>server</artifactId>
            <version>v1.12</version>
            <scope>system</scope>
            <systemPath>${project.nms.path}</systemPath>
        </dependency>
        <dependency>
            <groupId>com.plotsquared</groupId>
            <artifactId>plotsquared-api</artifactId>
            <version>3.1</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>me.clip</groupId>
            <artifactId>placeholderapi</artifactId>
            <version>2.9.2</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>de.tr7zw</groupId>
            <artifactId>item-nbt-api</artifactId>
            <version>2.8.0</version>
        </dependency>
        <dependency>
            <groupId>com.sk89q.worldguard</groupId>
            <artifactId>worldguard-legacy</artifactId>
            <version>6.2</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.sk89q.worldedit</groupId>
            <artifactId>worldedit-core</artifactId>
            <version>6.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>net.luckperms</groupId>
            <artifactId>api</artifactId>
            <version>5.4</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>
DePianoman
  • 170
  • 1
  • 1
  • 10

1 Answers1

0

I have found out due to this post that this happens when you replace the jar file before shutting down the server. This would explain all of the behavior I've been experiencing.

DePianoman
  • 170
  • 1
  • 1
  • 10