JPro-one / JPro-Tickets

The right place to report about bugs or suggest improvements for JPro.
https://www.jpro.one
9 stars 4 forks source link

NullPointerException from System.getProperty #102

Open BlueGoliath opened 3 years ago

BlueGoliath commented 3 years ago

Attempting to use the mouse in a web browser does not work(but does when visible=true via the app window). This error message is spammed in the output:

c.j.m.t.SceneInputListener - Error while processing the input: MouseEventToken(MouseEntered,265.0,639.0,MouseButtonToken(2),false,false,false,false,false,false,false,false) app: stage title: Goliath Envious FX V2 java.lang.NullPointerException: Cannot invoke "String.toLowerCase()" because the return value of "java.lang.System.getProperty(String)" is null at com.jpro.meta.tk.UtilSceneTKListener$.isMonocle$lzycompute(UtilSceneTKListener.scala:20) at com.jpro.meta.tk.UtilSceneTKListener$.isMonocle(UtilSceneTKListener.scala:20) at com.jpro.meta.tk.SceneInputListener.processInputInScene(SceneInputListener.scala:158) at com.jpro.meta.tk.SceneInputListener.processInput(SceneInputListener.scala:145) at com.jpro.meta.tk.SceneInputListener.processInputs(SceneInputListener.scala:108) at com.jpro.meta.tk.SceneInputListener.$anonfun$new$4(SceneInputListener.scala:42) at simplefx.cores.standard.parts.CoreTimeEvent.$anonfun$runAsAnimation$1(CoreTimeEvent.scala:64) at simplefx.cores.standard.parts.CoreTimeEvent$$anon$2.handle(CoreTimeEvent.scala:46) at javafx.animation.AnimationTimer$AnimationTimerReceiver.lambda$handle$0(AnimationTimer.java:57) at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)

FlorianKirmaier commented 3 years ago

Thank you for the bug report!

Can you share more details? Which java version are you using? Does your project set the property "glass.platform"?

Can you reproduce this issue with one of the HelloWorld projects? Gradle: https://github.com/JPro-one/HelloJPro Maven: https://github.com/JPro-one/HelloJPro-Maven

BlueGoliath commented 3 years ago

Correction: this only happens when visible=true, sorry. When set to false, I can interact with the JavaFX application in the browser but when visible=true I cannot and get the above error. Yes, I can reproduce with the Maven example.

Again, sorry for the confusion.

OS is Arch Linux. I'm using Java 17(built from source) and JavaFX 16. I don't set glass.platform.

FlorianKirmaier commented 3 years ago

I understand why it only happens, when visible is false. Because otherwise this code-path isn't taken. The question is, why is glass.platform not set.

Do you do something, which can confuse these variables?

Can you test it with Java16? A Java17 nightly build obviously isn't supported, even though it should work in theory. It is directly build from this repository https://github.com/openjdk/jdk ? I guess it's at least uncommon to build the jdk yourself. Maybe you can try out a common JDK vendors, like AdoptOpenJDK.

BlueGoliath commented 3 years ago

I use source builds for Panama and cannot downgrade, sorry. The only JVM/App arguements are:

--add-opens=java.base/java.lang=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.file=ALL-UNNAMED --add-modules=jdk.incubator.foreign --enable-native-access=org.goliath.crosspoint,org.goliath.bindings.nvml,ALL-UNNAMED

I'm also using Gnome 40. Not sure if that matters or not.

FlorianKirmaier commented 3 years ago

With which command do you start the server? mvn jpro:run ? How are these JVM arguments set? JPro normally sets various JVM Arguments, which I can't see in your list.

BlueGoliath commented 3 years ago

Yes, via Netbeans. All arguments are set via the flag.

FlorianKirmaier commented 3 years ago

You will have to use either the Maven or Gradle project, otherwise, it won't work. You can also set your JVMArgs with Maven and Gradle.

If Netbeans doesn't support starting the Maven/Gradle tasks, then you will have to start it from the terminal. From Intellij, you can directly start from the Maven/Gradle tasks, but I don't know whether that works for Netbeans.

Java17 ea builds will probably work, but I cannot guarantee.

FlorianKirmaier commented 3 years ago

probably the following JVM args are missing in your Setup: -Dglass.platform=Monocle -Dmonocle.platform=Headless -Dquantum.renderonlysnapshots=true How did you start JPro without these being set? Did you try to mirror the plugins? Or is your JVM for some reason ignoring the arguments we set?

