gluonhq / client-samples

Client samples to run with Gluon Client plugins for Maven and Gradle
114 stars 23 forks source link

Exe generated by the plugin on windows 8 is not running #88

Open aminabs opened 4 years ago

aminabs commented 4 years ago

Hi there,

This is related to #89 but not the same.

Using the client-maven-plugin version 0.1.27 I am able to generate an exe file for a very simple sample which is consist of an HBox with a button all inside a StackPane as the root pane of scene.

However, the exe when launched does nothing. No error even if you run it from a command shell (cmd). Simply nothing happens. I've check the task manager, no process is forked or it is so fast terminating which is not visible on the task manager list of processes.

My machine settings are: Windows 8 openjdk version "11.0.1" 2018-10-16 graalvm-ce-java11-windows-amd64-20.2.0

Here are the important sections of my pom.xml file:

...
      <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>14.0.1</version>
        </dependency>
...

 <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <release>11</release>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.gluonhq</groupId>
                <artifactId>client-maven-plugin</artifactId>
                <version>0.1.27</version>
                <configuration>
                    <mainClass>com.mycompany.gluonnew.App</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>

Would you please help me on this?

jperedadnr commented 4 years ago

Most likely you have an exception, you need to check the output.

By default, you will find a log here: target\client\x86_64-windows\gvm\log, search for the RUN task logs.

Another option is to launch the executable from a command prompt and redirect standard out and err to a file:

target\client\x86_64-windows\hellofx.exe > out.txt 2>&1

Yet another option is to use the java logging framework and log to a file instead of console.

aminabs commented 4 years ago

Thanks @jperedadnr,

No logs. I've redirected the exe output to out.txt. The file is empty after running the program.

To clarify, I am able to generate the exe file and logs are appended to the client-debug0.log file. I just cant execute the program. When I run it simply does nothing and ends. No output. No error.

The weird thing that I am able to generate and run a more simple sample. But when using TableView it is not working.

Kindly please note that in #89 I've provided all details including source code and pom.xml.

jperedadnr commented 4 years ago

Can you add <verbose>true</verbose> to the plugin, and run again mvn client:link client:run?

See if you get more output in the client-debug.log file.

aminabs commented 4 years ago
true

I'm doing so right now.

BTW, I've just understand that I've not provided enough information on how I am running the program.

I was not running it via mvn client:run command. I simply double clicked the exe file or executed it via cmd shell. (So no logs are expected in this case, am I right?)

Another question would be Is it possible for the plugin to generate the exe file while skipping build errors?

jperedadnr commented 4 years ago

Right, gvm/log is only enabled if you run with mvn client:run.

If there are build errors, you won't get an exe.

aminabs commented 4 years ago

Here is the result when mvn client:run issued. The same with mvn client:link client:run

[Tue Jun 09 22:10:59 IRDT 2020][INFO] ==================== RUN TASK ====================
[Tue Jun 09 22:10:59 IRDT 2020][FINE] PB Command for run until end: C:\Users\Amin\Documents\NetBeansProjects\GluonNew\target\client\x86_64-windows\GluonNew.exe
[Tue Jun 09 22:10:59 IRDT 2020][FINE] Start process run until end...
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB] Exception in Application start method
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB] Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at java.lang.Thread.run(Thread.java:834)
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:517)
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at com.oracle.svm.core.windows.WindowsJavaThreads.osThreadStartRoutine(WindowsJavaThreads.java:138)
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB] Caused by: java.lang.AssertionError: java.lang.ClassNotFoundException: javafx.scene.control.TableColumnBase
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at com.sun.javafx.util.Utils.forceInit(Utils.java:858)
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at com.sun.javafx.scene.control.TableColumnBaseHelper.<clinit>(TableColumnBaseHelper.java:39)
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:351)
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:271)
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at javafx.scene.control.TableColumnBase.<clinit>(TableColumnBase.java:132)
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:351)
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:271)
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at java.lang.Class.ensureInitialized(DynamicHub.java:508)
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:236)
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at com.mycompany.gluonnew.App.start(App.java:24)
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at java.security.AccessController.doPrivileged(AccessController.java:101)
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_VA_LIST:Ljava_lang_Runnable_2_0002erun_00028_00029V(JNIJavaCallWrappers.java:0)
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at com.sun.glass.ui.win.WinApplication._runLoop(WinApplication.java)
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     ... 3 more
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB] Caused by: java.lang.ClassNotFoundException: javafx.scene.control.TableColumnBase
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at com.oracle.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:60)
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at java.lang.Class.forName(DynamicHub.java:1220)
[Tue Jun 09 22:10:59 IRDT 2020][FINE] [SUB]     at com.sun.javafx.util.Utils.forceInit(Utils.java:855)
jperedadnr commented 4 years ago

there you go: java.lang.ClassNotFoundException: javafx.scene.control.TableColumnBase

Explanation: you are using FXML in your project, that uses reflection. All classes that are called reflectively have to be added to the reflectionList. See https://docs.gluonhq.com/client/#_reflectionlist

The plugin already takes care of most of the JavaFX classes, but some of them are still missing.

Simply fix: add this to the plugin. You will need to run mvn client:build again.

<reflectionList>
    <item>javafx.scene.control.TableColumnBase</item>
</reflectionList>
aminabs commented 4 years ago

I'm not using reflection nor fxml.

Here is the code snippet from #89


TableView<X> table = new TableView<>();
        for (int i = 0; i < 100; i++) {
            TableColumn<X, Integer> a = new TableColumn<>("A" + i);
            a.setCellValueFactory(p -> new SimpleObjectProperty<>(p.getValue().getId()));
            a.setCellFactory((TableColumn<X, Integer> p) -> new TableCell<>()
            {
                @Override
                protected void updateItem(Integer item, boolean empty)
                {
                    if (empty || item == null)
                        super.updateItem(item, empty);
                    else
                        setText(item + "");
                }

            });

            table.getColumns().add(a);
        }
        for (int i = 0; i < 100; i++) {
            table.getItems().add(new X(i));
        }
        var scene = new Scene(new StackPane(table), 640, 480);
        stage.setScene(scene);
        stage.show();
jperedadnr commented 4 years ago

Well, right, you are not using FXML (my bad)

