Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error using the Ikonli font library java.lang.UnsupportedOperationException #11

Closed
truongton92 opened this issue Sep 29, 2017 · 19 comments

Comments

@truongton92
Copy link

truongton92 commented Sep 29, 2017

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

@aalmiray
Copy link
Collaborator

I've setup a simple AfterburnerFx project with Ikonli 2.0.0 at https://github.com/aalmiray/sample-ikonli-app
The icon is loaded as expected running with

Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T21:39:06+02:00)
Maven home: /Users/aalmiray/.sdkman/candidates/maven/current
Java version: 1.8.0_144, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.5", arch: "x86_64", family: "mac"

@svininykh
Copy link

svininykh commented Dec 15, 2017

I had also problem try add Ikonli to Netbeans Maven JavaFX project.

import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import org.kordamp.ikonli.javafx.FontIcon;
import org.kordamp.ikonli.weathericons.WeatherIcons;

public class FXMLController implements Initializable {
    
    @FXML
    private Label label;
    
    @FXML
    private void handleButtonAction(ActionEvent event) {
        System.out.println("You clicked me!");        
        FontIcon fontIcon = new FontIcon(WeatherIcons.SNOW);
        label.setGraphic(fontIcon);
    }
    
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }    
}

Exception:

Exception in thread "JavaFX Application Thread" java.lang.UnsupportedOperationException: Cannot resolve 'wi-snow'
  at org.kordamp.ikonli.javafx.IkonResolver.resolveIkonHandler(IkonResolver.java:60)
  at org.kordamp.ikonli.javafx.FontIcon.setIconCode(FontIcon.java:215)
  at org.kordamp.ikonli.javafx.FontIcon$8.changed(FontIcon.java:174)
  at org.kordamp.ikonli.javafx.FontIcon$8.changed(FontIcon.java:171)
  at com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:182)
  at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
  at javafx.beans.property.ObjectPropertyBase.fireValueChangedEvent(ObjectPropertyBase.java:105)
  at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:112)
  at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:146)
  at javafx.css.StyleableObjectProperty.set(StyleableObjectProperty.java:82)
  at org.kordamp.ikonli.javafx.FontIcon.setIconCode(FontIcon.java:214)
  at org.kordamp.ikonli.javafx.FontIcon.<init>(FontIcon.java:86)
  at mobi.nordpos.ikonli.FXMLController.handleButtonAction(FXMLController.java:20)
  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.GeneratedMethodAccessor1.invoke(Unknown Source)
  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 javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1769)
  at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657)
  at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
  at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
  at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
  at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
  at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
  at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
  at javafx.event.Event.fireEvent(Event.java:198)
  at javafx.scene.Node.fireEvent(Node.java:8413)
  at javafx.scene.control.Button.fire(Button.java:185)
  at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
  at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
  at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
  at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
  at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
  at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
  at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
  at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
  at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
  at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
  at javafx.event.Event.fireEvent(Event.java:198)
  at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
  at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
  at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
  at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
  at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:381)
  at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
  at java.security.AccessController.doPrivileged(Native Method)
  at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(GlassViewEventHandler.java:417)
  at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
  at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:416)
  at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
  at com.sun.glass.ui.View.notifyMouse(View.java:937)
  at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
  at com.sun.glass.ui.gtk.GtkApplication.lambda$null$49(GtkApplication.java:139)
  at java.lang.Thread.run(Thread.java:745)

Can you help me also?

@aalmiray
Copy link
Collaborator

Are you running the application within NetBeans? The only thing I can think of right now would be a classloading issue, but even that would be quite strange if it were true.

I see in your code that the there's an import statement for the WeatherIcons class, thus the ikonli-weathericons-pack JAR should be available on your compile classpath. It should also be available at runtime. If these two conditions are true then IkonResolver can only fail to resolve an ikon definition if the expected resources (in this case META-INF/resources/weathericons/2.0.10/fonts/weathericons-regular-webfont.ttf are not found in the classpath. These resources are part of the ikonli-weathericons-pack JAR which we expect to see inside the runtime classpath.

Have you tried running the application on the command line alone (apply the maven-exec-java plugin)? If this works then there's some misconfiguration in NetBeans. If it does not work then there's a misconfiguration on the project's dependencies.

@nilsreiter
Copy link

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.

@aalmiray
Copy link
Collaborator

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.

@aalmiray
Copy link
Collaborator

aalmiray commented Mar 1, 2018

ping 😼

@mataide
Copy link

mataide commented Mar 1, 2018

I have the same problem here, the program works fine but the scene builder crash after you include FontIcon in FXML.

