i recently tried to update from spring-boot 3.1.6 to 3.2.0 and ran into the following problem:
java.lang.ExceptionInInitializerError: null
at ai.picovoice.porcupine.Porcupine$Builder.build(Porcupine.java:242)
...
Caused by: java.nio.file.FileSystemNotFoundException: null
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:156)
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:142)
at java.base/java.nio.file.Path.of(Path.java:209)
at java.base/java.nio.file.Paths.get(Paths.java:98)
at ai.picovoice.porcupine.Utils.getResourceDirectory(Utils.java:58)
at ai.picovoice.porcupine.Utils.<clinit>(Utils.java:39)
... 28 common frames omitted
I tried to figure out where the dependency tries to do this and found something like this:
private static Path getResourceDirectory() throws RuntimeException {
URL resourceURL = Porcupine.class.getProtectionDomain().getCodeSource().getLocation();
Path resourcePath;
try {
resourcePath = Paths.get(resourceURL.toURI());
} catch (URISyntaxException var4) {
resourcePath = Paths.get(resourceURL.getPath());
}
if (resourcePath.toString().endsWith(".jar")) {
try {
resourcePath = extractResources(resourcePath);
} catch (IOException var3) {
throw new RuntimeException("Failed to extract resources from Porcupine jar.");
}
}
return resourcePath.resolve("porcupine");
}
private static Path extractResources(Path jarPath) throws IOException {
String extractionDirName = jarPath.getFileName().toString().replace(".jar", "");
String systemTempDir = System.getProperty("java.io.tmpdir");
Path resourceDirectoryPath = (new File(systemTempDir, extractionDirName)).toPath();
if (!Files.exists(resourceDirectoryPath, new LinkOption[0])) {
try {
Files.createDirectory(resourceDirectoryPath);
} catch (IOException var13) {
logger.severe("Failed to create extraction directory at " + jarPath.toString());
var13.printStackTrace();
resourceDirectoryPath = (new File(systemTempDir)).toPath();
}
}
JarFile jf = new JarFile(jarPath.toFile());
Enumeration<JarEntry> entries = jf.entries();
while(entries.hasMoreElements()) {
JarEntry jarEntry = (JarEntry)entries.nextElement();
String jarEntryName = jarEntry.getName();
if (jarEntryName.startsWith("porcupine")) {
Path dstPath;
if (jarEntry.isDirectory()) {
dstPath = resourceDirectoryPath.resolve(jarEntryName);
if (!dstPath.toFile().exists()) {
Files.createDirectory(dstPath);
}
} else {
dstPath = resourceDirectoryPath.resolve(jarEntryName);
InputStream is = jf.getInputStream(jarEntry);
try {
Files.copy(is, dstPath, new CopyOption[]{StandardCopyOption.REPLACE_EXISTING});
} catch (Throwable var14) {
if (is != null) {
try {
is.close();
} catch (Throwable var12) {
var14.addSuppressed(var12);
}
}
throw var14;
}
if (is != null) {
is.close();
}
}
}
}
return resourceDirectoryPath;
}
I already unpacked the dependency like so (in 3.1.6 it worked):
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>net.indexoutofmj.neptune.NeptuneBot</mainClass>
<requiresUnpack>
<dependency>
<groupId>ai.picovoice</groupId>
<artifactId>picovoice-java</artifactId>
</dependency>
</requiresUnpack>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
but it seems to fail now ... and i don't know why
Can somebody help ?
Thanks in advance
Okay it was a bug in spring boot 3.2.0, since 3.2.1 it works as it should