# OPC import from script

**URL:** <https://forum.inductiveautomation.com/t/opc-import-from-script/12397>\
**Category:** Ignition\
**Created:** [November 23, 2016, 5:21pm UTC](https://forum.inductiveautomation.com/t/opc-import-from-script/12397 "2016-11-23T17:21:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![marioquark](https://avatars.discourse-cdn.com/v4/letter/m/22d042/32.png) [@marioquark](https://forum.inductiveautomation.com/u/marioquark)\
**Post date:** [November 23, 2016, 5:21pm UTC](https://forum.inductiveautomation.com/t/opc-import-from-script/12397/1 "2016-11-23T17:21:52Z")

</div>

I’m trying to import tags from Kepware at runtime, using a script.  
I configured a OPC-UA server, it is connected and works perfectly.  
Anyway this code taken from manual doesn’t work.

[code]#Browse Ignition’s OPC-UA Server. This can be changed to match any connected OPC server.  
server = “VendorOPCServer”

#Focus on the “SLC” device connection. This must match a valid device connection in the OPC server.  
device = “Line”

#Specify that the folder path should contain “B3”.  
folderPath = “\*”

#This example is not filtering on a specific OPCItemPath, so it pass Python’s None for this parameter  
opcItemPath = None

#Call browseSimple and store the results in a variable. Note that it may take some time to complete the browse.  
OpcObjects = system.opc.browseSimple(server, device, folderPath, opcItemPath)

#For each returned address, print out the  
for address in OpcObjects:  
print address.getOpcItemPath()[/code]  
It gives me an exception:

[code]Java Traceback:  
at org.python.core.Py.JavaError(Py.java:495)  
at org.python.core.Py.JavaError(Py.java:488)  
at org.python.core.PyReflectedFunction. **call** (PyReflectedFunction.java:188)  
at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction. **call** (ScriptManager.java:430)  
at org.python.core.PyObject. **call** (PyObject.java:441)  
at org.python.core.PyObject. **call** (PyObject.java:447)  
at org.python.pycode.\_pyx587.f$0(:17)  
at org.python.pycode.\_pyx587.call\_function()  
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 org.python.core.Py.exec(Py.java:1319)  
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:215)  
at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java:89)  
at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:70)  
at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$InterpreterWorker.doInBackground(JythonConsole.java:419)  
at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$InterpreterWorker.doInBackground(JythonConsole.java:407)  
at javax.swing.SwingWorker$1.call(Unknown Source)  
at java.util.concurrent.FutureTask.run(Unknown Source)  
at javax.swing.SwingWorker.run(Unknown Source)  
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)  
at java.lang.Thread.run(Unknown Source)  
Caused by: com.inductiveautomation.ignition.client.gateway\_interface.GatewayException: java.lang.NullPointerException  
at com.inductiveautomation.ignition.client.gateway\_interface.GatewayInterface.newGatewayException(GatewayInterface.java:329)  
at com.inductiveautomation.ignition.client.gateway\_interface.GatewayInterface.sendMessage(GatewayInterface.java:303)  
at com.inductiveautomation.ignition.client.gateway\_interface.GatewayInterface.sendMessage(GatewayInterface.java:260)  
at com.inductiveautomation.ignition.client.gateway\_interface.GatewayInterface.moduleInvokeSafe(GatewayInterface.java:842)  
at com.ialabs.scripting.functions.OPCFunctionsImpl.browseSimple(OPCFunctionsImpl.java:29)  
at sun.reflect.GeneratedMethodAccessor1091.invoke(Unknown Source)  
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)  
at java.lang.reflect.Method.invoke(Unknown Source)  
at org.python.core.PyReflectedFunction. **call** (PyReflectedFunction.java:186)  
… 20 more  
Caused by: java.util.concurrent.ExecutionException: java.lang.NullPointerException  
at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)  
at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895)  
at com.inductiveautomation.xopc2.client.OpcUaConnection.browse(OpcUaConnection.java:587)  
at com.inductiveautomation.ignition.gateway.opc.OPCManagerImpl$ServerWrapper.browse(OPCManagerImpl.java:781)  
at com.inductiveautomation.ignition.gateway.opc.OPCManagerImpl.browse(OPCManagerImpl.java:445)  
at com.ialabs.scripting.functions.OPCFunctionsImpl.\_browse(OPCFunctionsImpl.java:55)  
at com.ialabs.scripting.functions.OPCFunctionsImpl.\_browse(OPCFunctionsImpl.java:94)  
at com.ialabs.scripting.functions.OPCFunctionsImpl.\_browse(OPCFunctionsImpl.java:94)  
at com.ialabs.scripting.functions.OPCFunctionsImpl.\_browse(OPCFunctionsImpl.java:94)  
at com.ialabs.scripting.functions.OPCFunctionsImpl.\_browse(OPCFunctionsImpl.java:94)  
at com.ialabs.scripting.functions.OPCFunctionsImpl.browseSimple(OPCFunctionsImpl.java:47)  
at com.ialabs.scripting.RPCHandler.browseSimple(RPCHandler.java:138)  
at sun.reflect.GeneratedMethodAccessor39.invoke(null)  
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  
at java.lang.reflect.Method.invoke(Method.java:498)  
at com.inductiveautomation.ignition.gateway.servlets.gateway.functions.ModuleInvoke.invoke(ModuleInvoke.java:123)  
at com.inductiveautomation.ignition.gateway.servlets.Gateway.doPost(Gateway.java:390)  
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)  
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)  
at com.inductiveautomation.ignition.gateway.bootstrap.MapServlet.service(MapServlet.java:85)  
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:837)  
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583)  
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)  
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)  
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)  
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1160)  
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)  
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)  
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1092)  
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)  
at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)  
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)  
at org.eclipse.jetty.server.Server.handle(Server.java:518)  
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:308)  
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:244)  
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273)  
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)  
at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)  
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:246)  
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:156)  
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)  
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)  
at java.lang.Thread.run(Thread.java:745)  
Traceback (most recent call last):  
File “”, line 14, in   
at com.inductiveautomation.ignition.client.gateway\_interface.GatewayInterface.newGatewayException(GatewayInterface.java:329)  
at com.inductiveautomation.ignition.client.gateway\_interface.GatewayInterface.sendMessage(GatewayInterface.java:303)  
at com.inductiveautomation.ignition.client.gateway\_interface.GatewayInterface.sendMessage(GatewayInterface.java:260)  
at com.inductiveautomation.ignition.client.gateway\_interface.GatewayInterface.moduleInvokeSafe(GatewayInterface.java:842)  
at com.ialabs.scripting.functions.OPCFunctionsImpl.browseSimple(OPCFunctionsImpl.java:29)  
at sun.reflect.GeneratedMethodAccessor1091.invoke(Unknown Source)  
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)  
at java.lang.reflect.Method.invoke(Unknown Source)

com.inductiveautomation.ignition.client.gateway\_interface.GatewayException: com.inductiveautomation.ignition.client.gateway\_interface.GatewayException: java.lang.NullPointerException[/code]

Any idea?  
Thank you!

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [November 23, 2016, 6:35pm UTC](https://forum.inductiveautomation.com/t/opc-import-from-script/12397/2 "2016-11-23T18:35:50Z")

</div>

Double check your server and device name. I just tried it in 7.9.1 and the code worked as expected.

---

<div class="post-metadata">

**Author:** ![marioquark](https://avatars.discourse-cdn.com/v4/letter/m/22d042/32.png) [@marioquark](https://forum.inductiveautomation.com/u/marioquark)\
**Post date:** [November 25, 2016, 8:32am UTC](https://forum.inductiveautomation.com/t/opc-import-from-script/12397/3 "2016-11-25T08:32:11Z")

</div>

I’m using 7.9.0 (b2016101208)  
Our product provider’s tech support says they’re experiencing the same problem. ![:scratch:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/76d1620bec252bfac07050c889ff5a91dc8a9c25.gif ":scratch:")

Anyway I’m focusing on system.opc.browseSimple() because it’s the only function to extract the OPC tag type, since the system.opc.browseServer() can’t. Is there another way to get the type?
