Comments (19)
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
from ikonli.
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.
from ikonli.
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
from ikonli.
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.
from ikonli.
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!
from ikonli.
I solved this by putting the icon pack dependency first in the pom.xml
file.
from ikonli.
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"
from ikonli.
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?
from ikonli.
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.
from ikonli.
ping 😼
from ikonli.
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
from ikonli.
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>
from ikonli.
I will, thanks!
from ikonli.
The last stacktrace points to a CNFE as the cause. Are you using JDK9 or greater?
from ikonli.
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)
from ikonli.
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
from ikonli.
@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.
from ikonli.
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`
from ikonli.
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. 😊
from ikonli.
Related Issues (20)
- NullPointerException using modular approach HOT 3
- Tooltips on FontIcon not working properly for some icon sets
- Style: The icons in JavaFx when use ":selected" is not working? HOT 3
- Not gotting my Custom icon in my button HOT 5
- Hover Icon HOT 1
- ikonli-bom lists ikonli-browser as dependency
- FontAwesome - plans? HOT 3
- Font.loadFont() two or more times with the same font family fails on iOS
- Specifying icon size in "em" is not working HOT 3
- Some CoreUI cheat sheet samples are off HOT 1
- Unable resolve org.kordamp.ikonli:ikonli-materialdesign2-pack icons via FXML's "iconLiteral" attribute. HOT 2
- Cannot resolve 'mdi-clock' HOT 1
- Issue with third-party library using Ikonly: Exception in thread "JavaFX Application Thread" java.lang.UnsupportedOperationException: Cannot resolve 'mdi-close' HOT 3
- Resizing ikons dynamically HOT 1
- Browser icon displaying problem
- JFXCentral Badge HOT 2
- Cannot bind size then set font HOT 1
- Font Awesome 6
- Draw FontIcon (Ikonli) directly on "javafx.scene.Canvas"
- Support material design icons from pictogrammers.com HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ikonli.