Simsilica / SimArboreal-Editor

Editor using the SimArboreal library to generate exportable tree models.
http://simsilica.github.io/SimArboreal-Editor/
10 stars 6 forks source link

Crash immediately after launch: 'error running groovy compiled script' #7

Closed simon-brooke closed 7 months ago

simon-brooke commented 7 months ago

As discussed in [this thread]() on jMonkeyEngine Hub today.

Stacktrace as follows:

JAVA_HOME="/home/simon/bin/jmonkeyplatform/jdk"
cd /home/simon/workspace/SimArboreal-Editor; /home/simon/.gradle/wrapper/dists/gradle-8.3-rc-1-bin/3lbs5z64xhcdp1uarsx2vp16o/gradle-8.3-rc-1/bin/gradle --configure-on-demand -x check run
Configuration on demand is an incubating feature.

> Task :compileJava
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/simon/workspace/SimArboreal-Editor/src/main/java/com/simsilica/arboreal/FileActionsState.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

> Task :processResources
> Task :classes

> Task :run
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Apr 20, 2024 9:03:17 PM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.3.0-stable
 * Branch: HEAD
 * Git Hash: 391e0dc
 * Build Date: 2020-03-30
Apr 20, 2024 9:03:17 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: LWJGL 2.9.3 context running on thread jME3 Main
 * Graphics Adapter: null
 * Driver Version: null
 * Scaling Factor: 1
Apr 20, 2024 9:03:17 PM com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
INFO: OpenGL Renderer Information
 * Vendor: Intel
 * Renderer: Mesa Intel(R) HD Graphics 5500 (BDW GT2)
 * OpenGL Version: 4.6 (Compatibility Profile) Mesa 22.3.6
 * GLSL Version: 4.60
 * Profile: Compatibility
Apr 20, 2024 9:03:18 PM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.ogre.MeshLoader
Apr 20, 2024 9:03:18 PM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.ogre.SkeletonLoader
Apr 20, 2024 9:03:18 PM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.ogre.MaterialLoader
Apr 20, 2024 9:03:18 PM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.ogre.SceneLoader
Apr 20, 2024 9:03:18 PM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.blender.BlenderModelLoader
Apr 20, 2024 9:03:18 PM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.fbx.FbxLoader
Apr 20, 2024 9:03:18 PM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.gltf.GltfLoader
Apr 20, 2024 9:03:18 PM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.gltf.BinLoader
Apr 20, 2024 9:03:18 PM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.gltf.GlbLoader
Apr 20, 2024 9:03:18 PM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.audio.plugins.OGGLoader
Apr 20, 2024 9:03:18 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio Renderer Information
 * Device: OpenAL Soft
 * Vendor: OpenAL Community
 * Renderer: OpenAL Soft
 * Version: 1.1 ALSOFT 1.15.1
 * Supported channels: 64
 * ALC extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFT_loopback
 * AL extensions: AL_EXT_ALAW AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_LOKI_quadriphonic AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data AL_SOFTX_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points AL_SOFT_source_latency
Apr 20, 2024 9:03:18 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
WARNING: Pausing audio device not supported.
Apr 20, 2024 9:03:18 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio effect extension version: 1.0
Apr 20, 2024 9:03:18 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio max auxiliary sends: 4
Apr 20, 2024 9:03:19 PM com.jme3.app.LegacyApplication handleError
SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.RuntimeException: Error running:org.codehaus.groovy.jsr223.GroovyCompiledScript@3b1101e4 from:resource:/com/simsilica/lemur/style/StyleApi.groovy
    at com.simsilica.lemur.style.StyleLoader.initializeApi(StyleLoader.java:134)
    at com.simsilica.lemur.style.StyleLoader.loadStyle(StyleLoader.java:170)
    at com.simsilica.lemur.style.StyleLoader.loadStyle(StyleLoader.java:162)
    at com.simsilica.lemur.style.BaseStyles.loadStyleResources(BaseStyles.java:78)
    at com.simsilica.lemur.style.BaseStyles.loadGlassStyle(BaseStyles.java:62)
    at com.simsilica.arboreal.TreeEditor.simpleInitApp(TreeEditor.java:149)
    at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:239)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:211)
    at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: javax.script.ScriptException: java.lang.reflect.InaccessibleObjectException: Unable to make private java.lang.Class(java.lang.ClassLoader,java.lang.Class) accessible: module java.base does not "opens java.lang" to unnamed module @6f29c911
    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:355)
    at org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(GroovyCompiledScript.java:72)
    at java.scripting/javax.script.CompiledScript.eval(CompiledScript.java:93)
    at com.simsilica.lemur.style.StyleLoader.initializeApi(StyleLoader.java:132)
    ... 9 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make private java.lang.Class(java.lang.ClassLoader,java.lang.Class) accessible: module java.base does not "opens java.lang" to unnamed module @6f29c911
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
    at java.base/java.lang.reflect.Constructor.checkCanSetAccessible(Constructor.java:188)
    at java.base/java.lang.reflect.Constructor.setAccessible(Constructor.java:181)
    at org.codehaus.groovy.reflection.CachedConstructor$1.run(CachedConstructor.java:44)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
    at org.codehaus.groovy.reflection.CachedConstructor.<init>(CachedConstructor.java:42)
    at org.codehaus.groovy.reflection.CachedClass$2.initValue(CachedClass.java:79)
    at org.codehaus.groovy.reflection.CachedClass$2.initValue(CachedClass.java:69)
    at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:49)
    at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:36)
    at org.codehaus.groovy.reflection.CachedClass.getConstructors(CachedClass.java:268)
    at groovy.lang.MetaClassImpl.<init>(MetaClassImpl.java:218)
    at groovy.lang.MetaClassImpl.<init>(MetaClassImpl.java:228)
    at groovy.lang.MetaClassRegistry$MetaClassCreationHandle.createNormalMetaClass(MetaClassRegistry.java:171)
    at groovy.lang.MetaClassRegistry$MetaClassCreationHandle.createWithCustomLookup(MetaClassRegistry.java:161)
    at groovy.lang.MetaClassRegistry$MetaClassCreationHandle.create(MetaClassRegistry.java:144)
    at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:253)
    at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:285)
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:257)
    at groovy.lang.MetaClassImpl.pickStaticMethod(MetaClassImpl.java:1514)
    at groovy.lang.MetaClassImpl.retrieveStaticMethod(MetaClassImpl.java:1404)
    at groovy.lang.MetaClassImpl.createStaticSite(MetaClassImpl.java:3383)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallStaticSite(CallSiteArray.java:77)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallSite(CallSiteArray.java:162)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
    at Script1.run(Script1.groovy:44)
    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:352)
    ... 12 more

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

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

