Electrostat-Lab / jMonkeyBuilder

Alex's Jme3 Scene editor Maintained Version
https://hub.jmonkeyengine.org/t/editor-jmonkeybuilder/35179/1232
Apache License 2.0
6 stars 3 forks source link

java 17 and jfx19 run error #20

Closed icyboxs closed 1 year ago

icyboxs commented 2 years ago
警告: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @6071d81f'
Exception in Application constructor
Exception in thread "JFX-MainApplication" java.lang.RuntimeException: Unable to construct Application instance: class com.ss.editor.JFXApplication
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:891)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:196)
    at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$8(LauncherImpl.java:803)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
    ... 1 more
Caused by: java.lang.ExceptionInInitializerError
    at com.ss.editor.config.EditorConfig.<clinit>(EditorConfig.java:73)
    at com.ss.editor.JFXApplication.<init>(JFXApplication.java:31)
    ... 14 more
Caused by: java.lang.IllegalArgumentException: InputStream cannot be null
    at java.xml/javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:118)
    at com.ss.rlib.data.AbstractStreamDocument.parse(AbstractStreamDocument.java:92)
    at com.ss.editor.config.Config.<clinit>(Config.java:85)
    ... 16 more

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.3.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 2s
3 actionable tasks: 1 executed, 2 up-to-date

build.gradle file

plugins {
    id 'java'
    id 'application'
    id 'org.openjfx.javafxplugin' version '0.0.13'
}

javafx {
    version = "19"
    modules = [ 'javafx.controls', 'javafx.graphics', 'javafx.swing', 'javafx.base']
}
String engineVersion = "3.5.1-stable"
group 'org.scrappers'
version '1.0-RM-VERSION'

mainClassName = 'com.ss.editor.Launcher'
description = 'jMonkeyBuilder'

repositories {
    mavenCentral()
    maven { url 'https://jcenter.bintray.com' } // for SimMath
}

dependencies {
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
    implementation 'org.jetbrains:annotations:16.0.2'
    /* local dependencies */
    implementation fileTree(dir: "libs", include: ["*.jar", "*.so"])
    implementation fileTree(dir: "libs/extensions", include: ["*.jar", "*.so"])
    implementation fileTree(dir: "libs/extensions/simsilica", include: ["*.jar", "*.so"])
    implementation fileTree(dir: "libs/extensions/toneg0d", include: ["*.jar", "*.so"])
    implementation fileTree(dir: "libs/extensions/xbuf", include: ["*.jar", "*.so"])
    implementation fileTree(dir: "libs/http", include: ["*.jar", "*.so"])
    implementation fileTree(dir: "libs/svg", include: ["*.jar", "*.so"])

    /* remote dependencies */
    implementation "org.jmonkeyengine:jme3-core:$engineVersion"
    implementation "org.jmonkeyengine:jme3-desktop:$engineVersion"
    implementation "org.jmonkeyengine:jme3-effects:$engineVersion"
    implementation "org.jmonkeyengine:jme3-terrain:$engineVersion"
    implementation "org.jmonkeyengine:jme3-lwjgl3:$engineVersion"
    implementation "org.jmonkeyengine:jme3-plugins:$engineVersion"
}

test {
    useJUnitPlatform()
}

tasks.withType(JavaExec) { // Java runtime options:
    args = []
    classpath sourceSets.main.runtimeClasspath
    //debug true
    enableAssertions true
    //jvmArgs '-verbose:gc'
    //jvmArgs '-Xbatch'
    //jvmArgs '-Xms256m', '-Xmx256m'
    //jvmArgs '-XX:+PrintCompilation'
    //jvmArgs '-XX:+UseConcMarkSweepGC'
    jvmArgs '-XX:+UseG1GC', '-XX:MaxGCPauseMillis=10'
    /*
     * Opens : allows a module to open one of its packages to a <target-module>, regardless of the module declaration.
     * Exports : exports other jfx module to the UN-NAMED modules
     * For more : https://docs.oracle.com/javase/9/migrate/toc.htm#JSMIG-GUID-7744EF96-5899-4FB2-B34E-86D49B2E89B6
     */
    jvmArgs = ['--add-opens=javafx.media/javafx.scene.media=ALL-UNNAMED',
               '--add-exports=javafx.graphics/com.sun.javafx.application=ALL-UNNAMED',
               '--add-exports=javafx.media/com.sun.media.jfxmedia=ALL-UNNAMED',
               '--add-exports=javafx.media/com.sun.media.jfxmedia.events=ALL-UNNAMED',
               '--add-exports=javafx.media/com.sun.media.jfxmedia.control=ALL-UNNAMED',
               '--add-opens=javafx.graphics/com.sun.javafx.application=ALL-UNNAMED']
}

