2013-03-03 17 views
0

當我嘗試在JavaFX 2.2(從JDK 7更新11)中使用我自己的自定義css時,出現以下記錄到stderr的異常。這很有趣,因爲css實際上是在我的應用程序中找到並使用的,所以唯一錯誤的是日誌中的異常。我也以這種方式加載其他資源(圖像,字體等),並且在這些情況下沒有例外記錄。在Felix OSGI中使用JavaFX中的自定義css時記錄的異常

我加載像這樣的CSS:

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

,你可以從輸出中看到的,它被發現(我不知道爲什麼在例外它說* *的.bss但也許這就是菲利克斯做一些內部包重命名。

有誰知道爲什麼被記錄此異常和/或如何擺脫它?

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

要麼你的CSS文件轉換爲二進制格式BSS:

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

,或者當你運行你的應用程序中使用「-Dbinary.css =假」。

另外請注意,我最近公佈的Drombler FX,基於OSGi和Maven JavaFX的模塊化RCP的初始版本(POM-在前):

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

http://wiki.drombler.org/GettingStarted

通過默認情況下它也使用Apache Felix。也許你覺得它很有用。

+0

Equinox-OSGi從bundle中加載CSS文件沒有問題 - Felix可能沒有設置URL-Resolver嗎? – tomsontom 2013-03-03 19:20:06

+0

謝謝,使用-Dbinary.css = false標誌按預期工作。那麼javafx會嘗試加載二進制文件,以及何時它不能回退到文本css?並通過嘗試加載二進制felix無法找到它,所以輸出異常? – Boomah 2013-03-03 19:48:20

+0

tomsontom,我沒有做任何特別的URL解析器 - 我也加載其他資源就好了。 – Boomah 2013-03-03 19:49:56

相關問題