NullPointerException when calling VisionClientInterface.getGuiUtil

Hi,

I have below code in my module’s client hook:

public void startup(ClientContext context, LicenseState activationState) throws Exception {
super.startup(context, activationState);
VisionClientInterface vision = (VisionClientInterface)context.getModule(VisionClientInterface.VISION_MODULE_ID);

	if(vision != null)
	{
		vision.getGuiUtil();
	}
}

When I install the module and start the client, I get following error
java.lang.NullPointerException: null
at com.inductiveautomation.factorypmi.application.runtime.ClientContextImpl.getGuiUtil(ClientContextImpl.java:438)
at com.vaspsolutions.mymodule.client.MyModuleClientHook.startup(MyModuleClientHook.java:30)
at com.inductiveautomation.factorypmi.application.runtime.ClientContextImpl$LoadedModule.startup(ClientContextImpl.java:328)
at com.inductiveautomation.factorypmi.application.runtime.ClientContextImpl.startup(ClientContextImpl.java:373)
at com.inductiveautomation.factorypmi.application.runtime.ClientPanel.startupApp(ClientPanel.java:710)
at com.inductiveautomation.factorypmi.application.runtime.ClientPanel$LoginAction$LoginTask.run(ClientPanel.java:547)
at java.lang.Thread.run(Unknown Source)

Tried this with Ignition SDK versions 7.9.3, 7.9.4 and 7.9.5-SNAPSHOT
Ignition versions 7.9.5 and 7.9.7.

Is this an issue with API or am I missing something ?
getGUIUtil when called from VisionDesignerInterface in the designer hook works correctly.

Request to please help.

Based on the JavaDoc, I would guess that it is related to multiple desktop support, where the initial desktop hasn’t been established at module hook time. You might have to refactor your code to retrieve this interface when needed, respecting the possibility of different desktops, instead of assuming there’s only one instance.

1 Like

Thanks . After moving the code from client hook startup to the constructor of my vision component, the problem is solved.

1 Like