I'm new to JavaFX and TornadoFX but know Kotlin.
I am working on new desktop application and was trying TornadoFX.
I installed TornadoFX plugin in IntelliJ and create a new TornadoFX project (gradle based).
With the template code, when I run the app I get the following error :
Jan 28, 2020 4:06:22 PM tornadofx.DefaultErrorHandler uncaughtException
SEVERE: Uncaught error
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:483)
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:875)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$147(LauncherImpl.java:157)
at com.sun.javafx.application.LauncherImpl$$Lambda$49/458209687.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoSuchMethodError: javafx.stage.Window.getProperties()Ljavafx/collections/ObservableMap;
at tornadofx.FXKt.setAboutToBeShown(FX.kt:663)
at tornadofx.App.start(App.kt:84)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(LauncherImpl.java:821)
at com.sun.javafx.application.LauncherImpl$$Lambda$52/707342127.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(PlatformImpl.java:323)
at com.sun.javafx.application.PlatformImpl$$Lambda$46/1637506559.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.java:292)
at com.sun.javafx.application.PlatformImpl$$Lambda$48/1602612637.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImpl.java:291)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/2117255219.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
MyApp Class:
class MyApp: App(MainView::class, Styles::class)
Styles Class:
class Styles : Stylesheet() {
companion object {
val heading by cssclass()
}
init {
label and heading {
padding = box(10.px)
fontSize = 20.px
fontWeight = FontWeight.BOLD
}
}
}
MainView Class:
class MainView : View("Hello TornadoFX") {
override val root = hbox {
label(title) {
addClass(Styles.heading)
}
}
}
I'm using java 1.8, kotlin 1.3 and tornadofx 1.7.17
I also tried by creating a new "Application" configuration to run the app.
Any help is appreciated.
The gradle configuration produced by the TornadoFX plugin is obsolete and has a number of problems. Not only because of the older versions selected for kotlin and tornadofx, but also the buildscript method has been deprecated for kotlin applications that use gradle. Additionaly, the gradle version is quite old and must be updated to work with newer Java versions.
To get a running build starting with the demo app created by the TornadoFX wizard and Java 8 do the following:
Make sure you have a Java 8 JDK that includes JavaFX. Most open JDKs such as Adopt OpenJDK do not. The oracle JDK 8 should include Java FX. For open JDKs, I suggest Zulu or Liberica (they have a build for raspery pi). When you download, make sure to select the JDK with Java FX included. For Zulu, you have to select "JDK FX", for Liberica you have to select "Full JDK".
Edit gradle/wrapper/gradle-wrapper.properties and change the gradle-4.4-bin.zip in the URL to gradle-6.3-bin.zip Version 6.3 will work with JDK up to version 14.
If on Mac or Linux, you have to convert the gradlew script to use unix line endings. The one produced by the TornadoFX plugin uses windows new lines "\r\n" which the "sh" interpreter can't handle. On linux, you can use dos2unix command or sed if you don't have dos2unix installed:sed -i 's/\x0D$//' gradlew
Edit build.gradle using the code below. This is the simplest config to build and run the demo app
Execute the gradlew script to build and run
Mac/Linux: ./gradlew run
Windows: gradlew.bat run
It's a good idea to update the wrapper
Mac/Linux: ./gradlew wrapper
Windows: gradlew.bat wrapper
JDK 8 build.gradle
plugins {
// Apply the Kotlin JVM plugin to add support for Kotlin.
id 'org.jetbrains.kotlin.jvm' version '1.3.70'
// Apply the application plugin to add support for building a CLI application.
id 'application'
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
repositories {
mavenLocal()
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
// Align versions of all Kotlin components
implementation platform('org.jetbrains.kotlin:kotlin-bom')
// Use the Kotlin JDK 8 standard library.
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
// Use the tornadofx
implementation "no.tornado:tornadofx:1.7.20"
}
mainClassName = "com.example.demo.app.MyApp"
JDK 9+
For JDK 9+, start at step 2 above plus modify the build.gradle to download JavaFX since it was separated from the JDK starting with 9.
Add to the plugins section:
// Apply the javafx plugin
id 'org.openjfx.javafxplugin' version '0.0.8'
And then add a javafx section:
javafx {
version = "13"
modules = [ 'javafx.controls', 'javafx.fxml' ]
}
Finally, change tornadofx version to the 2.0 snapshot
// Use the tornadofx
implementation "no.tornado:tornadofx:2.0.0-SNAPSHOT"
At this point the demo app should run. There are some gotchas with running a JDK 9+ version with TornadoFX but you should be able to find those answers in other questions.
Related
Using the following dependencies (amongst others, the bundle is supposed to be installed to AEM 6.1)
runtime is java8
maven-scr-plugin 1.15.0
org.apache.felix.scr.annotations: 1.9.8
org.apache.felix.scr.ds-annotations: 1.2.8
I get this exception
Caused by: org.apache.felix.scrplugin.SCRDescriptorException: Unable to scan class files: ...
(Class file format probably not supported by ASM ?)
at org.apache.felix.scrplugin.helper.ClassScanner.processClass(ClassScanner.java:219)
at org.apache.felix.scrplugin.helper.ClassScanner.process(ClassScanner.java:161)
at org.apache.felix.scrplugin.helper.ClassScanner.scanSources(ClassScanner.java:146)
at org.apache.felix.scrplugin.SCRDescriptorGenerator.execute(SCRDescriptorGenerator.java:146)
at org.apache.felix.scrplugin.mojo.SCRDescriptorMojo.execute(SCRDescriptorMojo.java:221)
... 22 more
Caused by: java.lang.IllegalArgumentException
at org.objectweb.asm.ClassReader.(Unknown Source)
at org.objectweb.asm.ClassReader.(Unknown Source)
at org.objectweb.asm.ClassReader.(Unknown Source)
at org.apache.felix.scrplugin.helper.ClassScanner.processClass(ClassScanner.java:201)
The class in question does not contain any osgi annotations at all, but is merely imported in some other #Component annotated classes.
Did anyone encounter this and found a solution?
I ran into this issue today. This happens when you are running maven-scr-plugin with scanClasses=true option. Older versions of maven-scr-plugin cannot scan classfile generated by java8. you will have to either switch to a newer version of scr plugin (I upgraded to 1.22) or set you maven-compiler-plugin target config to 1.7
I found out that my Felix SCR Annotation Processor plugin that I installed to my Intellij as a prerequisite to using the aem-ide-tooling-4-intellij from headwirecom is causing the issue. It was working for quite a while until today suddenly giving me an issue in running my unit tests (needless to say, there were no changes made in my java, mvn versions or in my IDE).
This forced me to update my java version, intellij version but didn't fix the issue. But disabled the SCR annotation plugin fixed it.
As you can see, this plugin is really old (2014). I hope they will release a newer version soon.
I'm trying to upgrade my mongodb plugin from 2.0.1 to 3.0.3. However I keep getting the following error:
java.lang.NoClassDefFoundError: com/mongodb/AggregationOptions
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2531)
at java.lang.Class.getDeclaredMethods(Class.java:1855)
at org.codehaus.groovy.reflection.CachedClass$3$1.run(CachedClass.java:84)
at java.security.AccessController.doPrivileged(Native Method)
at org.codehaus.groovy.reflection.CachedClass$3.initValue(CachedClass.java:81)
at org.codehaus.groovy.reflection.CachedClass$3.initValue(CachedClass.java:79)
at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46)
at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33)
at org.codehaus.groovy.reflection.CachedClass.getMethods(CachedClass.java:250)
at groovy.lang.MetaClassImpl.populateMethods(MetaClassImpl.java:343)
at groovy.lang.MetaClassImpl.fillMethodIndex(MetaClassImpl.java:293)
at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:3048)
at groovy.lang.ExpandoMetaClass.initialize(ExpandoMetaClass.java:483)
at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(Cl
...
I've tried changing the version of the plugin to 3.0.2 but the error persists.
UPDATE:
I'm on Grails 2.3.11.
I've tried including the plugin with specifying no dependencies and also copy pasting the dependencies from my past configuration which is:
dependencies {
runtime "org.mongodb:mongo-java-driver:2.11.4"
compile "org.mongodb:mongo-java-driver:2.11.4"
runtime "com.gmongo:gmongo:1.2"
}
and
plugins {
...
compile(':mongodb:2.0.1') {
excludes 'mongo-java-driver', 'gmongo'
}
Update your BuildConfig a bit:
compile ":mongodb:3.0.2"
Don't specify any other mongo related dependencies and don't exclude mongo-java-driver or gmongo. Also, if you are using mongeez plugin then you have to exclude the java driver.
compile (":mongeez:0.2.3") {
excludes("mongo-java-driver")
}
changing dependencies to:
runtime "org.mongodb:mongo-java-driver:2.12.3"
compile "org.mongodb:mongo-java-driver:2.12.3"
works
I am using the newest version (2.8.0) of the Eclipse-Groovy plugin that ships with groovy-all-2.1.5.jar. I added Guice to my Groovy project, and when I go to run them from inside Eclipse I get the following error in the console output:
Caught: java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
at net.me.myapp.utils.restclient.RestClient.<init>(RestClient.groovy:57)
at net.me.myapp.inject.UserServiceClientModule.configure(UserServiceClientModule.groovy:34)
at com.google.inject.AbstractModule.configure(AbstractModule.java:59)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
at com.google.inject.spi.Elements.getElements(Elements.java:101)
at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:133)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:103)
at com.google.inject.Guice.createInjector(Guice.java:95)
at com.google.inject.Guice.createInjector(Guice.java:72)
at com.google.inject.Guice.createInjector(Guice.java:62)
at net.me.myapp.UserServiceClient.<init>(UserServiceClient.groovy:37)
at net.me.myapp.UserServiceClient.main(UserServiceClient.groovy:45)
Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.runtime.typehandling.ShortTypeHandling
... 12 more
According to this answer it's because ShortTypeHandling wasn't added until 2.3.x. So I would now like to attach groovy-all-2.3.3.jar to my Eclipse project's classpath.
The problem is that I don't seem to have edit permissions to change what library the Groovy Libraries library uses under the hood. And when I manually add the 2.3.3 JAR to my build path, I get the following error:
Caught: java.lang.ExceptionInInitializerError
java.lang.ExceptionInInitializerError
Caused by: groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-all is loaded in version 2.1.5 and you are trying to load version 2.3.3
What are my options?
Groovy-eclipse versions have its own compilers and are "locked" to them. You may change the versions to whatever is listed under Window > Preferences > Groovy > Compilers, but, AFAIK, you can't change to an arbitrary version of the compiler by simply changing the groovy-all jar in the guts of the plugin dir.
You can install new compiler versions using the update site or eclipse marketplace
Update: install additional compiler versions through Help > Install new Software, select Groovy update site and expand the Extra Groovy Compilers session:
Note i'm using snapshot update site, because i like to live dangerously.
I just installed Eclipse KEPLER and am trying to bring all my projects back in from github. The projects are all gradle projects so my procedure is pretty much...
Clone the git repo
gradle eclipse
Import Project into Eclipse
Everything seems to be fine, except I can't "Run As, Groovy Script" the scripts within the project. When I try, the console spews...
java.lang.NoClassDefFoundError: org/apache/commons/cli/CommandLineParser
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2521)
at java.lang.Class.getMethod0(Class.java:2764)
at java.lang.Class.getMethod(Class.java:1653)
at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:99)
at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:130)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.cli.CommandLineParser
at org.codehaus.groovy.tools.RootLoader.findClass(RootLoader.java:156)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:128)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 6 more
. Interestingly enough, I can "Run As, Java Application" without issue. Its definitely a Groovy project as it has the G in the project icon. What does the stacktrace mean and how do I overcome it?
The repository that is causing my issue is at https://github.com/robertkuhar/StackOverflow
My gradle is 1.11 on groovy 1.8.6 in eclipse kepler with the Groovy-Eclipse plug-in Version: 2.8.0.xx-20130703-1600-e43-RELEASE
Looks like when creating the "Groovy Script" run configuration, the main class is set to org.codehaus.groovy.tools.GroovyStarter instead of the script you are intending to run. Replacing it with the Groovy class/script you would like to run sorts the issue.
Update
After some digging the way to solve the issue is:
Remove the Groovy dependency from the Gradle build.
Configure the project classpath and nature, as suggested in this answer
build.gradle
eclipse {
project {
natures.add 'org.eclipse.jdt.groovy.core.groovyNature'
}
classpath {
file {
withXml {
Node node = it.asNode()
node.appendNode('classpathentry',[exported:"true",kind:"con",path:"GROOVY_SUPPORT"])
node.appendNode('classpathentry',[exported:"true",kind:"con",path:"GROOVY_DSL_SUPPORT"])
}
}
}
}
sorry for my english! I install plagin in eclipse, but wen i run my little project i have this problem. Why its not work?
error(10): internal error: Can't get property indirectDelegates using
method get/isIndirectDelegates from org.antlr.tool.Grammar instance :
java.lang.NullPointerException
java.util.Objects.requireNonNull(Unknown Source)
java.util.ArrayList.removeAll(Unknown Source)
org.antlr.tool.CompositeGrammar.getIndirectDelegates(CompositeGrammar.java:222)
org.antlr.tool.Grammar.getIndirectDelegates(Grammar.java:2620)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.antlr.stringtemplate.language.ASTExpr.invokeMethod(ASTExpr.java:564)
org.antlr.stringtemplate.language.ASTExpr.rawGetObjectProperty(ASTExpr.java:515)
org.antlr.stringtemplate.language.ASTExpr.getObjectProperty(ASTExpr.java:417)
org.antlr.stringtemplate.language.ActionEvaluator.attribute(ActionEvaluator.java:351)
org.antlr.stringtemplate.language.ActionEvaluator.expr(ActionEvaluator.java:136)
org.antlr.stringtemplate.language.ActionEvaluator.templateApplication(ActionEvaluator.java:216)
org.antlr.stringtemplate.language.ActionEvaluator.expr(ActionEvaluator.java:126)
org.antlr.stringtemplate.language.ActionEvaluator.action(ActionEvaluator.java:84)
org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:149)
org.antlr.stringtemplate.StringTemplate.write(StringTemplate.java:705)
org.antlr.stringtemplate.language.ASTExpr.writeTemplate(ASTExpr.java:750)
org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:680)
org.antlr.stringtemplate.language.ASTExpr.writeAttribute(ASTExpr.java:660)
org.antlr.stringtemplate.language.ActionEvaluator.action(ActionEvaluator.java:86)
org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:149)
org.antlr.stringtemplate.StringTemplate.write(StringTemplate.java:705)
org.antlr.stringtemplate.language.ASTExpr.writeTemplate(ASTExpr.java:750)
org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:680)
org.antlr.stringtemplate.language.ASTExpr.writeAttribute(ASTExpr.java:660)
org.antlr.stringtemplate.language.ActionEvaluator.action(ActionEvaluator.java:86)
org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:149)
org.antlr.stringtemplate.StringTemplate.write(StringTemplate.java:705)
org.antlr.stringtemplate.language.ASTExpr.writeTemplate(ASTExpr.java:750)
org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:680)
org.antlr.stringtemplate.language.ASTExpr.writeAttribute(ASTExpr.java:660)
org.antlr.stringtemplate.language.ActionEvaluator.action(ActionEvaluator.java:86)
org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:149)
org.antlr.stringtemplate.StringTemplate.write(StringTemplate.java:705)
org.antlr.codegen.CodeGenerator.write(CodeGenerator.java:1281)
org.antlr.codegen.Target.genRecognizerFile(Target.java:94)
org.antlr.codegen.CodeGenerator.genRecognizer(CodeGenerator.java:466)
org.antlr.Tool.generateRecognizer(Tool.java:641)
org.antlr.Tool.process(Tool.java:454)
ANTLR 3 produces this message when used with Java 8. However, it doesn't seem to affect the actual output. Until the fix is released in a new version of ANTLR 3, you can either ignore the message, or use Java 7.
Related issue:
#151: NPE in CompositeGrammer.getIndirectDelegates in Java 8
I got a similar error running ANTLR 3.1.1 with Java 1.8. In my Ant Build file, I changed the attribute of the "java" task to "failonerror="false". I still got the error message, but my build stopped failing and produced the output that I wanted.
For java 8 and antlr 3, change the jar to "antlr-3.5.2-complete.jar" and the error will go away.
update the ANTLR plugin to version 2.1.2
Go to project properties-> ANTLR -> Building
Uncheck "Enable project specific settings"
Click "Configure Workspace Settings" -> ANTLR -> Builder -> Building
Remove the installed 3.5.2 package
Add installed packages and point it to the folder of "antlr-3.5.2-complete.jar"
Save and come back to enable project specific settings.
In the General-> ANTLR Runtime, select 3.5.2