-
Notifications
You must be signed in to change notification settings - Fork 40.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested jar URLs cannot be split and reassembled resulting in errors with projects that use this technique (such as JobRunr) #38592
Comments
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as duplicate.
This comment was marked as duplicate.
Thanks very much for the detailed report @rdehuyss. I think we've actually got two distinct bugs here so I've opened #38595 for the second. I think I have a fix for the sample project provided in jobrunr/jobrunr#884 but I'm not sure about the reproducer you attached to this issue. As it stands, that your sample is calling It then gets the JAR file URL which is There are a couple of problems here:
If I change the sample as follows, things work. @GetMapping("/get/from/nested/jar")
public String getFromNestedJar() throws IOException, URISyntaxException {
loadFileSystemIfNecessary();
Path path = fileSystem.getPath("org/jobrunr/storage/sql/common/migrations/");
boolean exists = Files.exists(path);
List<Path> list = Files.list(path).collect(Collectors.toList());
return "Root exists: " + exists + "; contents: " + list;
}
private static void loadFileSystemIfNecessary() throws IOException, URISyntaxException {
if (fileSystem == null) {
URL resource = H2StorageProvider.class.getResource("migrations");
var jarFileUrl = ((JarURLConnection) resource.openConnection()).getJarFileURL();
fileSystem = FileSystems.newFileSystem(new URI("jar:" + jarFileUrl), Collections.emptyMap());
}
} I think this makes sense because if we remove nested JARs from the picture, the original sample wouldn't work. For example, the following code: URL url = new URL("jar:file:/the.jar!/");
JarURLConnection connection = (JarURLConnection) url.openConnection();
URL jarFileUrl = connection.getJarFileURL();
FileSystem fileSystem = FileSystems.newFileSystem(jarFileUrl.toURI(), Collections.emptyMap()); Fails when
In other words, we always need the I hope that makes sense and the fix works OK. If it doesn't, please let me know. |
Hi @philwebb - thanks for your swift intervention and input. Just to be 100% sure, I changed the reproducer project to the above example you gave (still using Spring Boot 3.2.0). Is it possible I then encounter the issue about java.util.zip.ZipException: read CEN tables failed? I assume this will then be fixed in Spring Boot 3.2.1? |
That correct. There's a 3.2.1-SNAPSHOT available if you want to give that a try. It's in repo.spring.io/snapshot. You can use start.spring.io to generate a project with the maven config you need. |
Will do! Any idea on a release date already? |
@rdehuyss it's scheduled on December 21st, see https://github.com/spring-projects/spring-boot/milestones and https://calendar.spring.io |
I should have known that there is a release calendar 🤓. |
Hi @philwebb , @wilkinsona, @bclozel : I can confirm that JobRunr works again with Spring Boot 3.2.1-SNAPSHOT. Has anybody already mentioned you guys are awesome?! Thanks for the swift handling and feedback. I ❤️ that I do not need to change anything in JobRunr 🎉 (which I was expecting). |
Hi, I'm Ronald, the creator of JobRunr.
An issue was reported to us regarding the new nested jar support which broke JobRunr as it reads files from the classpath.
Inside an Uber jar, it is currently impossible to list the files within a directory using a NIO FileSystemProvider
I would expect the following to work:
The FileSystem returned is of type class org.springframework.boot.loader.nio.file.NestedFileSystem.
For a reproducible scenario, please see https://github.com/rdehuyss/spring-boot-3.2-nested-jar-issue
The text was updated successfully, but these errors were encountered: