kordamp / ikonli

Icon packs for Java applications
http://kordamp.org/ikonli/
Apache License 2.0
498 stars 50 forks source link

"Cannot resolve 'gmi-add'" Exception Thrown #10

Closed collinsmith closed 7 years ago

collinsmith commented 7 years ago

Hi, I'm sorry if this is the improper channel to post this, but after following your guide, I'm getting stacktraces when trying to run my program from a fat jar with JavaFX. The program runs fine with all of the icons when started from my IDE, it's only when I try and run it from a fat jar that I see the problems. Is there something special I should be doing in order to have the icons included within a fat jar?

https://github.com/collinsmith/steamlinker https://github.com/collinsmith/steamlinker/releases https://github.com/collinsmith/steamlinker/blob/master/build.gradle

PS C:\Users\csmith\Desktop> java -jar .\steamlinker-all-1.0-SNAPSHOT.jar
[DEBUG] com.gmail.collinsmith70.steamlinker.Main::<clinit> - Clearing preferences...
[FATAL] com.gmail.collinsmith70.steamlinker.Main::start -
file:/C:/Users/csmith/Desktop/steamlinker-all-1.0-SNAPSHOT.jar!/layout/main.fxml:37

javafx.fxml.LoadException:
file:/C:/Users/csmith/Desktop/steamlinker-all-1.0-SNAPSHOT.jar!/layout/main.fxml:37

        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.gmail.collinsmith70.steamlinker.Main.start(Main.java:75)
        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)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: javafx.fxml.LoadException:
file:/C:/Users/csmith/Desktop/steamlinker-all-1.0-SNAPSHOT.jar!/layout/repos.fxml:24

        at com.gmail.collinsmith70.steamlinker.ReposControl.<init>(ReposControl.java:56)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at java.lang.Class.newInstance(Class.java:442)
        at sun.reflect.misc.ReflectUtil.newInstance(ReflectUtil.java:51)
        at javafx.fxml.FXMLLoader$InstanceDeclarationElement.constructValue(FXMLLoader.java:1009)
        at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:746)
        at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2707)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527)
        ... 12 more
Caused by: javafx.fxml.LoadException:
file:/C:/Users/csmith/Desktop/steamlinker-all-1.0-SNAPSHOT.jar!/layout/repos.fxml:24

        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.gmail.collinsmith70.steamlinker.ReposControl.<init>(ReposControl.java:54)
        ... 22 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)
        ... 25 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)
        ... 33 more
Caused by: java.lang.UnsupportedOperationException: Cannot resolve 'gmi-add'
        at org.kordamp.ikonli.javafx.IkonResolver.resolveIkonHandler(IkonResolver.java:60)
        at org.kordamp.ikonli.javafx.FontIcon.setIconLiteral(FontIcon.java:232)
        ... 44 more
aalmiray commented 7 years ago

Ikonli relies on metadata files located inside META-INF/services in order to identify Ikon resolvers. These files must be merged using an specific strategy. I'm afraid that the fatJar task you've defined does not take into account these files. I'd suggest to use the shadow plugin instead https://plugins.gradle.org/plugin/com.github.johnrengelman.shadow

collinsmith commented 7 years ago

Got it, thanks. I was able to implement the changes and it works great now!

aalmiray commented 7 years ago

It looks like you're building a JavaFX application that can grow in complexity. I'd recommend you to use an application framework; you'll find a good list at https://github.com/mhrimaz/AwesomeJavaFX among other interesting JavaFX related projects.

Of course I'm biased but I'd suggest you to have a look at http://griffon-framework.org/ 😉

MegaOsama commented 4 years ago

Ikonli relies on metadata files located inside META-INF/services in order to identify Ikon resolvers. These files must be merged using an specific strategy. I'm afraid that the fatJar task you've defined does not take into account these files. I'd suggest to use the shadow plugin instead https://plugins.gradle.org/plugin/com.github.johnrengelman.shadow

thanks you tooooo much you helped me to very very very much .. i was spend about five days finding solve for above problem and getResources return null problem .. and now like magic all thing work fine .. good lock for all ;-)