system.print.createPrintJob not working with NCL embedded Azul 9.0.7.2

I am using a simple script on a button actionPerformed to print a barcode in v7.9.10. It works fine in the designer and in clients launched via JWS. If I use the Native Client Launcher to deploy (which I prefer), I get nondescript NPE errors. Anybody else have this issue?

edit: My installed Java version is Oracle 1.8.0_201. The NCL runs Azul 9.0.7.2

Button Script:

PrintBarcode = system.print.createPrintJob(event.source.parent.getComponent('Barcode'))
PrintBarcode.setShowPrintDialog(0)
PrintBarcode.setPageHeight(1.5)
PrintBarcode.setPageWidth(2.0)
PrintBarcode.setOrientation(1)
PrintBarcode.setLeftMargin(.3)
PrintBarcode.setRightMargin(0)
PrintBarcode.setTopMargin(.1)
PrintBarcode.setBottomMargin(.1)
PrintBarcode.setFitToPage(1)
PrintBarcode.setPrinterName('Tharo V-425E')

PrintBarcode.print()

Error thread dump:

java.lang.NullPointerException
	at java.desktop/sun.print.RasterPrinterJob.setAttributes(Unknown Source)
	at java.desktop/sun.awt.windows.WPrinterJob.setAttributes(Unknown Source)
	at java.desktop/sun.print.RasterPrinterJob.print(Unknown Source)
	at com.inductiveautomation.factorypmi.application.print.FPMIPrinterJob.print(FPMIPrinterJob.java:455)
	at com.inductiveautomation.factorypmi.application.script.builtin.PrintUtilities$JythonPrintJob.print(PrintUtilities.java:129)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:186)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:204)
	at org.python.core.PyObject.__call__(PyObject.java:387)
	at org.python.core.PyObject.__call__(PyObject.java:391)
	at org.python.core.PyMethod.__call__(PyMethod.java:109)
	at org.python.pycode._pyx4.f$0(<event:actionPerformed>:20)
	at org.python.pycode._pyx4.call_function(<event:actionPerformed>)
	at org.python.core.PyTableCode.call(PyTableCode.java:165)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1275)
	at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:636)
	at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:603)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:182)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:271)
	at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:57)
	at com.sun.proxy.$Proxy25.actionPerformed(Unknown Source)
	at java.desktop/javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at java.desktop/javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
	at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.Component.processEvent(Unknown Source)
	at java.desktop/java.awt.Container.processEvent(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.EventQueue.access$500(Unknown Source)
	at java.desktop/java.awt.EventQueue$3.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$3.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)

Ignition v7.9.10 (b2018112821)
Java: Azul Systems, Inc. 9.0.7.2

Ignition still packages the original NCLs – and you can rename the files in your gateway to have the older one get served from the homepage.

Thanks, yeah, I would really like to avoid having to install Java separately on all the clients. I wonder if I could figure out how to bundle Oracle 1.8 with the new NCL. Or maybe the problem has been fixed in a subsequent release of the Azul build, and I just need to figure out how to update that…

This is probably a bug - write or call into support so it gets officially tracked.

1 Like

I’ve used Phil Turmel’s graciously provided “Introspect” script on a few very helpful occasions, but trying it out just today (which is the first time I’ve used it since the NCL came embedded with the Azul Systems 9.0.7.2 JVM) an exception gets thrown due to the reflect method no longer being accessible in the java.lang library…as follows:

com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last):
  File "<event:propertyChange>", line 4, in <module>
  File "<module:shared.Introspect>", line 31, in introspect
ImportError: cannot import name reflect

	at org.python.core.Py.ImportError(Py.java:304)
	at org.python.core.imp.importFromAs(imp.java:1023)
	at org.python.core.imp.importFrom(imp.java:987)
	at org.python.pycode._pyx167.introspect$1(<module:shared.Introspect>:87)
	at org.python.pycode._pyx167.call_function(<module:shared.Introspect>)
	at org.python.core.PyTableCode.call(PyTableCode.java:165)
	at org.python.core.PyBaseCode.call(PyBaseCode.java:134)
	at org.python.core.PyFunction.__call__(PyFunction.java:317)
	at org.python.pycode._pyx175.f$0(<event:propertyChange>:4)
	at org.python.pycode._pyx175.call_function(<event:propertyChange>)
	at org.python.core.PyTableCode.call(PyTableCode.java:165)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1275)
	at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:636)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:180)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.access$000(ActionAdapter.java:40)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter$ActionRunner.run(ActionAdapter.java:286)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.EventQueue.access$500(Unknown Source)
	at java.desktop/java.awt.EventQueue$3.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$3.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
Caused by: org.python.core.PyException: Traceback (most recent call last):
  File "<event:propertyChange>", line 4, in <module>
  File "<module:shared.Introspect>", line 31, in introspect
ImportError: cannot import name reflect

I couldn’t help but notice a line in your stack trace included…a couple references to the reflect method.

While this post was on the back burner, I think I found where they’re “hiding” the reflect method…it’s in org.apache.commons.lang3.* of the Azul base package that Ignition uses for the NCL.

1 Like