Exception logged when using custom css in JavaFX i

2019-09-06 08:06发布

I'm getting the exception below logged to stderr when trying to use my own custom css in JavaFX 2.2 (from JDK 7 update 11). It's funny because the css is actually found and used in my application so the only thing wrong is the exception in the logs. I also load up other resources this way (images, fonts etc) and there are no exceptions logged in these cases.

I'm loading the css like this:

val cssResource = getClass.getResource("/com/openaf/browser/gui/resources/openaf.css").toExternalForm
println("CSS Resource:    " + cssResource)
println("")
scene.getStylesheets.add(cssResource)

and you can see from the output that it is found (and I'm not sure why in the exception it says **.bss but maybe that's felix doing some internal bundle renaming.

Does anyone know why this exception is being logged and/or how to get rid of it?

CSS Resource:    bundle://21.57:1/com/openaf/browser/gui/resources/openaf.css

java.io.IOException: Resource does not exist: bundle://21.57:1/com/openaf/browser/gui/resources/openaf.bss
java.io.IOException: Resource does not exist: bundle://21.57:1/com/openaf/browser/gui/resources/openaf.bss
at org.apache.felix.framework.URLHandlersBundleURLConnection.<init>(URLHandlersBundleURLConnection.java:136)
at org.apache.felix.framework.URLHandlersBundleStreamHandler.openConnection(URLHandlersBundleStreamHandler.java:64)
at java.net.URL.openConnection(URL.java:971)
at java.net.URL.openStream(URL.java:1037)
at com.sun.javafx.css.Stylesheet.loadBinary(Stylesheet.java:201)
at com.sun.javafx.css.StyleManager.loadStylesheetUnPrivileged(StyleManager.java:572)
at com.sun.javafx.css.StyleManager.loadStylesheet(StyleManager.java:411)
at com.sun.javafx.css.StyleManager.updateStylesheets(StyleManager.java:858)
at javafx.stage.Window.impl_visibleChanging(Window.java:818)
at javafx.stage.Stage.impl_visibleChanging(Stage.java:922)
at javafx.stage.Window$10.invalidated(Window.java:689)
at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:127)
at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:161)
at javafx.stage.Window.setShowing(Window.java:782)
at javafx.stage.Window.show(Window.java:797)
at javafx.stage.Stage.show(Stage.java:229)
at com.openaf.browser.gui.BrowserStageManager.createStage(BrowserStageManager.scala:64)
at com.openaf.browser.gui.BrowserStageManager.start(BrowserStageManager.scala:41)
at com.openaf.browser.gui.BrowserBundleActivator$$anonfun$startUp$2.apply$mcV$sp(BrowserBundleActivator.scala:32)
at com.openaf.browser.gui.utils.BrowserUtils$$anon$1.run(BrowserUtils.scala:48)
at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)

1条回答
我想做一个坏孩纸
2楼-- · 2019-09-06 08:52

Either convert your CSS files to the binary BSS format:

http://docs.oracle.com/javafx/2/deployment/packaging.htm#BABCACBD

or use "-Dbinary.css=false" when you run your application.

Also note that I've recently released an initial version of Drombler FX, a modular RCP for JavaFX based on OSGi and Maven (POM-first):

http://puces-blog.blogspot.ch/2012/12/drombler-fx-building-modular-javafx.html

http://wiki.drombler.org/GettingStarted

By default it uses Apache Felix as well. Maybe you find it useful.

查看更多
登录 后发表回答