BlueGoliath commented 3 years ago

I meant I run the jpro:run goal from the IDE via right clicking the project, hovering over "Run Maven" and then selecting the custom "jpro:run" goal. The POM section looks like:

`

com.sandec.jpro
            <artifactId>jpro-maven-plugin</artifactId>
            <version>2021.1.1</version>
            <configuration>
                <visible>true</visible>
                <openURLOnStartup>true</openURLOnStartup>
                <JVMArgs>
                    <JVMArg>--add-opens=java.base/java.lang=ALL-UNNAMED</JVMArg>
                    <JVMArg>--add-exports=java.base/sun.net.www.protocol.file=ALL-UNNAMED</JVMArg>
                    <JVMArg>--add-modules=jdk.incubator.foreign</JVMArg> 
                    <JVMArg> --enable-native-access=org.goliath.crosspoint,org.goliath.bindings.nvml,ALL-UNNAMED</JVMArg>
                    <!-- <JVMArg>your-args</JVMArg> -->
                </JVMArgs>
                <mainClassName>org.goliath.envious.fx.app.GoliathEnviousFX</mainClassName>
                <openingPath>/</openingPath>
            </configuration>
        </plugin>`

If I add all 3 of those JVM arguments then visible=true no longer shows the application. I'm guessing that's because of -Dmonocle.platform=Headless but when I remove that, I get:

