Identifying missing imports in Groovy jar - java

I am trying to create a jar file for a Groovy program I have written (BINSIC - an interpreter cum DSL that runs BASIC code: https://github.com/mcmenaminadrian/BINSIC).
I have a fundamental problem in that the code runs fine (if very slowly) on the development machine but fails on deployment (see below) - even on a box where I have installed a full Groovy installation. It looks like I'm failing to import something into the jar which is then called, though I don't know why that would fail when I have a full Groovy install. I have had the same problem with several different versions of Java (also using sdkman) activated.
What do I have to do to get the code to work on deployment? Does anyone know?
Setting groovy 3.0.2 as default.
lorraine#Kobani:~/Downloads$ java -jar binsic.jar test.bas
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61)
Caused by: java.lang.NoClassDefFoundError: Unable to load class org.apache.groovy.jaxb.extensions.JaxbExtensions due to missing dependency javax/xml/bind/JAXBContext
at org.codehaus.groovy.vmplugin.v8.Java8.configureClassNode(Java8.java:458)
at org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:274)
at org.codehaus.groovy.ast.ClassNode.getMethods(ClassNode.java:396)
at org.codehaus.groovy.transform.stc.AbstractExtensionMethodCache.scan(AbstractExtensionMethodCache.java:116)
at org.codehaus.groovy.transform.stc.AbstractExtensionMethodCache.getMethods(AbstractExtensionMethodCache.java:97)
at org.codehaus.groovy.transform.stc.AbstractExtensionMethodCache.getMethodsFromClassLoader(AbstractExtensionMethodCache.java:73)
at org.codehaus.groovy.runtime.memoize.StampedCommonCache.compute(StampedCommonCache.java:163)
at org.codehaus.groovy.runtime.memoize.StampedCommonCache.getAndPut(StampedCommonCache.java:154)
at org.codehaus.groovy.runtime.memoize.StampedCommonCache.getAndPut(StampedCommonCache.java:115)
at org.codehaus.groovy.transform.stc.AbstractExtensionMethodCache.get(AbstractExtensionMethodCache.java:51)
at org.codehaus.groovy.macro.transform.MacroCallTransformingVisitor.findMacroMethods(MacroCallTransformingVisitor.java:119)
at org.codehaus.groovy.macro.transform.MacroCallTransformingVisitor.visitMethodCallExpression(MacroCallTransformingVisitor.java:90)
at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:76)
at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:117)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:200)
at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40)
at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:86)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:164)
at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)
at org.codehaus.groovy.ast.MethodCallTransformation.visit(MethodCallTransformation.java:42)
at org.codehaus.groovy.transform.ASTTransformationVisitor.lambda$addPhaseOperationsForGlobalTransforms$4(ASTTransformationVisitor.java:336)
at org.codehaus.groovy.control.CompilationUnit$ISourceUnitOperation.doPhaseOperation(CompilationUnit.java:880)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:650)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:627)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:389)
at groovy.lang.GroovyClassLoader.lambda$parseClass$3(GroovyClassLoader.java:332)
at org.codehaus.groovy.runtime.memoize.StampedCommonCache.compute(StampedCommonCache.java:163)
at org.codehaus.groovy.runtime.memoize.StampedCommonCache.getAndPut(StampedCommonCache.java:154)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:330)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:530)
at groovy.lang.GroovyShell.parse(GroovyShell.java:542)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:430)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:474)
at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:274)
at binsic.BinsicEngine.process(Binsic.groovy:53)
at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:274)
at binsic.Binsic.run(Binsic.groovy:81)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1262)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1029)
at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:1027)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:1010)
at org.codehaus.groovy.runtime.InvokerHelper.runScript(InvokerHelper.java:442)
at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:274)
at binsic.Binsic.main(Binsic.groovy)
... 5 more

the root error message:
Caused by: java.lang.NoClassDefFoundError:
Unable to load class org.apache.groovy.jaxb.extensions.JaxbExtensions
due to
missing dependency javax/xml/bind/JAXBContext
open site https://search.maven.org/
and search for full class name that s missing with prefix fc:
like this fc:javax.xml.bind.JAXBContext
https://search.maven.org/search?q=fc:javax.xml.bind.JAXBContext

