7.9.2 SDK Expression Functions Broken

I’ve defined an expression function in one of my modules as:

public static class GetStackTraceFunction extends AbstractFunction{

    @Override
    protected String getFunctionDisplayName() {
        return "getStackTrace";
    }

    @Override
    public String getArgDocString() {
        return "";
    }

    @Override
    public Class<?> getType() {
        return String.class;
    }

    @Override
    public QualifiedValue execute(Expression[] expressions) throws ExpressionException {
        return new BasicQualifiedValue(Thread.currentThread().getStackTrace()[0].toString());
    }

}

I’m adding it to the client/designer scope by calling the following in my hook classes:

@Override
public void configureFunctionFactory(ExpressionFunctionManager factory) {
    super.configureFunctionFactory(factory);
    factory.addFunction("getUUID","Strings", new AbstractSystemUtils.GetUUIDFunction());
    factory.addFunction("getStackTrace","Strings", new AbstractSystemUtils.GetStackTraceFunction());
}

Now since the upgrade to 7.9.2+, my function can no longer be found from either the designer or client. Any info on this?

Are you sure your client and designer hooks are being loaded and that configureFunctionFactory is being called in each scope?

There haven’t been any intentional changes that would break your module.

Yup it’s in both. I also had to the sdk version from 7.9.1 to 7.9.2 or the client/designer would hang on startup… I’ve got scripts and functions in other modules that didn’t seem to be affected.

Something sounds very wrong with what you’re saying.

The SDK is just an API you compile against. None of it actually goes into your module or should effect the implementation. If anything, changing Ignition versions would make a difference, but not SDK versions (unless we changed an API in a way we shouldn’t have).

Do you have any logs, both from the gateway and from enabling the Java console and starting a client/designer?

Alright, so the reason your module hangs on 7.9.1 is because of this error:

Exception in thread "Designer-Startup" java.lang.NoSuchMethodError: com.inductiveautomation.ignition.client.script.ClientTagUtilities.<init>(Lcom/inductiveautomation/ignition/client/model/ClientContext;)V
	at com.tamakicontrol.modules.scripting.client.scripts.ClientTagUtils.initialize(ClientTagUtils.java:31)
	at com.tamakicontrol.modules.scripting.designer.DesignerHook.startup(DesignerHook.java:34)
	at com.inductiveautomation.ignition.designer.IgnitionDesigner$LoadedModule.startup(IgnitionDesigner.java:1746)
	at com.inductiveautomation.ignition.designer.IgnitionDesigner.startupModule(IgnitionDesigner.java:961)
	at com.inductiveautomation.ignition.designer.IgnitionDesigner.loadProject(IgnitionDesigner.java:839)
	at com.inductiveautomation.ignition.designer.IgnitionDesigner$StartupProjectDialogHandler$1.run(IgnitionDesigner.java:1818)
	at java.lang.Thread.run(Thread.java:748)

This is because we changed the constructor for our ClientTagUtilities between 7.9.1 and 7.9.2 from taking a ClientTagManager to taking a ClientContext. I’m not sure we consider any of our scripting utility classes to be part of the public API despite their reachability from 3rd party code, but either way what’s done is done.

To further complicate things, in 7.9.2 and 7.9.3 your module loads without error, but it appears we broke something and that client and designer hooks never get their configureFunctionFactory() methods called… so I’m going to look into that now.

Thanks Kevin! I’ll change it to access tag through the Client Context/Tag Manager. For now, if I fix this then build the module with the 7.9.1 SDK will that work?

As things are now, your expression functions will only work on Ignition 7.9.1 (and that’s only after you change your SDK version to 7.9.1 and then fix the compilation error you get re: ClientContext vs ClientTagManager).

Ok I can work with that. Thanks for your help Kevin.

No problem. I’m going to try to get this fixed for 7.9.4 if it’s not too late.

1 Like

If you have a chance, try 7.9.4-beta1 and verify that your custom expression functions work again.

1 Like

That works. Thanks Kevin!

1 Like