java.io.IOException: javafx.fxml.LoadException: 
/D:/Users/marcus/Documents/Workspace/proak-desktop/src/main/resources/view/fragment/launcher/team/TeamInfo.fxml:66

	at com.oracle.javafx.scenebuilder.kit.fxom.FXOMLoader.load(FXOMLoader.java:92)
	at com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument.<init>(FXOMDocument.java:82)
	at com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument.<init>(FXOMDocument.java:97)
	at com.oracle.javafx.scenebuilder.kit.editor.EditorController.updateFxomDocument(EditorController.java:2384)
	at com.oracle.javafx.scenebuilder.kit.editor.EditorController.setFxmlTextAndLocation(EditorController.java:664)
	at com.oracle.javafx.scenebuilder.app.DocumentWindowController.loadFromFile(DocumentWindowController.java:385)
	at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.performOpenFiles(SceneBuilderApp.java:634)
	at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.handleOpenFilesAction(SceneBuilderApp.java:489)
	at com.oracle.javafx.scenebuilder.app.AppPlatform$MessageBoxDelegate.lambda$messageBoxDidGetMessage$0(AppPlatform.java:206)
	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)
	at java.lang.Thread.run(Thread.java:745)
Caused by: javafx.fxml.LoadException: 
/D:/Users/marcus/Documents/Workspace/proak-desktop/src/main/resources/view/fragment/launcher/team/TeamInfo.fxml:66

	at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
	at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2579)
	at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2425)
	at com.oracle.javafx.scenebuilder.kit.fxom.FXOMLoader.load(FXOMLoader.java:89)
	... 15 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)
	... 17 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.GeneratedMethodAccessor1.invoke(Unknown Source)
	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)
	... 25 more
Caused by: java.lang.UnsupportedOperationException: Cannot resolve 'fa-home'
	at org.kordamp.ikonli.javafx.IkonResolver.resolveIkonHandler(IkonResolver.java:60)
	at org.kordamp.ikonli.javafx.FontIcon.setIconLiteral(FontIcon.java:252)
	... 35 more

@mataide
Copy link

mataide commented Mar 1, 2018

Oh sorry, in my case, was missing ikonli-fontawesome-pack in SceneBuilder

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

@nilsreiter
Copy link

I will, thanks!

@siva-kranthi
Copy link

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

@aalmiray
Copy link
Collaborator

The last stacktrace points to a CNFE as the cause. Are you using JDK9 or greater?

@leonlogli
Copy link

I am having the same issue when I packaged a fat jar file using the maven-shade-plugin. I am using OpenJDK 11.0.1, Javafx11.0.1 and ikonli 11.0.2

Caused by: java.lang.UnsupportedOperationException: Cannot resolve 'fa-circle-thin'
at org.kordamp.ikonli.javafx.IkonResolver.resolveIkonHandler(IkonResolver.java:62)
at org.kordamp.ikonli.javafx.FontIcon.setIconLiteral(FontIcon.java:255)

@leonlogli
Copy link

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

@wulf0r
Copy link

wulf0r commented Dec 20, 2019

For anyone still affected:
I solved this by using the gradle shadow plugin "com.github.johnrengelman.shadow" with a call to mergeServiceFiles() configuration. This sets the file META-INF/services/org.kordamp.ikonli.IkonHandler to this content and now the icon loading from the JAR works:

# Generated by org.kordamp.jipsy.processor.service.ServiceProviderProcessor (0.4.1)
# Wed, 19 Sep 2018 16:53:12 +0200
org.kordamp.ikonli.fontawesome.FontAwesomeIkonHandler
org.kordamp.ikonli.IkonliIkonResolver

jsarabia added a commit to Bible-Translation-Tools/Orature that referenced this issue Feb 13, 2020
Ikonli requires merging service files, or there is a runtime exception when loading a page with a FontIcon.

Solution from:
kordamp/ikonli#11
jsarabia added a commit to Bible-Translation-Tools/Orature that referenced this issue Feb 13, 2020
Ikonli requires merging service files, or there is a runtime exception when loading a page with a FontIcon.

Solution from:
kordamp/ikonli#11
@pangbuddy
Copy link

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!

@frapa
Copy link

frapa commented Jul 5, 2020

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

@marvk
Copy link

marvk commented Jan 15, 2021

@frapa this will only work if you are using one icon pack. Multiple icon packs require the use of the aforementioned transformer for maven shade.

@iazarny
Copy link

iazarny commented Jun 3, 2021

Correct order for dependency when building shade

    <!-- https://mvnrepository.com/artifact/org.kordamp.ikonli/ikonli-javafx -->
    <dependency>
        <groupId>org.kordamp.ikonli</groupId>
        <artifactId>ikonli-fontawesome-pack</artifactId>
        <version>11.5.0</version>
    </dependency>



    <!-- https://mvnrepository.com/artifact/org.kordamp.ikonli/ikonli-javafx -->
    <dependency>
        <groupId>org.kordamp.ikonli</groupId>
        <artifactId>ikonli-javafx</artifactId>
        <version>11.5.0</version>
    </dependency>

The META-INF/service/org.kordamp.ikonli.IkonHandler in shade jar must have the following content

org.kordamp.ikonli.fontawesome.FontAwesomeIkonHandler`

@dalegaspi
Copy link

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

@leonlogli not all heroes wear capes. 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests