B4J Question NullPointer exception when using B4xPages and printing with B4j Print JavaFX8

stevel05

Expert
Licensed User
Longtime User
I have come across an issue when attempting to print within a B4xPages project in debug mode. Specifically when using a virtual printer and the file selection dialog is displayed.

These are the logs that are shown:

B4X:
Waiting for debugger to connect...
Program started.
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
Unexpected event (missing RaiseSynchronousEvents): mainform_focuschanged
java.lang.Exception: Stack trace
    at java.base/java.lang.Thread.dumpStack(Thread.java:1387)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:199)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
    at anywheresoftware.b4a.BA$1.run(BA.java:236)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._enterNestedEventLoopImpl(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._enterNestedEventLoop(WinApplication.java:201)
    at javafx.graphics/com.sun.glass.ui.Application.enterNestedEventLoop(Application.java:509)
    at javafx.graphics/com.sun.glass.ui.EventLoop.enter(EventLoop.java:107)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.enterNestedEventLoop(QuantumToolkit.java:591)
    at javafx.graphics/com.sun.prism.j2d.print.J2DPrinterJob$J2DPageable.implPrintPage(J2DPrinterJob.java:1178)
    at javafx.graphics/com.sun.prism.j2d.print.J2DPrinterJob$J2DPageable.access$500(J2DPrinterJob.java:1004)
    at javafx.graphics/com.sun.prism.j2d.print.J2DPrinterJob.print(J2DPrinterJob.java:829)
    at javafx.graphics/javafx.print.PrinterJob.printPage(PrinterJob.java:399)
    at javafx.graphics/javafx.print.PrinterJob.printPage(PrinterJob.java:415)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
    at b4j.example.printerjob._printpage(printerjob.java:51)
    at b4j.example.b4xmainpage._button1_click(b4xmainpage.java:78)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
    at anywheresoftware.b4a.BA$1.run(BA.java:236)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
    at java.base/java.lang.Thread.run(Thread.java:834)
2022-10-24T10:17:52.354ZE [2948:ShellIpcClient] shell_ipc_client.cc:129:Connect Can't connect to socket at: \\.\Pipe\GoogleDriveFSPipe_lamin_shell
2022-10-24T10:17:52.355ZE [2948:ShellIpcClient] shell_ipc_client.cc:602:operator() Failed to connect to the server: Status::UNAVAILABLE_RESOURCE
2022-10-24T10:17:52.355ZE [9264:ShellIpcClient] shell_ipc_client.cc:129:Connect Can't connect to socket at: \\.\Pipe\GoogleDriveFSPipe_lamin_shell
2022-10-24T10:17:52.355ZE [9264:ShellIpcClient] shell_ipc_client.cc:602:operator() Failed to connect to the server: Status::UNAVAILABLE_RESOURCE
2022-10-24T10:17:52.355ZE [16180:ShellIpcClient] shell_ipc_client.cc:129:Connect Can't connect to socket at: \\.\Pipe\GoogleDriveFSPipe_lamin_shell
2022-10-24T10:17:52.355ZE [16180:ShellIpcClient] shell_ipc_client.cc:602:operator() Failed to connect to the server: Status::UNAVAILABLE_RESOURCE
2022-10-24T10:17:52.366ZE [2948:ShellIpcClient] shell_ipc_client.cc:129:Connect Can't connect to socket at: \\.\Pipe\GoogleDriveFSPipe_lamin_shell
2022-10-24T10:17:52.366ZE [2948:ShellIpcClient] shell_ipc_client.cc:602:operator() Failed to connect to the server: Status::UNAVAILABLE_RESOURCE
2022-10-24T10:17:52.367ZE [9264:ShellIpcClient] shell_ipc_client.cc:129:Connect Can't connect to socket at: \\.\Pipe\GoogleDriveFSPipe_lamin_shell
2022-10-24T10:17:52.367ZE [9264:ShellIpcClient] shell_ipc_client.cc:602:operator() Failed to connect to the server: Status::UNAVAILABLE_RESOURCE
2022-10-24T10:17:52.367ZE [16180:ShellIpcClient] shell_ipc_client.cc:129:Connect Can't connect to socket at: \\.\Pipe\GoogleDriveFSPipe_lamin_shell
2022-10-24T10:17:52.367ZE [16180:ShellIpcClient] shell_ipc_client.cc:602:operator() Failed to connect to the server: Status::UNAVAILABLE_RESOURCE
2022-10-24T10:17:52.461ZE [2948:ShellIpcClient] shell_ipc_client.cc:129:Connect Can't connect to socket at: \\.\Pipe\GoogleDriveFSPipe_lamin_shell
2022-10-24T10:17:52.461ZE [2948:ShellIpcClient] shell_ipc_client.cc:602:operator() Failed to connect to the server: Status::UNAVAILABLE_RESOURCE
2022-10-24T10:17:52.461ZE [9264:ShellIpcClient] shell_ipc_client.cc:129:Connect Can't connect to socket at: \\.\Pipe\GoogleDriveFSPipe_lamin_shell
2022-10-24T10:17:52.461ZE [9264:ShellIpcClient] shell_ipc_client.cc:602:operator() Failed to connect to the server: Status::UNAVAILABLE_RESOURCE
2022-10-24T10:17:52.461ZE [16180:ShellIpcClient] shell_ipc_client.cc:129:Connect Can't connect to socket at: \\.\Pipe\GoogleDriveFSPipe_lamin_shell
2022-10-24T10:17:52.461ZE [16180:ShellIpcClient] shell_ipc_client.cc:602:operator() Failed to connect to the server: Status::UNAVAILABLE_RESOURCE
2022-10-24T10:17:52.502ZE [2948:ShellIpcClient] shell_ipc_client.cc:129:Connect Can't connect to socket at: \\.\Pipe\GoogleDriveFSPipe_lamin_shell
2022-10-24T10:17:52.502ZE [2948:ShellIpcClient] shell_ipc_client.cc:602:operator() Failed to connect to the server: Status::UNAVAILABLE_RESOURCE
2022-10-24T10:17:52.502ZE [9264:ShellIpcClient] shell_ipc_client.cc:129:Connect Can't connect to socket at: \\.\Pipe\GoogleDriveFSPipe_lamin_shell
2022-10-24T10:17:52.502ZE [9264:ShellIpcClient] shell_ipc_client.cc:602:operator() Failed to connect to the server: Status::UNAVAILABLE_RESOURCE
2022-10-24T10:17:52.502ZE [16180:ShellIpcClient] shell_ipc_client.cc:129:Connect Can't connect to socket at: \\.\Pipe\GoogleDriveFSPipe_lamin_shell
2022-10-24T10:17:52.502ZE [16180:ShellIpcClient] shell_ipc_client.cc:602:operator() Failed to connect to the server: Status::UNAVAILABLE_RESOURCE
2022-10-24T10:17:52.621ZE [2948:ShellIpcClient] shell_ipc_client.cc:129:Connect Can't connect to socket at: \\.\Pipe\GoogleDriveFSPipe_lamin_shell
2022-10-24T10:17:52.621ZE [2948:ShellIpcClient] shell_ipc_client.cc:602:operator() Failed to connect to the server: Status::UNAVAILABLE_RESOURCE
2022-10-24T10:17:52.621ZE [9264:ShellIpcClient] shell_ipc_client.cc:129:Connect Can't connect to socket at: \\.\Pipe\GoogleDriveFSPipe_lamin_shell
2022-10-24T10:17:52.621ZE [9264:ShellIpcClient] shell_ipc_client.cc:602:operator() Failed to connect to the server: Status::UNAVAILABLE_RESOURCE
2022-10-24T10:17:52.621ZE [16180:ShellIpcClient] shell_ipc_client.cc:129:Connect Can't connect to socket at: \\.\Pipe\GoogleDriveFSPipe_lamin_shell
2022-10-24T10:17:52.621ZE [16180:ShellIpcClient] shell_ipc_client.cc:602:operator() Failed to connect to the server: Status::UNAVAILABLE_RESOURCE
2022-10-24T10:17:52.634ZE [2948:ShellIpcClient] shell_ipc_client.cc:129:Connect Can't connect to socket at: \\.\Pipe\GoogleDriveFSPipe_lamin_shell
2022-10-24T10:17:52.634ZE [2948:ShellIpcClient] shell_ipc_client.cc:602:operator() Failed to connect to the server: Status::UNAVAILABLE_RESOURCE
2022-10-24T10:17:52.635ZE [9264:ShellIpcClient] shell_ipc_client.cc:129:Connect Can't connect to socket at: \\.\Pipe\GoogleDriveFSPipe_lamin_shell
2022-10-24T10:17:52.635ZE [9264:ShellIpcClient] shell_ipc_client.cc:602:operator() Failed to connect to the server: Status::UNAVAILABLE_RESOURCE
2022-10-24T10:17:52.635ZE [16180:ShellIpcClient] shell_ipc_client.cc:129:Connect Can't connect to socket at: \\.\Pipe\GoogleDriveFSPipe_lamin_shell
2022-10-24T10:17:52.635ZE [16180:ShellIpcClient] shell_ipc_client.cc:602:operator() Failed to connect to the server: Status::UNAVAILABLE_RESOURCE
Error occurred on line: 433 (B4XPagesManager)
java.lang.NullPointerException
    at b4j.example.b4xpagesmanager._mainform_focuschanged(b4xpagesmanager.java:562)
    at b4j.example.b4xpagesdelegator._mainform_focuschanged(b4xpagesdelegator.java:78)
    at b4j.example.main._mainform_focuschanged(main.java:123)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at anywheresoftware.b4a.shell.Shell$1.run(Shell.java:206)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
    at java.base/java.lang.Thread.run(Thread.java:834)
Error occurred on line: 433 (B4XPagesManager)
java.lang.NullPointerException
    at anywheresoftware.b4a.shell.Shell.runGoodChain(Shell.java:370)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:181)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at anywheresoftware.b4a.shell.Shell$1.run(Shell.java:206)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
    at java.base/java.lang.Thread.run(Thread.java:834)

I can see that there is an Unexpected event (missing RaiseSynchronousEvents): mainform_focuschanged
and a NullPointer exception in b4xpagesmanager._mainform_focuschanged when the dialog closes.

When The MainForm_FocusChanged event is raised after the dialog has closed, HasFocus is a valid boolean. I don't think there is anything else I can do to patch this in my app apart from commenting out the delegate call.

The attached simple app shows the problem, Requires B4j Print JavaFX8 b4xlib. My default printer is "Microsoft print to PDF"
 

Attachments

  • Project.zip
    8.7 KB · Views: 183
Top