java.lang.RuntimeException: java.lang.UnsatisfiedLinkError: no glass_monocle in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:296) at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:288) at javafx.application.Platform.startup(Platform.java:111) at simplefx.cores.interfaces.parts.testing.ApplicationStarter$.initialize(ApplicationStarter.scala:10) at simplefx.cores.interfaces.parts.testing.CoreTesting$testing$.(CoreTesting.scala:57) at simplefx.cores.standard.Core.testing$lzycompute$1(Core.scala:9) at simplefx.cores.standard.Core.testing(Core.scala:9) at simplefx.cores.interfaces.parts.testing.CoreTesting.initializeJavaFX(CoreTesting.scala:54) at simplefx.cores.interfaces.parts.testing.CoreTesting.initializeJavaFX$(CoreTesting.scala:54) at simplefx.cores.standard.Core.initializeJavaFX(Core.scala:9) at simplefx.cores.interfaces.parts.testing.CoreTesting.inFX(CoreTesting.scala:19) at simplefx.cores.interfaces.parts.testing.CoreTesting.inFX$(CoreTesting.scala:18) at simplefx.cores.standard.Core.inFX(Core.scala:9) at simplefx.cores.interfaces.parts.CoreTimeEvent.$init$(CoreTimeEvent.scala:23) at simplefx.cores.standard.Core.(Core.scala:9) at simplefx.cores.standard.Core$.createNewCore(Core.scala:6) at simplefx.package$.(packageSimplefx.scala:5) at simplefx.package$.(packageSimplefx.scala) at com.jpro.internal.server.Initializer$.$anonfun$new$9(Initializer.scala:164) at com.jpro.internal.server.Initializer$.execute(Initializer.scala:51) at com.jpro.internal.server.Initializer$.(Initializer.scala:163) at com.jpro.internal.server.Initializer$.(Initializer.scala) at controllers.jpro.(jpro.scala:53) at controllers.jpro$$FastClassByGuice$$3baba93a.newInstance() at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:89) at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:114) at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91) at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:306) at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:42) at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:65) at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:113) at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91) at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:306) at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:42) at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:65) at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:113) at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91) at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:306) at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1094) at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1131) at play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:436) at play.api.inject.ContextClassLoaderInjector.$anonfun$instanceOf$3(Injector.scala:120) at play.api.inject.ContextClassLoaderInjector.withContext(Injector.scala:128) at play.api.inject.ContextClassLoaderInjector.instanceOf(Injector.scala:120) at play.api.inject.RoutesProvider.$anonfun$get$2(BuiltinModule.scala:121) at scala.Option.fold(Option.scala:251) at play.api.inject.RoutesProvider.get$lzycompute(BuiltinModule.scala:121) at play.api.inject.RoutesProvider.get(BuiltinModule.scala:116) at play.api.inject.RoutesProvider.get(BuiltinModule.scala:110) at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:85) at com.google.inject.internal.BoundProviderFactory.provision(BoundProviderFactory.java:77) at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:59) at com.google.inject.internal.BoundProviderFactory.get(BoundProviderFactory.java:61) at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1094) at play.api.http.DefaultHttpRequestHandler.routeRequest(HttpRequestHandler.scala:289) at play.api.http.JavaCompatibleHttpRequestHandler.routeRequest(HttpRequestHandler.scala:396) at play.api.http.DefaultHttpRequestHandler.routeWithFallback$1(HttpRequestHandler.scala:187) at play.api.http.DefaultHttpRequestHandler.handlerForRequest(HttpRequestHandler.scala:237) at play.core.server.Server$.getHandlerFor(Server.scala:126) at play.core.server.AkkaHttpServer.handleRequest(AkkaHttpServer.scala:317) at play.core.server.AkkaHttpServer.$anonfun$createServerBinding$1(AkkaHttpServer.scala:224) at akka.stream.impl.fusing.MapAsync$$anon$30.onPush(Ops.scala:1297) at akka.stream.impl.fusing.GraphInterpreter.processPush(GraphInterpreter.scala:541) at akka.stream.impl.fusing.GraphInterpreter.processEvent(GraphInterpreter.scala:495) at akka.stream.impl.fusing.GraphInterpreter.execute(GraphInterpreter.scala:390) at akka.stream.impl.fusing.GraphInterpreterShell.runBatch(ActorGraphInterpreter.scala:625) at akka.stream.impl.fusing.GraphInterpreterShell$AsyncInput.execute(ActorGraphInterpreter.scala:502) at akka.stream.impl.fusing.GraphInterpreterShell.processEvent(ActorGraphInterpreter.scala:600) at akka.stream.impl.fusing.ActorGraphInterpreter.akka$stream$impl$fusing$ActorGraphInterpreter$$processEvent(ActorGraphInterpreter.scala:775) at akka.stream.impl.fusing.ActorGraphInterpreter$$anonfun$receive$1.applyOrElse(ActorGraphInterpreter.scala:790) at akka.actor.Actor.aroundReceive(Actor.scala:537) at akka.actor.Actor.aroundReceive$(Actor.scala:535) at akka.stream.impl.fusing.ActorGraphInterpreter.aroundReceive(ActorGraphInterpreter.scala:691) at akka.actor.ActorCell.receiveMessage(ActorCell.scala:579) at akka.actor.ActorCell.invoke(ActorCell.scala:547) at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:270) at akka.dispatch.Mailbox.run(Mailbox.scala:231) at akka.dispatch.Mailbox.exec(Mailbox.scala:243) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1176) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1647) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1614) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) Caused by: java.lang.UnsatisfiedLinkError: no glass_monocle in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2423) at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:808) at java.base/java.lang.System.loadLibrary(System.java:1912) at com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:163) at com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:53) at com.sun.glass.ui.monocle.LinuxSystem.loadLibrary(LinuxSystem.java:76) at com.sun.glass.ui.monocle.X11Platform.(X11Platform.java:39) at com.sun.glass.ui.monocle.X11PlatformFactory.createNativePlatform(X11PlatformFactory.java:55) at com.sun.glass.ui.monocle.NativePlatformFactory.getNativePlatform(NativePlatformFactory.java:112) at com.sun.glass.ui.monocle.MonocleApplication.(MonocleApplication.java:49) at com.sun.glass.ui.monocle.MonoclePlatformFactory.createApplication(MonoclePlatformFactory.java:42) at com.sun.glass.ui.Application.run(Application.java:144) at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:286) ... 82 more

FlorianKirmaier commented 3 years ago

This part in your configuration looks suspicious: <JVMArg> --enable-native-access=org.goliath.crosspoint,org.goliath.bindings.nvml,ALL-UNNAMED</JVMArg> Be aware, that arguments can contain whitespace, in all OS the arguments to a command can contain whitespace, so there are ugly corner cases where people actually want whitespace and not argument separators. Maybe removing the whitespace at the beginning might help.

I would recommend you comparing your project with HelloJProMaven. Does the same issue happen there? Then I would gradually add your configurations in your current project to HelloJProMaven, and see, whether you can reproduce the same error.

The effect of the issue is, that the JVM is not configured to work with JPro. This causes: