In fastjar mode, it is not possible to add a custom URLStreamHandler using the environment variable java.protocol.handler.pkgs
I have implemented a URLStreamHandler to handle my custom protocol, let's assume it's called "myprotocol". It works properly when I start the application in the IDE, but fails to function correctly after I package it using the spring-boot-maven-plugin. The reason is that when loading the protocol's Handler, Java uses the SystemClassLoader, but the SystemClassLoader cannot load the classes I wrote in Spring Boot's fatjar. For the same reason, the URLStreamHandlerProvider also fails to load them.
Comment From: philwebb
Unfortunately we have no control over the classloader that the JDK uses to load URLStreamHandler classes. You might be able to use URL.setURLStreamHandlerFactory to programmatically register a factory that can support your handler.
The other option you have is to package your handler classes directly in the JAR rather than in a nested JAR. You can write a custom layout for that (you could look at https://github.com/spring-projects-experimental/spring-boot-thin-launcher/blob/608a66aaa85314adeb81523ba8368a102e5bd664/layout/src/main/java/org/springframework/boot/loader/thin/ThinLayout.java for inspiration).