For more on this, please refer to https://docs.gradle.org/8.3-rc-1/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD SUCCESSFUL in 21s
3 actionable tasks: 3 executed

I hope you can make some sense of this!

simon-brooke commented 7 months ago

Note that this is a launch after selecting 'run' from the context menu in the projects tab of jMonkeyPlaform 3.6.1-stable. I am trying to build an uberjar for SimArboreal-Editor, but so far have not succeeded.

pspeed42 commented 7 months ago

I'm not sure why you want to make an "uber jar". It's an ancient and frowned-upon practice these days.

As to the other, the error is because of this: "Unable to make private java.lang.Class(java.lang.ClassLoader,java.lang.Class) accessible: module java.base does not "opens java.lang" to unnamed module @6f29c911" ...you have to pass the right command line argument for newer Java to support reflection. Reflection is going to be required for a lot of things in Lemur, JME, etc. that SimArboreal relies on.

I don't have the command line argument handy but will post back later if you haven't found it yet.

Edit: note also that an uber-jar (that includes all dependencies) will fail in this case because it will have trouble combining the lemur (UI) jars together.

pspeed42 commented 7 months ago

To run things that use reflection, I pass the --add-opens argument like in this application config from Mythruna's build.gradle file:

application {
    applicationDefaultJvmArgs = [ "-ea", "-Xmx3g", "-Xms512m", "-XX:MaxDirectMemorySize=3g", "--add-opens", "java.base/java.io=ALL-UNNAMED" ]
}
simon-brooke commented 7 months ago

Re: uberjars, if a SimArboreal-Editor uberjar had been built back in 2016 and published somewhere, folk could just download it and run it and evaluate it without having to recompile anything, and you would get

  1. More active users; and
  2. Fewer bug reports

Both of which are good things. If you package an application with all its dependencies, then you have a fair guarantee that it will continue to just work.

However, if I remove the single line BaseStyles.loadGlassStyle();, thus:

diff --git a/src/main/java/com/simsilica/arboreal/TreeEditor.java b/src/main/java/com/simsilica/arboreal/TreeEditor.java
index 89be342..0696143 100644
--- a/src/main/java/com/simsilica/arboreal/TreeEditor.java
+++ b/src/main/java/com/simsilica/arboreal/TreeEditor.java
@@ -146,7 +146,7 @@ public class TreeEditor extends SimpleApplication {
         rootNode.attachChild(geom);
         */ 

-        BaseStyles.loadGlassStyle();
+//        BaseStyles.loadGlassStyle();

         TreeOptionsState treeOptions = stateManager.getState(TreeOptionsState.class);                
         treeOptions.addOptionToggle("Grass", stateManager.getState(GroundState.class), "setShowGrass");      

I get a successful launch of a window showing a leafless tree, a male character model, a female character model, and what appears to be an editing UI on the left hand side: Screenshot from 2024-04-22 10-01-42

This has at present the standard SimpleApplication mouse and keyboard behaviour, so I haven't yet worked out whether I can interact with the UI, but it should be enough to get me started.

pspeed42 commented 7 months ago

re:"Re: uberjars, if a SimArboreal-Editor uberjar had been built back in 2016 and published somewhere, folk could just download it and run it and evaluate it without having to recompile anything, and you would get

More active users; and
Fewer bug reports

" But uber-jars like that have numerous problems because any files that are the same name will fail, meta-inf gets weird, etc... it's ancient maven technology from 20 years ago because maven couldn't figure out how to build an application jar. It also has a problem with command line arguments and stuff. Giant single jars were never a good idea and maven developers should be ashamed of themselves. :)

As to your points, a gradle generated application zip would solve the same problems... and I thought I already published one. Apparently, I only have the older netbeans generated .exe versions: https://github.com/Simsilica/SimArboreal-Editor/tree/master/release

pspeed42 commented 7 months ago

re: "However, if I remove the single line BaseStyles.loadGlassStyle();, thus:"

Yes, because you've disable all Lemur styling support. It would be better to fix your reflection permission problems with the command line argument.

You should only have to edit build.gradle: https://github.com/Simsilica/SimArboreal-Editor/blob/master/build.gradle#L10 ...to look like the line I pasted above. If I get time later then maybe I will try it but we're in a weird place because I'm stuck (for the moment) on gradle 7.

pspeed42 commented 7 months ago

Also, my recollection is that space bar toggles between flight mode and edit mode... but I thought it started in edit mode.