ikonli: Error using the Ikonli font library java.lang.UnsupportedOperationException

Follow the font instructions from https://aalmiray.github.io/ikonli/

I use two dependencies for my javafx as follows

<dependency>
        <groupId>org.kordamp.ikonli</groupId>
        <artifactId>ikonli-javafx</artifactId>
        <version>1.9.0</version>
    </dependency>
    <dependency>
        <groupId>org.kordamp.ikonli</groupId>
        <artifactId>ikonli-fontawesome-pack</artifactId>
        <version>1.9.0</version>
    </dependency>

My XML file

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.VBox?>
<?import org.kordamp.ikonli.javafx.FontIcon?>

<VBox id="VBox" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="touya.akira.parser.ParserPresenter">
   <children>
       <Button mnemonicParsing="false">
         <graphic>
            <FontIcon iconLiteral="fa-address-book" />
         </graphic>
       </Button>
   </children>
</VBox>

ERROR


--- exec-maven-plugin:1.2.1:exec (default-cli) @ Touya-Akira ---
Exception in Application start method
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
    at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: Cannot load touya.akira.parser.parser
    at com.airhacks.afterburner.views.FXMLView.loadSynchronously(FXMLView.java:101)
    at com.airhacks.afterburner.views.FXMLView.initializeFXMLLoader(FXMLView.java:125)
    at com.airhacks.afterburner.views.FXMLView.getView(FXMLView.java:137)
    at touya.akira.MainApp.start(MainApp.java:16)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
    ... 1 more
Caused by: javafx.fxml.LoadException: 
file:/E:/Java/NetBeansProjects/Touya-Akira/main/1.0.6/Touya-Akira/target/Touya-Akira-1.0.6.jar!/touya/akira/parser/parser.fxml:13

    at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2579)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
    at com.airhacks.afterburner.views.FXMLView.loadSynchronously(FXMLView.java:99)
    ... 12 more
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at com.sun.javafx.fxml.BeanAdapter.put(BeanAdapter.java:262)
    at com.sun.javafx.fxml.BeanAdapter.put(BeanAdapter.java:54)
    at javafx.fxml.FXMLLoader$Element.applyProperty(FXMLLoader.java:512)
    at javafx.fxml.FXMLLoader$Element.processValue(FXMLLoader.java:363)
    at javafx.fxml.FXMLLoader$Element.processPropertyAttribute(FXMLLoader.java:325)
    at javafx.fxml.FXMLLoader$Element.processInstancePropertyAttributes(FXMLLoader.java:235)
    at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:767)
    at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2823)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2532)
    ... 15 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
    at com.sun.javafx.fxml.BeanAdapter.put(BeanAdapter.java:258)
    ... 23 more
Caused by: java.lang.UnsupportedOperationException: Cannot resolve 'fa-circle-thin'
    at org.kordamp.ikonli.javafx.IkonResolver.resolveIkonHandler(IkonResolver.java:60)
    at org.kordamp.ikonli.javafx.FontIcon.setIconLiteral(FontIcon.java:232)
    ... 34 more
Exception running application touya.akira.MainApp
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 5.914s
Finished at: Fri Sep 29 08:49:05 ICT 2017
Final Memory: 14M/35M
But if I use dependencies

<dependency>
    <groupId>org.kordamp.ikonli</groupId>
    <artifactId>ikonli-devicons-pack</artifactId>
    <version>1.9.0</version>
</dependency>

<FontIcon iconLiteral="di-android" />

then it can work but with other dependencies i try it the above error appears

What am I missing here? What should I do to make this work? Please help me

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 19

Commits related to this issue

Most upvoted comments

I had the same issue, but only when I packaged a jar file using the maven-shade-plugin, and not in Eclipse. I was able to solve it by including the icon pack dependency before the core and swing dependencies. I don’t exactly understand why though, but maybe it helps.

Problem solved

For maven-shade-plugin users, add this to your transformers

<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>

For more information about Resource Transformers, refer to this page

I am also facing same issue. Project runs properly in IDEA. But after generating fat jar, it is failing.

My dependencies

 dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
     compile 'org.kordamp.ikonli:ikonli-javafx:2.1.1'
     compile 'org.kordamp.ikonli:ikonli-feather-pack:2.1.1'
 }

Tried Gradle fatjar, shadow jar & javafx-gradle-plugin jar.Only javafx-gradle-plugin jar worked

Gradle fat jar - Not working

task fatJar(type: Jar) {
    manifest.from jar.manifest
    baseName = project.name + '-all'
    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
    with jar
}

In generated jar under META-info/services 2 org.kordamp.ikonli.IkonHandler files are available

Caused by: java.lang.UnsupportedOperationException: Cannot resolve 'fth-speech-bubble'
        at org.kordamp.ikonli.javafx.IkonResolver.resolveIkonHandler(IkonResolver.java:60)
        at org.kordamp.ikonli.javafx.FontIcon.setIconLiteral(FontIcon.java:252)
        at Main.start(Main.java:18)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:919)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$11(PlatformImpl.java:449)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$9(PlatformImpl.java:418)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:417)
        at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:175)

Shadow jar - Not working

shadowJar {
    baseName = 'shadowjar'
    mergeServiceFiles()    //For Merging Service Descriptor Files
}

In generated jar, under META-info/services 1 org.kordamp.ikonli.IkonHandler file is available from feather

Caused by: java.lang.NoClassDefFoundError: com/sun/javafx/css/converters/SizeConverter
        at org.kordamp.ikonli.javafx.FontIcon$StyleableProperties.<clinit>(FontIcon.java:265)
        at org.kordamp.ikonli.javafx.FontIcon.getClassCssMetaData(FontIcon.java:321)
        at org.kordamp.ikonli.javafx.FontIcon.getCssMetaData(FontIcon.java:325)
        at javafx.graphics/javafx.scene.CssStyleHelper$CacheContainer.<init>(CssStyleHelper.java:402)
        at javafx.graphics/javafx.scene.CssStyleHelper$CacheContainer.<init>(CssStyleHelper.java:362)
        at javafx.graphics/javafx.scene.CssStyleHelper.createStyleHelper(CssStyleHelper.java:177)
        at javafx.graphics/javafx.scene.Node.reapplyCss(Node.java:9442)
        at javafx.graphics/javafx.scene.Node.reapplyCSS(Node.java:9405)
        at javafx.graphics/javafx.scene.Node.invalidatedScenes(Node.java:1087)
        at javafx.graphics/javafx.scene.Node.setScenes(Node.java:1152)

javafx-gradle-plugin - Working

https://github.com/FibreFoX/javafx-gradle-plugin

Creates a jar file with classpath link to 3 ikonli jar files. It is working fine

Class-Path: lib/ikonli-feather-pack-2.1.1.jar lib/ikonli-core-2.1.1.jar lib/ikonli-javafx-2.1.1.jar

How to make it work with shadow jar. Please help

I solved this by putting the icon pack dependency first in the pom.xml file.

Problem solved

For maven-shade-plugin users, add this to your transformers

<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>

For more information about Resource Transformers, refer to this page

This solution woks to me!

This appears to be a problem caused by missing resources. If you’re creating a shaded/fatjar version then you must make sure that all resources under META-INF/services are merged correctly. Refer to the documentation of the particular plugin (Shade for Maven, Shadow for Gradle) on how to configure the build to merge service files.