Skip to content
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

spring-boot-maven-plugin repackage uber jar execution fails when jar is put on WSL network drive #38956

Closed
pdeneve opened this issue Jan 2, 2024 · 2 comments
Assignees
Labels
type: regression A regression from a previous release
Milestone

Comments

@pdeneve
Copy link
Contributor

pdeneve commented Jan 2, 2024

When the uber jar created with spring-boot-maven-plugin:3.2.1 (repackage goal) is put on a WSL (Windows subsystem for Linux) network drive, the following error is emitted when running the jar:

$ java -jar \\wsl$\debian\spring-boot_3.2.1-uber-jar-issue-0.0.1.jar
Exception in thread "main" java.lang.ClassNotFoundException: be.pdn.issue.sbmp.Main
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:593)
        at org.springframework.boot.loader.net.protocol.jar.JarUrlClassLoader.loadClass(JarUrlClassLoader.java:104)
        at org.springframework.boot.loader.launch.LaunchedClassLoader.loadClass(LaunchedClassLoader.java:91)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:534)
        at java.base/java.lang.Class.forName(Class.java:513)
        at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:88)
        at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:53)
        at org.springframework.boot.loader.launch.JarLauncher.main(JarLauncher.java:58)

This is not the case when the uber jar is created with spring-boot-maven-plugin:3.1.7

$ java -jar \\wsl$\debian\spring-boot_3.1.7-uber-jar-issue-0.0.1.jar
If you see this it works

As a workaround it is possible to set CLASSIC in spring-boot-maven-plugin, see release notes for details.

Tested on Windows 11 with Java 21. Example project to reproduce: spring-boot-uber-jar-issue.tar.gz.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 2, 2024
@wilkinsona
Copy link
Member

wilkinsona commented Jan 3, 2024

I'm not familiar with WSL, unfortunately, and I don't think anyone on the Spring Boot team has used it. Is \\wsl$\debian\spring-boot_3.2.1-uber-jar-issue-0.0.1.jar pointing to a jar file on the Linux filesystem from within Windows? If so, does mounting that path to a Windows drive help to work around the problem? I also wonder if other UNC paths are affected or, perhaps, the $ here is crucial (possibly due to URL encoding).

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Jan 3, 2024
@pdeneve
Copy link
Contributor Author

pdeneve commented Jan 5, 2024

Affirmative, \\wsl$\debian\spring-boot_3.2.1-uber-jar-issue-0.0.1.jar is pointing to a jar file on the Linux filesystem from within Windows.

I've tested a couple of things and it seems the issue is the UNC path, not the dollar sign. Mapping the network share as a drive works around the issue. Here's the output of my tests:

C:\d\apps\jdk\jdk-21.0.1\bin>.\java -jar \\wsl.localhost\Debian\home\philippe\spring-boot_3.1.7-uber-jar-issue-0.0.1.jar
If you see this it works

C:\d\apps\jdk\jdk-21.0.1\bin>.\java -jar \\wsl.localhost\Debian\home\philippe\spring-boot_3.2.1-uber-jar-issue-0.0.1.jar
Exception in thread "main" java.lang.ClassNotFoundException: be.pdn.issue.sbmp.Main
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:593)
        at org.springframework.boot.loader.net.protocol.jar.JarUrlClassLoader.loadClass(JarUrlClassLoader.java:104)
        at org.springframework.boot.loader.launch.LaunchedClassLoader.loadClass(LaunchedClassLoader.java:91)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:534)
        at java.base/java.lang.Class.forName(Class.java:513)
        at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:88)
        at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:53)
        at org.springframework.boot.loader.launch.JarLauncher.main(JarLauncher.java:58)

C:\d\apps\jdk\jdk-21.0.1\bin>.\java -jar Z:\home\philippe\spring-boot_3.2.1-uber-jar-issue-0.0.1.jar
If you see this it works

C:\d\apps\jdk\jdk-21.0.1\bin>.\java -jar \\192.168.0.4\storage\tmp\spring-boot_3.2.1-uber-jar-issue-0.0.1.jar
Exception in thread "main" java.lang.ClassNotFoundException: be.pdn.issue.sbmp.Main
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:593)
        at org.springframework.boot.loader.net.protocol.jar.JarUrlClassLoader.loadClass(JarUrlClassLoader.java:104)
        at org.springframework.boot.loader.launch.LaunchedClassLoader.loadClass(LaunchedClassLoader.java:91)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:534)
        at java.base/java.lang.Class.forName(Class.java:513)
        at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:88)
        at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:53)
        at org.springframework.boot.loader.launch.JarLauncher.main(JarLauncher.java:58)

C:\d\apps\jdk\jdk-21.0.1\bin>.\java -jar \\192.168.0.4\storage\tmp\spring-boot_3.1.7-uber-jar-issue-0.0.1.jar
If you see this it works

Explanation on the shares used:

  1. It's possible to access a WSL linux instance via \\wsl.localhost, rather than via \\wsl$. I've used \\wsl.localhost this time to rule out the issue is related to the dollar sign.
  2. Z:\ is the drive I've mounted the WSL share on.
  3. \\192.168.0.4 is an external Windows share, i.e. not WSL, to rule out the issue is related to WSL.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jan 5, 2024
@philwebb philwebb added type: regression A regression from a previous release and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Jan 9, 2024
@philwebb philwebb added this to the 3.2.x milestone Jan 9, 2024
@wilkinsona wilkinsona self-assigned this Jan 12, 2024
@wilkinsona wilkinsona modified the milestones: 3.2.x, 3.2.2 Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

4 participants