SpringBoot springboot3.2.1 Custom class loader unknown protocol: nested An unknown protocol: nested error occurs when loading the org.springframework.boot.loader.net.protocol.jar.JarUrlConnection class.

Comment From: wilkinsona

Thanks for the report. Unfortunately, a screenshot tells us very little about the problem or what needs to be done to reproduce it. If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

Comment From: wxq851685279

SpringBoot springboot3.2.1 Custom class loader unknown protocol: nested

Comment From: wxq851685279

The simplest code example, an error is reported when loading the org.springframework.boot.loader.net.protocol.jar.JarUrlConnection class

public static void main(String[] args) throws ClassNotFoundException {
        Class.forName("org.springframework.boot.loader.net.protocol.jar.JarUrlConnection")
}

Comment From: wilkinsona

Unfortunately, that's not what I asked for and doesn't provide the information that I need. The handler for the nested protocol should have been registered automatically by Spring Boot's uber jar support. I can't tell why that hasn't happened in your case as I know nothing about how you have built the jar or how you are running it.

It looks like you might be trying to use org.springframework.boot.loader.net.protocol.jar.JarUrlConnection without launching your application using Spring Boot's launcher. This is not supported. If you are using the launcher (typically through java -jar) please provide the requested minimal sample.

Comment From: wxq851685279

We need to use a custom class loader. We originally used springboot2.7.8. After upgrading to 3.2.1, we found that org.springframework.boot.loader.LaunchedURLClassLoader was deleted, so we changed it to org.springframework.boot.loader.launch. LaunchedClassLoader Then the custom class inherits from org.springframework.boot.loader.net.protocol.jar.Handler, calls super.openConnection(url); the method reports an error, and finds org.springframework.boot.loader.net.protocol.jar.JarUrlConnection The code in the static code block reports an error when loading

Comment From: wilkinsona

You still haven't provided the requested information or even said whether or not you're using Spring Boot's launcher with your custom class loader. FWIW, the handler for nested, org.springframework.boot.loader.net.protocol.nested.Handler, should be loaded by the JDK if it's on the classpath. Please provide the requested sample that clearly shows what you're trying to do as simply as possible. If you cannot do so, this issue will be closed as there's nothing we can do without the information that we require.

Comment From: wxq851685279

springboot-demo.zip Can you take a look at this code? It is extracted from the project and the encryption and decryption logic is removed.

Comment From: wilkinsona

You aren't using Spring Boot launcher and you haven't set java.protocol.handler.pkgs in your own code. This means that Boot's handler for nested cannot be loaded.

You can fix this by calling org.springframework.boot.loader.net.protocol.Handlers.register() in your application's main method. However, please note that what you're doing isn't really supported and you're using Spring Boot's uber jar support in a way that was not intended. Given that you're not even using nested jars, I cannot see a reason to use LaunchedClassLoader or LaunchedURLClassLoader. A regular URLClassLoader should meet your needs.