V8 API: browseAsync returns null values

ignition80
#1

I’m attempting to find tagpaths in one of my tagproviders. With this code.

public void setup(GatewayContext gatewayContext) {
    	try {
    		provider=TagPathParser.parseSafe("[default]");
    		 CompletableFuture<Results<NodeDescription>>node=context.getTagManager().getTagProvider("default").browseAsync(provider,bfilter.setRecursive(true));
    		Results <NodeDescription> nodeResult=node.get();
    		Collection<NodeDescription> nodeCollection=nodeResult.getResults();
    		Object[] nodenames=nodeCollection.toArray();
    		
    	}catch(Exception e){
                logger.info(Arrays.toString(nodenames));
    		logger.info("nodenames is: " + nodenames);
    		logger.info("nodeResult is: " + nodeResult);
    		logger.info("nodeCollection is: " + nodeCollection);
    	}
    }

My results from browseAsync are all null.

INFO   | jvm 1    | 2019/08/06 09:19:33 | I [t.d.c.GatewayHook             ] [13:19:33]: null
INFO   | jvm 1    | 2019/08/06 09:19:33 | I [t.d.c.GatewayHook             ] [13:19:33]: nodenames is: null 
INFO   | jvm 1    | 2019/08/06 09:19:33 | I [t.d.c.GatewayHook             ] [13:19:33]: nodeResult is: null 
INFO   | jvm 1    | 2019/08/06 09:19:33 | I [t.d.c.GatewayHook             ] [13:19:33]: nodeCollection is: null
0 Likes

#2

What’s the exception?

Btw, you’ve written your code such that you wouldn’t print anything if it succeeded.

0 Likes

#3

Ah, and doing this during setup in your hook might be too early for the tag manager to be ready to use…

0 Likes

#4

So I’ve move this to the startup(), but I get the same result.

try {
    		provider=TagPathParser.parseSafe("[default]");
    		node=context.getTagManager().getTagProvider("default").browseAsync(provider,bfilter.setRecursive(true));
    		nodeResult=node.get();
    		nodeCollection=nodeResult.getResults();
    		nodenames=nodeCollection.toArray();
    		logger.info(Arrays.toString(nodenames));
    		logger.info("nodenames is: " + nodenames);
    		logger.info("nodeResult is: " + nodeResult);
    		logger.info("nodeCollection is: " + nodeCollection);
    		
    	}catch(Exception e){
    		logger.info("Exception triggered");
    		logger.info(Arrays.toString(nodenames));
    		logger.info("nodenames is: " + nodenames);
    		logger.info("nodeResult is: " + nodeResult);
    		logger.info("nodeCollection is: " + nodeCollection);
    	}

And I don’t get any Exception message from the wrapper file, but it seems to print what’s inside the catch statement anyway.

INFO   | jvm 1    | 2019/08/06 10:07:04 | I [g.ModuleManager               ] [14:07:04]: Starting up module 'tag.database.connection.TagDBV8' v1.0.0 (b0)... module-name=TagDBV8 Ignition Module
INFO   | jvm 1    | 2019/08/06 10:07:04 | I [t.d.c.GatewayHook             ] [14:07:04]: Exception triggered module-name=TagDBV8 Ignition Module
INFO   | jvm 1    | 2019/08/06 10:07:04 | I [t.d.c.GatewayHook             ] [14:07:04]: null module-name=TagDBV8 Ignition Module
INFO   | jvm 1    | 2019/08/06 10:07:04 | I [t.d.c.GatewayHook             ] [14:07:04]: nodenames is: null module-name=TagDBV8 Ignition Module
INFO   | jvm 1    | 2019/08/06 10:07:04 | I [t.d.c.GatewayHook             ] [14:07:04]: nodeResult is: null module-name=TagDBV8 Ignition Module
INFO   | jvm 1    | 2019/08/06 10:07:04 | I [t.d.c.GatewayHook             ] [14:07:04]: nodeCollection is: null module-name=TagDBV8 Ignition Module
0 Likes

#5

You’re catching the exception, you need to print it out yourself.

0 Likes

#6

Whoops. My bad. It’s a NullPointerException:

INFO   | jvm 1    | 2019/08/06 10:22:11 | I [t.d.c.GatewayHook             ] [14:22:11]: java.lang.NullPointerException module-name=TagDBV8 Ignition Module
INFO   | jvm 1    | 2019/08/06 10:22:11 | I [t.d.c.GatewayHook             ] [14:22:11]: null module-name=TagDBV8 Ignition Module
INFO   | jvm 1    | 2019/08/06 10:22:11 | I [t.d.c.GatewayHook             ] [14:22:11]: nodenames is: null module-name=TagDBV8 Ignition Module
INFO   | jvm 1    | 2019/08/06 10:22:11 | I [t.d.c.GatewayHook             ] [14:22:11]: nodeResult is: null module-name=TagDBV8 Ignition Module
INFO   | jvm 1    | 2019/08/06 10:22:11 | I [t.d.c.GatewayHook             ] [14:22:11]: nodeCollection is: null module-name=TagDBV8 Ignition Module
0 Likes

#7

Is this returning null?

0 Likes

#8

It seems so:

}catch(Exception e){
    logger.info(e);
    logger.info(context.getTagManager().getTagProvider("default"));
}

faults the module and returns:

INFO   | jvm 1    | 2019/08/06 10:34:13 | java.lang.NullPointerException: null
INFO   | jvm 1    | 2019/08/06 10:34:13 | 	at tag.database.connection.GatewayHook.startup(GatewayHook.java:68)
INFO   | jvm 1    | 2019/08/06 10:34:13 | 	at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl$LoadedModule.startup(ModuleManagerImpl.java:2349)
INFO   | jvm 1    | 2019/08/06 10:34:13 | 	at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl.startupModule(ModuleManagerImpl.java:1166)
INFO   | jvm 1    | 2019/08/06 10:34:13 | 	at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl$2.call(ModuleManagerImpl.java:733)
INFO   | jvm 1    | 2019/08/06 10:34:13 | 	at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl.executeModuleOperation(ModuleManagerImpl.java:905)
INFO   | jvm 1    | 2019/08/06 10:34:13 | 	at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl.installModuleInternal(ModuleManagerImpl.java:695)
INFO   | jvm 1    | 2019/08/06 10:34:13 | 	at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl$InstallCommand.execute(ModuleManagerImpl.java:1851)
INFO   | jvm 1    | 2019/08/06 10:34:13 | 	at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl$Receiver.receiveCall(ModuleManagerImpl.java:1801)
INFO   | jvm 1    | 2019/08/06 10:34:13 | 	at com.inductiveautomation.ignition.gateway.redundancy.QueueableMessageReceiver.receiveCall(QueueableMessageReceiver.java:47)
INFO   | jvm 1    | 2019/08/06 10:34:13 | 	at com.inductiveautomation.ignition.gateway.redundancy.RedundancyManagerImpl.dispatchMessage(RedundancyManagerImpl.java:813)
INFO   | jvm 1    | 2019/08/06 10:34:13 | 	at com.inductiveautomation.ignition.gateway.redundancy.RedundancyManagerImpl$ExecuteTask.run(RedundancyManagerImpl.java:849)
INFO   | jvm 1    | 2019/08/06 10:34:13 | 	at com.inductiveautomation.ignition.common.execution.impl.BasicExecutionEngine$ThrowableCatchingRunnable.run(BasicExecutionEngine.java:518)
INFO   | jvm 1    | 2019/08/06 10:34:13 | 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
INFO   | jvm 1    | 2019/08/06 10:34:13 | 	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
INFO   | jvm 1    | 2019/08/06 10:34:13 | 	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
INFO   | jvm 1    | 2019/08/06 10:34:13 | 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
INFO   | jvm 1    | 2019/08/06 10:34:13 | 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
INFO   | jvm 1    | 2019/08/06 10:34:13 | 	at java.base/java.lang.Thread.run(Unknown Source)
0 Likes

#9

I made some changes to my GatewayContext and now

logger.info(context.getTagManager().getTagProvider("default"));

returns

com.inductiveautomation.ignition.gateway.tags.TagProviderImpl@4722edc2
0 Likes

#10

It seems now the only object returning null is my BrowseFilter (bfilter). Are there any examples that show how to correctly configure a BrowseFilter?

0 Likes