Let me know if you need more information

pavly-gerges commented 2 years ago

@icyboxs Thanks for testing jmb, i will add this to my schedule to work on it by the next month hopefully.

8Keep commented 1 year ago

Any update? I'm on java 19, I updated the gradle wrapper to use 7.6 and when building it isn't finding the javafx lib. I'm pretty sure you have to declare this in the gradle build since jfx isn't included with the jdk anymore, but it's not there.

pavly-gerges commented 1 year ago

Any update? I'm on java 19, I updated the gradle wrapper to use 7.6 and when building it isn't finding the javafx lib. I'm pretty sure you have to declare this in the gradle build since jfx isn't included with the jdk anymore, but it's not there.

Hello @8Keep thanks for testing, yeah, i am going to setup jfx17 with openjdk soon, stay tuned !

8Keep commented 1 year ago

I made some local changes, maybe you can build on them:

https://github.com/8Keep/jMonkeyBuilder/commit/0b88731af718588f6bd5d5d7f049acbbaa099866

1) deleted the build dir since it's already in gitignore and don't want old compiled files in the repo 2) Fixed some localization things (unfinished because I didn't feel like typing out all the english words, but the app didn't run with an equivalent en_us properties file 3) Use newest gradle version 4) Use javafx as it's supposed to be in gradle 5) Some fixes to random stuff in the editor, some crappy things that were there and blocked using a newer jfx version

The app now builds with java 19/ jfx 19. It doesn't run however. The problem is that the multithreading in the program is messed up and tries to initialize the jfx thread multiple times. I was trying to fix it but didn't get there.

pavly-gerges commented 1 year ago

Fantastic, yeah i agree the multithreading is a little outdated and creepy, but its worth trying though, that saying I may introduce a github discussion here on this repo to fix this issue completely, resolve those runtime errors and update the editor to jfx19/jdk-19, so stay tuned.

If we managed to draw a UML diagram and understand the delegation pattern of the editor, we may fix this error...

icyboxs commented 1 year ago

Caused by: java.lang.IllegalArgumentException: InputStream cannot be null at java.xml/javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:118) at com.ss.rlib.data.AbstractStreamDocument.parse(AbstractStreamDocument.java:92) at com.ss.editor.config.Config.<clinit>(Config.java:84) ... 16 more

The error points to config.java

@NotNull private static final String CONFIG_RESOURCE_PATH = "/config.xml";

final VarTable vars = new DocumentConfig(EditorUtil.getInputStream(CONFIG_RESOURCE_PATH)).parse(); This value is indeed null.

XNZHK30M694F O~MUGK5VAK

But you can also see from the diagram that the config.xml file does exist and I don't know why I can't get this file

pavly-gerges commented 1 year ago

@icyboxs If you have problem loading this file, then just replace this: https://github.com/jMonkeyBuilder/jMonkeyBuilder/blob/79e09786ad2eb17ef6f462c91e88134bd669cb5a/src/main/java/com/ss/editor/config/Config.java#LL85C1-L89C66

With:

DEV_DEBUG = false;
DEV_DEBUG_JFX = false;
ENABLE_PBR = true;

Until, I investigate into this to see, I think this file is a trash.

pavly-gerges commented 1 year ago

@8Keep @icyboxs I have tried jfx-19 with openjdk-17 and with a lot of changes (because the editor uses very old jfx libraries that are not built for new jfx, so very old com.sun packages are used), so there are a lot of errors, I am giving up on this issue, until I find time to maintain the other old libraries, instead, I will create a building manual using java 8.