Related

I have been trying to install Jdownloader2 on fedora linux but keep getting NoClassDefFoundError

Running the executable file (.sh) from terminal gives this output
[akash#fedora Downloads]$ ./JDownloader2Setup_unix_nojre.sh
Starting Installer ...
java.lang.NoClassDefFoundError: Could not initialize class java.awt.Toolkit
at java.desktop/java.awt.Color.<clinit>(Color.java:277)
at com.install4j.runtime.installer.frontend.GUIHelper.<clinit>(GUIHelper.java:46)
at com.install4j.runtime.installer.helper.InstallerUtil.reportException(InstallerUtil.java:1327)
at com.install4j.runtime.installer.Installer.main(Installer.java:48)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at com.exe4j.runtime.LauncherEngine.launch(LauncherEngine.java:84)
at com.install4j.runtime.launcher.UnixLauncher.start(UnixLauncher.java:69)
at install4j.Installer378667612.main(Unknown Source)
I don't know if there is any other output I have to send since I am still pretty new to Linux.
If anyone else got same error. Just remove your JRE/JDK and install it again.
Note- It might remove some other apps like libreoffice and stuff, so save files and make backups.

Eclipse error: error has occured see log file

I went to the file and the info below is what it displayed. I was attempting to add web tools for github repo functionality and then it crashed and would love to not uninstall and risk losing my code that I am working on. Is there a way to fix this without causing any harm on the projects in eclipse?
this is the log file:
java.lang.IllegalArgumentException
at org.eclipse.equinox.internal.p2.metadata.VersionParser.parse(VersionParser.java:83)
at org.eclipse.equinox.p2.metadata.Version.create(Version.java:96)
at org.eclipse.equinox.p2.metadata.Version.parseVersion(Version.java:164)
at org.eclipse.equinox.internal.p2.repository.helpers.LocationProperties.create(LocationProperties.java:88)
at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.handleRemoteIndexFile(AbstractRepositoryManager.java:735)
at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.loadIndexFile(AbstractRepositoryManager.java:724)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.eclipse.oomph.util.ReflectUtil.invokeMethod(ReflectUtil.java:119)
at org.eclipse.oomph.p2.internal.core.CachingRepositoryManager.loadIndexFile(CachingRepositoryManager.java:388)
at org.eclipse.oomph.p2.internal.core.CachingRepositoryManager.loadRepository(CachingRepositoryManager.java:187)
at org.eclipse.oomph.p2.internal.core.CachingRepositoryManager$Metadata.loadRepository(CachingRepositoryManager.java:495)
at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.loadRepository(MetadataRepositoryManager.java:110)
at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.loadRepository(MetadataRepositoryManager.java:105)
at org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob.doLoad(LoadMetadataRepositoryJob.java:126)
at org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob.runModal(LoadMetadataRepositoryJob.java:110)
at org.eclipse.equinox.internal.p2.ui.sdk.PreloadingRepositoryHandler$1.runModal(PreloadingRepositoryHandler.java:84)
at org.eclipse.equinox.p2.operations.ProvisioningJob.run(ProvisioningJob.java:188)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

Class not found while generating the GUI sources java.lang.NoClassDefFoundError: com/sun/xml/bind/v2/model/annotation/AnnotationReader [Codenameone]

Im using eclipse 2021-3 ( detailed version below), and after updating my form in GUIBuilder I noticed the initGuiBuilderComponents java method in the form class was empty but the .gui file had the components declared.
The stack trace I got after saving the changes in the GUIBuilder is:
enGuiSrc:
[generateGuiSources] Generating GUI sources
[generateGuiSources] timeStr=1.0.0-1621275794779-1621275373210, lastTime=1.0.0-1621275794779-1621275373210
[generateGuiSources] Summary.java unmodified, skipping
[generateGuiSources] timeStr=1.0.0-1622573752664-1622594808739, lastTime=1.0.0-1622573752664-1622594776479
[generateGuiSources] Processing GUI builder file: /Users/jahrvis/eclipse-workspace-mobile/BabyTracker/src/com/jahrvis/mobile/babytracker/forms/CalendarForm.java
[generateGuiSources] Attempting to generate GUI sources for /Users/jahrvis/eclipse-workspace-mobile/BabyTracker/res/guibuilder/com/jahrvis/mobile/babytracker/forms/CalendarForm.gui with System JAXB
[generateGuiSources] Failed to generate Gui Source with System JAXB. Will attempt using bundled JAXB.
BUILD FAILED
/Users/jahrvis/eclipse-workspace-mobile/BabyTracker/build.xml:49: java.lang.RuntimeException: java.lang.NoClassDefFoundError: com/sun/xml/bind/v2/model/annotation/AnnotationReader
at com.codename1.build.client.GenerateGuiSources.generateGuiSource(GenerateGuiSources.java:294)
at com.codename1.build.client.GenerateGuiSources.generateGuiSource(GenerateGuiSources.java:246)
at com.codename1.build.client.GenerateGuiSources.execute(GenerateGuiSources.java:216)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
at org.apache.tools.ant.Task.perform(Task.java:350)
at org.apache.tools.ant.Target.execute(Target.java:449)
at org.apache.tools.ant.Target.performTasks(Target.java:470)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1401)
at org.apache.tools.ant.Project.executeTarget(Project.java:1374)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.eclipse.ant.internal.core.ant.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:34)
at org.apache.tools.ant.Project.executeTargets(Project.java:1264)
at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:712)
at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:532)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.eclipse.ant.core.AntRunner.run(AntRunner.java:374)
at org.eclipse.ant.core.AntRunner.run(AntRunner.java:476)
at codenameoneplugin.EclipseGUIBuilderConnector$2.run(EclipseGUIBuilderConnector.java:142)
at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.NoClassDefFoundError: com/sun/xml/bind/v2/model/annotation/AnnotationReader
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
at org.apache.tools.ant.AntClassLoader.defineClassFromData(AntClassLoader.java:1153)
at org.apache.tools.ant.AntClassLoader.getClassFromStream(AntClassLoader.java:1321)
at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1373)
at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1338)
at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1093)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3325)
at java.base/java.lang.Class.getMethodsRecursive(Class.java:3466)
at java.base/java.lang.Class.getMethod0(Class.java:3452)
at java.base/java.lang.Class.getMethod(Class.java:2199)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:258)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:250)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:447)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:652)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:599)
at com.codename1.build.client.GenerateGuiSources.generateGuiSource_(GenerateGuiSources.java:301)
at com.codename1.build.client.GenerateGuiSources.access$000(GenerateGuiSources.java:32)
at com.codename1.build.client.GenerateGuiSources$1.run(GenerateGuiSources.java:272)
... 1 more
Caused by: java.lang.ClassNotFoundException: com.sun.xml.bind.v2.model.annotation.AnnotationReader
at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1383)
at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1338)
at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1093)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 22 more
Total time: 0 seconds
Version: 2021-03 (4.19.0)
Build id: 20210312-0638
Any clue if this is a framework issue with the new eclipse?
This is related to the JDK. Originally the code was written for JDK 8 but jaxb was removed later and for JDK 11 we try to dynamically download it which doesn't always work well.
I think the best workaround would be a migration to Maven which should solve the issue.
Alternatively try to make sure you're running with JDK 8 which should workaround this issue.

JavaFX 15 Libraries not working with Java 14 in IntelliJ

I had this working before, and I am 99% positive I have been following the same procedure I have used in the past of adding the lib to the project file structure, adding VM options in the Edit Configurations menu. For some reason I still cannot get JavaFX to work with my setup the way it did in the past. My old projects still run and were written with the same libraries and Java version. I have been banging my head on the wall with this issue all morning, I feel as though the solution may be sitting right in front of me. I have no clue what else to try from here, Reddit has been useless and everything I've searched has been the same.
I have tried running with both, when I took the VM options out the last time I finally got my errors in the editor to go away, but get the errors I had in the original post, this is why I didn't include them in the ZIP but included them in the post.
https://ufile.io/6iknpzqy
I have tried with these VM options and without:
--module-path /home/(myUser)/Downloads/javafx-sdk-15.0.1/lib --add-modules=javafx.controls,javafx.fxml
Exception in Application start method
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Exception in Application start method
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.IllegalAccessError: superclass access check failed: class com.sun.javafx.scene.control.ControlHelper (in unnamed module #0x34ce8af7) cannot access class com.sun.javafx.scene.layout.RegionHelper (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.scene.layout to unnamed module #0x34ce8af7
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:821)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:719)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:642)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:600)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at javafx.scene.control.Control.<clinit>(Control.java:86)
at DoMath.start(DoMath.java:36)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run$$$capture(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
... 1 more
Exception running application DoMath
Disconnected from the target VM, address: '127.0.0.1:51735', transport: 'socket'
Process finished with exit code 1
Your project is using Java 14, even though you initially specified Java 11 in the question.
Per the documentation when using Java 14 the following VM Options are also needed:
--add-exports javafx.graphics/com.sun.javafx.sg.prism=ALL-UNNAMED
in addition to these options:
--module-path /home/(myUser)/Downloads/javafx-sdk-15.0.1/lib --add-modules=javafx.controls,javafx.fxml
Double check all the options are specified in the VM Options field of the Run Configuration, not in the Program Arguments.

getResource() method returns null while loading font file, but why?

So I am trying to use the library called PreferencesFX, which uses FontAwesomeFX which throws the following error.
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
at de.jensd.fx.fontawesomefx.commons/de.jensd.fx.glyphs.GlyphsFactory.loadFont(GlyphsFactory.java:64)
at de.jensd.fx.fontawesomefx.commons/de.jensd.fx.glyphs.GlyphsFactory.<init>(GlyphsFactory.java:38)
at de.jensd.fx.fontawesomefx.fontawesome/de.jensd.fx.glyphs.fontawesome.utils.FontAwesomeIconFactory.<init>(FontAwesomeIconFactory.java:28)
at de.jensd.fx.fontawesomefx.fontawesome/de.jensd.fx.glyphs.fontawesome.utils.FontAwesomeIconFactory.get(FontAwesomeIconFactory.java:33)
at com.dlsc.preferencesfx#11.7.0/com.dlsc.preferencesfx.view.UndoRedoBox.<init>(UndoRedoBox.java:17)
at com.dlsc.preferencesfx#11.7.0/com.dlsc.preferencesfx.PreferencesFx.init(PreferencesFx.java:71)
at com.dlsc.preferencesfx#11.7.0/com.dlsc.preferencesfx.PreferencesFx.<init>(PreferencesFx.java:64)
at com.dlsc.preferencesfx#11.7.0/com.dlsc.preferencesfx.PreferencesFx.<init>(PreferencesFx.java:55)
at com.dlsc.preferencesfx#11.7.0/com.dlsc.preferencesfx.PreferencesFx.of(PreferencesFx.java:102)
at my.package.tryThis(Clusters.java:38)
at my.package.Main.main(Main.java:17)
... 11 more
Caused by: java.lang.NullPointerException
at de.jensd.fx.fontawesomefx.commons/de.jensd.fx.glyphs.GlyphsFactory.loadFont(GlyphsFactory.java:62)
... 21 more
Exception running application my.package.Main
I found the cause of the problem to sit at line 62 of the Glyphs Factory class but I have no idea how to fix it.
The method GlyphsFactory.class.getResource(pathToIconFont) returns null, instead of returning the font file. I can see that the method is loading the font file via path /de/jensd/fx/glyphs/fontawesome/fontawesome-webfont.ttf (which seem to be correct). I can see that the font is loaded from package de.jensd.fx.glyphs.fontawesome to package de.jensd.fx.glyphs but both packages are in different jars.
Any ideas why getResource() returns null? I reported it to the developer but it seems the FontAwesomeFX library is abandoned.
I am running this with newest IntelliJ on a Mac OS X Big Sur.
I was successful in patching the library (after reading this) by changing the following line.
Font.loadFont(GlyphsFactory.class.getResource(pathToIconFont).openStream(), 10.0D);
To this.
Font.loadFont(GlyphsFactory.class.getResourceAsStream(pathToIconFont), 10.0D);

Categories