However, JavaFX does use reflection in this call: com.sun.javafx.util.Utils.forceInit (see https://github.com/openjdk/jfx/blob/22d4343fe8563c2931910b98e8f18c6fd4a48f05/modules/javafx.graphics/src/main/java/com/sun/javafx/util/Utils.java#L853)

The proposed fix still applies.

aminabs commented 4 years ago

I'm testing the fix right now,

If so, I will continue the rest in #89 since It has yet another part which is unresolved.

aminabs commented 4 years ago

OK, the program is now running. However, it crashes when I do some scrolling over the table data then clicking a row (I am not sure if the reproduction steps are like this actually)

Note:

  1. No difference when running the exe directly or using mvn client:run. It sometimes crashes.

  2. It sometimes does not crash

  3. No logs available

I'm just confused.

jperedadnr commented 4 years ago

The same procedure applies: you need to see the logs, you will find an exception at some point. If it is a class not found exception, add it to the reflection list and build all over again.

aminabs commented 4 years ago

Yes, my bad. I edited the comment above: 3. No logs available.

Note: I clicked over a row. Then maximized the stage here is what happened (the image attached)

image

aminabs commented 4 years ago

Here are logs for last 3 executions with at least one crash

[Tue Jun 09 22:29:26 IRDT 2020][INFO] ==================== RUN TASK ==================== [Tue Jun 09 22:29:26 IRDT 2020][FINE] PB Command for run until end: C:\Users\Amin\Documents\NetBeansProjects\GluonNew\target\client\x86_64-windows\GluonNew.exe [Tue Jun 09 22:29:26 IRDT 2020][FINE] Start process run until end... [Tue Jun 09 22:30:40 IRDT 2020][FINE] [SUB] Main [Tue Jun 09 22:30:40 IRDT 2020][FINE] Result for run until end: 0 [Tue Jun 09 22:30:45 IRDT 2020][INFO] ==================== RUN TASK ==================== [Tue Jun 09 22:30:45 IRDT 2020][FINE] PB Command for run until end: C:\Users\Amin\Documents\NetBeansProjects\GluonNew\target\client\x86_64-windows\GluonNew.exe [Tue Jun 09 22:30:45 IRDT 2020][FINE] Start process run until end... [Tue Jun 09 22:30:51 IRDT 2020][FINE] [SUB] Main [Tue Jun 09 22:30:51 IRDT 2020][FINE] Result for run until end: 0 [Tue Jun 09 22:31:17 IRDT 2020][INFO] ==================== RUN TASK ==================== [Tue Jun 09 22:31:17 IRDT 2020][FINE] PB Command for run until end: C:\Users\Amin\Documents\NetBeansProjects\GluonNew\target\client\x86_64-windows\GluonNew.exe [Tue Jun 09 22:31:17 IRDT 2020][FINE] Start process run until end... [Tue Jun 09 22:31:23 IRDT 2020][FINE] [SUB] Main [Tue Jun 09 22:31:23 IRDT 2020][FINE] Result for run until end: 0

aminabs commented 4 years ago

I've found that it rarely happen when running via mvn client:run command.

But it is very likely to happen when double clicking the exe file. (Can't log this?)

jperedadnr commented 4 years ago

I mentioned it above: open a terminal and run:

\path\to\target\client\x86_64-windows\hellofx.exe > out.txt 2>&1

aminabs commented 4 years ago

Yes you were. Now I did it. no logs when crashed. The out.txt file is empty again. A hundred percent of times it crashes when running directly via terminal as above or double clicked.

99% of times it works fine when mvn client: run.

aminabs commented 4 years ago

So, redirecting output when executed normally (without mvn client:run command) results in an empty log file. No logs on the console or the log file.

Again when mvn client:run is issued, rarely crashing (only one time) and no error logs (all FINE if any)

zrb80 commented 4 years ago

I faced similar issue too. The successfully assembled project starts. But, when start using it for its intended purpose, the project just closes. There is not enough debug mode in the assembled project in order to understand what the problem is.

jperedadnr commented 4 years ago

@zrb80 see https://github.com/gluonhq/client-samples/issues/88#issuecomment-641459463

zrb80 commented 4 years ago

Thanks @jperedadnr, I have tried all the recommendations the same way. All is unsuccessful. No output. No error.

The Java logging framework is good. Need to think about how you can use it with Log4J2 Framework

zrb80 commented 4 years ago

Added Log4J2 to the project. And after a successful build at startup, this comes out image

jperedadnr commented 4 years ago

Setting up the log framework might not be straightforward.

Without it, can you just add <verbose>true</verbose> to the plugin, and run mvn client:link client:run, then check the logs under target\client\x86_64-microsoft\gvm\log. Can you post the log with the RUN task?

zrb80 commented 4 years ago

client-debug0.log AND [яэ рту. 24 22:38:43 MSK 2020][INFO] ==================== LINK TASK ==================== [яэ рту. 24 22:38:43 MSK 2020][FINE] Looking for resource: /native/windows/launcher.c [яэ рту. 24 22:38:43 MSK 2020][FINE] PB Command for compile-additional-sources: cl -c -DGVM_VERBOSE -DSUBSTRATE /MD /D_UNICODE /DUNICODE /DWIN32 /D_WINDOWS -ID:\MyProjects\java\tst\CutReportINV19\target\client\x86_64-windows\gvm\CutReportINV19 launcher.c [яэ рту. 24 22:38:43 MSK 2020][FINE] Start process compile-additional-sources... [яэ рту. 24 22:38:43 MSK 2020][FINE] [SUB] Оптимизирующий компилятор Microsoft (R) C/C++ версии 19.26.28805 для x64 [яэ рту. 24 22:38:43 MSK 2020][FINE] [SUB] (C) Корпорация Майкрософт (Microsoft Corporation). Все права защищены. [яэ рту. 24 22:38:43 MSK 2020][FINE] [SUB] [яэ рту. 24 22:38:43 MSK 2020][FINE] [SUB] launcher.c [яэ рту. 24 22:38:43 MSK 2020][FINE] Result for compile-additional-sources: 0 [яэ рту. 24 22:38:44 MSK 2020][FINE] PB Command for link: link D:\MyProjects\java\tst\CutReportINV19\target\client\x86_64-windows\gvm\CutReportINV19\launcher.obj D:\MyProjects\java\tst\CutReportINV19\target\client\x86_64-windows\gvm\tmp\SVM-1598297837117\su.netsoft.cutreportinv19.mainapp.obj advapi32.lib iphlpapi.lib secur32.lib userenv.lib ws2_32.lib j2pkcs11.lib java.lib net.lib nio.lib prefs.lib fdlibm.lib sunec.lib zip.lib ffi.lib jvm.lib libchelper.lib /NODEFAULTLIB:libcmt.lib /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup comdlg32.lib dwmapi.lib gdi32.lib imm32.lib shell32.lib uiautomationcore.lib urlmon.lib winmm.lib glass.lib javafx_font.lib javafx_iio.lib prism_common.lib prism_d3d.lib /WHOLEARCHIVE:glass.lib /WHOLEARCHIVE:javafx_font.lib /WHOLEARCHIVE:javafx_iio.lib /WHOLEARCHIVE:prism_common.lib /WHOLEARCHIVE:prism_d3d.lib /OUT:D:\MyProjects\java\tst\CutReportINV19\target\client\x86_64-windows\CutReportINV19.exe /LIBPATH:C:\Users\Rus.gluon\substrate\javafxStaticSdk\15-ea+gvm22\windows-x86_64\sdk\lib /LIBPATH:D:\MyProjects\java\tools\graalvm-ce-java11-20.2.0\lib\svm\clibraries\windows-amd64 /LIBPATH:D:\MyProjects\java\tools\graalvm-ce-java11-20.2.0\lib\static\windows-amd64 [яэ рту. 24 22:38:44 MSK 2020][FINE] Start process link... [яэ рту. 24 22:38:44 MSK 2020][INFO] [SUB] Microsoft (R) Incremental Linker Version 14.26.28805.0 [яэ рту. 24 22:38:44 MSK 2020][INFO] [SUB] Copyright (C) Microsoft Corporation. All rights reserved. [яэ рту. 24 22:38:44 MSK 2020][INFO] [SUB] [яэ рту. 24 22:38:44 MSK 2020][INFO] [SUB] Создается библиотека D:\MyProjects\java\tst\CutReportINV19\target\client\x86_64-windows\CutReportINV19.lib и объект D:\MyProjects\java\tst\CutReportINV19\target\client\x86_64-windows\CutReportINV19.exp [яэ рту. 24 22:38:44 MSK 2020][FINE] Result for link: 0 [яэ рту. 24 22:38:44 MSK 2020][FINE] Logging process [link] to file: D:\MyProjects\java\tst\CutReportINV19\target\client\log\process-link-1598297924832.log [яэ рту. 24 22:39:24 MSK 2020][INFO] ==================== RUN TASK ==================== [яэ рту. 24 22:39:24 MSK 2020][FINE] PB Command for run until end: D:\MyProjects\java\tst\CutReportINV19\target\client\x86_64-windows\CutReportINV19.exe [яэ рту. 24 22:39:24 MSK 2020][FINE] Start process run until end... [яэ рту. 24 22:39:24 MSK 2020][FINE] [SUB] Main [яэ рту. 24 22:39:47 MSK 2020][FINE] Result for run until end: 0

jperedadnr commented 4 years ago

I see it works for 23 seconds, so it might crash at some given point? Maybe when you access some view or click on some action? Could you guess which one? Probably wrapping that node/action with something like:

try {
...
} catch (Throwable t) {
    System.out.println("Error");
    t.printStackTrace();
} 

might not work at all, but it's worth trying?

zrb80 commented 4 years ago

Yes. When starting Task.

I added to event print exception. getException().printStackTrace(); And this is what happened image

client-debug0.log

jperedadnr commented 4 years ago

OK, that's good, it gives you the reason why it fails: the class org.apache.poi.xssf.usermodel.XSSFSheet is missing from the <reflectionList/>. Add it and try again.

zrb80 commented 4 years ago

I added. But when building the project, an error comes out. image See client-debug0.log

zrb80 commented 4 years ago

https://github.com/oracle/graal/issues/2187

I understand that this is a similar question. Just need to wait for the fix. Right?

zrb80 commented 4 years ago

@jperedadnr , thank you for your help! Thank you for helping me figure out how to work with debugging in the project. Debugging actually works.

I will wait for a solution to the issue of the correct work of the native-image application using Apache POI.

Plantrek commented 4 years ago

Just so same, confusing problem. 100% runs via mvn client:run are fine, 100% direct runs are terminated abruptly, silently, confusingly, at the point that I could not know.

jperedadnr commented 4 years ago

@Plantrek See if you can apply some of the suggestions in this thread. Without a reproducible case, I can't help you.