JavaFx Resources (css) and OSGi

I have an osgi (felix) javafx application. When the application starts, I get:

May 30, 2015 10:44:59 PM com.sun.javafx.css.StyleManager loadStylesheetUnPrivileged
WARNING: Resource "com/sun/javafx/scene/control/skin/modena/modena.css" not found.
May 30, 2015 10:44:59 PM com.sun.javafx.css.StyleManager loadStylesheetUnPrivileged
WARNING: Resource "com/sun/javafx/scene/control/skin/modena/modena.css" not found.

And my steps are without CSS rules (and borders, etc.). The only solution I found is

Bundle systemBundle =FrameworkUtil.getBundle(MyApplication.class).getBundleContext().getBundle(0);
URL url0=systemBundle.getResource("com/sun/javafx/scene/control/skin/modena/modena.css");
URL url1=systemBundle.getResource("com/sun/javafx/scene/control/skin/modena/modena-no-transparency.css");
scene.getStylesheets().add(url0.toString());
scene.getStylesheets().add(url1.toString());

However, this is a bad decision, and in addition, I need to do this for each stage. What is the best solution to solve this problem?

+4
source share
1 answer

I have found the answer. It was necessary to add packages to import into the manifest.mf file. Since I use maven, this can be done via maven-bundle-plugin

<plugin>
   <groupId>org.apache.felix</groupId>
   <artifactId>maven-bundle-plugin</artifactId>
   <version>2.3.7</version>
   <extensions>true</extensions>
   <configuration>
       <instructions>
         <Import-Package>com.sun.javafx.scene.control.skin.modena,*</Import-Package>
       </instructions>
   </configuration>
</plugin>

The most important thing is the asterisk at the end. This is necessary in order to add all automatically detected packages required for this package. If we omit this sign, we will have to add all the packages manually.

+1
source

All Articles