With a standalone application I can register an URLStreamHandlerProvider via the service loader. But this does not work with a war file in an application server like Tomcat or WildFly.
The alternate solution via URL.setURLStreamHandlerFactory( x ) does also not work. Only one can call this and the application service has already do it.
The third hack via reflection no longer works with Java 17.
java.lang.reflect.InaccessibleObjectException: Unable to make field static java.util.Hashtable java.net.URL.handlers accessible: module java.base does not "opens java.net" to unnamed module
Are there other solutions inside an application to register an URLStreamHandlerProvider? For example via web.xml or Servlet API? Are there individual solutions for single application server?