Loading streams from URL generated by...
Status: Beta
Brought to you by:
simontuffs
I'm using one-jar via the gradle plugin in my JavaFX project.
In this configuration third party JavaFX libraries seam to have a problem with loading resources from URL generated in the following manner:
@Override protected String getUserAgentStylesheet() {
return NotificationPane.class.getResource("notificationpane.css").toExternalForm();
}
PS. I'm using this class loader:
One-Jar-URL-Factory: com.simontuffs.onejar.JarClassLoader$OneJarURLFactory
(Note that this post relates to 0.97.1 - I don't know what the situation in 0.98 is.)
We have a similar problem with our code, for example in resolution of XSLT includes. The way we "fix"/work around it is by meddling with JAR URL loading.
We put a custom JAR URL Connection handler in using
(There is some magic going on with the PROTOCOL_HANDLER_PROPERTY and the static isOneJarAvailable member that relates to how we test this code, but you get the idea.)
The OneJarAwareUrlStreamHandlerFactory looks like this (I admit that it is not perfect, but it works for us):
We basically turn every JAR URL into a onejar: URL (that is why we need part of the protocol handler initialization in OneJarContext), i.e., we force a classpath "search" of the code.
We had lots of other workarounds in place before, but made these superfluous.