When using maven to package a jar (unsure if it's a maven issue) the java ClassLoader can't find any resources.
Jar structure -
Value of test.class.getClassLoader().getResourceAsStream("")
(or any other existing directory) is empty. No folders or files or found.
Maven Build Script:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>9</source>
<target>9</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<transformers>
<transformer implementation=
"org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.swordofsouls.discord.chatexporter.test</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Any help would be greatly appreciated.
Thanks
Tried using different ClassLoaders.
Value of Thread.currentThread().getContextClassLoader()
is null.
Value of ClassLoader.getSystemClassLoader()
is null.
CodePudding user response:
The solution was to use
/
instead of File.separator