# Is there a way to read tags inside a component?

**URL:** <https://forum.inductiveautomation.com/t/is-there-a-way-to-read-tags-inside-a-component/10392>\
**Category:** Module Development\
**Created:** [August 25, 2015, 5:31pm UTC](https://forum.inductiveautomation.com/t/is-there-a-way-to-read-tags-inside-a-component/10392 "2015-08-25T17:31:38Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![tmv090020](https://avatars.discourse-cdn.com/v4/letter/t/54ee81/32.png) [@tmv090020](https://forum.inductiveautomation.com/u/tmv090020)\
**Post date:** [August 25, 2015, 5:31pm UTC](https://forum.inductiveautomation.com/t/is-there-a-way-to-read-tags-inside-a-component/10392/1 "2015-08-25T17:31:38Z")

</div>

I am looking for a way to read a tag’s value form inside a AbstractVisionPanel.

I have tried using “getAppContext().getTagManager().getTag()” but I am not sure if this is the right way ❓ . If it is, could you leave an example of getTag? I would greatly appreciation it 😃

---

<div class="post-metadata">

**Author:** ![Colby.Clegg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/colby.clegg/32/3282_2.png) [@Colby.Clegg](https://forum.inductiveautomation.com/u/Colby.Clegg)\
**Post date:** [November 6, 2015, 12:34am UTC](https://forum.inductiveautomation.com/t/is-there-a-way-to-read-tags-inside-a-component/10392/2 "2015-11-06T00:34:11Z")

</div>

Hi,

Yes, I think you’re close, I’d just use the read() function on the tag manager. It takes a list of tag paths, so if you don’t have those, you can use TagPathParser#parse to build them. In the client, a blank source means “project default”, so you could do something like:

```auto
QualifiedValue value = getAppContext().getTagManager().read(Arrays.asList(TagPathParser.parse("", "my/tag"))).get(0)
```

I highly doubt you’d have a tag path hard coded in your component, but that would read it.

Regards,

---

<div class="post-metadata">

**Author:** ![salbrechtsen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/salbrechtsen/32/18660_2.png) [@salbrechtsen](https://forum.inductiveautomation.com/u/salbrechtsen)\
**Post date:** [April 9, 2018, 4:14pm UTC](https://forum.inductiveautomation.com/t/is-there-a-way-to-read-tags-inside-a-component/10392/3 "2018-04-09T16:14:30Z")

</div>

I have copied your line of code, but my IDE and Maven keep showing `java.io.IOException; must be caught or declared to be thrown`. On the `TagPathParser.parse` call Not sure what I could be missing.

I am trying to call this in an AbstractVisionComponent.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 9, 2018, 5:41pm UTC](https://forum.inductiveautomation.com/t/is-there-a-way-to-read-tags-inside-a-component/10392/4 "2018-04-09T17:41:04Z")

</div>

> [@salbrechtsen](#):
>
> must be caught or declared to be thrown

That's your IDE enforcing java's exception handling. Add a `throws` clause to your containing method or catch the parse errors within the method.

---

<div class="post-metadata">

**Author:** ![salbrechtsen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/salbrechtsen/32/18660_2.png) [@salbrechtsen](https://forum.inductiveautomation.com/u/salbrechtsen)\
**Post date:** [April 9, 2018, 7:00pm UTC](https://forum.inductiveautomation.com/t/is-there-a-way-to-read-tags-inside-a-component/10392/5 "2018-04-09T19:00:10Z")

</div>

I neglected to mention I did do that yesterday, and now it will build a .modl but I’m getting a stack trace now with the error `Unable to locate function 'SQLTags.read' ...` Here is some of the trace:

```auto
Exception in thread "AWT-EventQueue-2" java.lang.RuntimeException: com.inductiveautomation.ignition.client.gateway_interface.GatewayException: Unable to locate function 'SQLTags.read'
	at com.inductiveautomation.ignition.client.sqltags.impl.db.DatasourceTagManager.read(DatasourceTagManager.java:436)
	at com.inductiveautomation.ignition.client.sqltags.impl.ClientTagManagerImpl.read(ClientTagManagerImpl.java:192)

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 9, 2018, 7:04pm UTC](https://forum.inductiveautomation.com/t/is-there-a-way-to-read-tags-inside-a-component/10392/6 "2018-04-09T19:04:57Z")

</div>

That isn’t enough context. Please show the whole error and the code of the method where it occurs.

---

<div class="post-metadata">

**Author:** ![salbrechtsen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/salbrechtsen/32/18660_2.png) [@salbrechtsen](https://forum.inductiveautomation.com/u/salbrechtsen)\
**Post date:** [April 9, 2018, 7:18pm UTC](https://forum.inductiveautomation.com/t/is-there-a-way-to-read-tags-inside-a-component/10392/7 "2018-04-09T19:18:47Z")

</div>

```auto
Exception in thread "AWT-EventQueue-2" java.lang.RuntimeException: com.inductiveautomation.ignition.client.gateway_interface.GatewayException: Unable to locate function 'SQLTags.read'
	at com.inductiveautomation.ignition.client.sqltags.impl.db.DatasourceTagManager.read(DatasourceTagManager.java:436)
	at com.inductiveautomation.ignition.client.sqltags.impl.ClientTagManagerImpl.read(ClientTagManagerImpl.java:192)
	at com.inductiveautomation.ignition.examples.ce.components.StandardTank.drawTag(StandardTank.java:103)
	at com.inductiveautomation.ignition.examples.ce.components.StandardTank.paintComponent(StandardTank.java:91)
	at javax.swing.JComponent.paint(Unknown Source)
	at javax.swing.JComponent.paintChildren(Unknown Source)
	at com.inductiveautomation.vision.api.client.components.model.AbstractVisionPanel.paintChildren(AbstractVisionPanel.java:279)
	at javax.swing.JComponent.paint(Unknown Source)
	at javax.swing.JComponent.paintChildren(Unknown Source)
	at com.inductiveautomation.vision.api.client.components.model.AbstractVisionPanel.paintChildren(AbstractVisionPanel.java:279)
	at javax.swing.JComponent.paint(Unknown Source)
	at javax.swing.JComponent.paintChildren(Unknown Source)
	at com.inductiveautomation.vision.api.client.components.model.AbstractVisionPanel.paintChildren(AbstractVisionPanel.java:279)
	at javax.swing.JComponent.paint(Unknown Source)
	at javax.swing.JComponent.paintChildren(Unknown Source)
	at com.inductiveautomation.vision.api.client.components.model.AbstractVisionPanel.paintChildren(AbstractVisionPanel.java:279)
	at javax.swing.JComponent.paint(Unknown Source)
	at javax.swing.JComponent.paintChildren(Unknown Source)
	at com.inductiveautomation.vision.api.client.components.model.AbstractVisionPanel.paintChildren(AbstractVisionPanel.java:279)
	at javax.swing.JComponent.paint(Unknown Source)
	at javax.swing.JComponent.paintChildren(Unknown Source)
	at com.inductiveautomation.vision.api.client.components.model.AbstractVisionPanel.paintChildren(AbstractVisionPanel.java:279)
	at javax.swing.JComponent.paint(Unknown Source)
	at javax.swing.JComponent.paintChildren(Unknown Source)
	at javax.swing.JComponent.paint(Unknown Source)
	at javax.swing.JLayeredPane.paint(Unknown Source)
	at javax.swing.JComponent.paintChildren(Unknown Source)
	at javax.swing.JComponent.paint(Unknown Source)
	at javax.swing.JComponent.paintChildren(Unknown Source)
	at javax.swing.JComponent.paint(Unknown Source)
	at javax.swing.JComponent.paintChildren(Unknown Source)
	at javax.swing.JComponent.paint(Unknown Source)
	at javax.swing.JLayeredPane.paint(Unknown Source)
	at javax.swing.JComponent.paintToOffscreen(Unknown Source)
	at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source)
	at javax.swing.RepaintManager$PaintManager.paint(Unknown Source)
	at javax.swing.RepaintManager.paint(Unknown Source)
	at javax.swing.JComponent._paintImmediately(Unknown Source)
	at javax.swing.JComponent.paintImmediately(Unknown Source)
	at javax.swing.RepaintManager$4.run(Unknown Source)
	at javax.swing.RepaintManager$4.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
	at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
	at javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source)
	at javax.swing.RepaintManager.access$1200(Unknown Source)
	at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source)
	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.awt.EventQueue.access$500(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: com.inductiveautomation.ignition.client.gateway_interface.GatewayException: Unable to locate function 'SQLTags.read'
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.newGatewayException(GatewayInterface.java:341)
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.sendMessage(GatewayInterface.java:315)
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.sendMessage(GatewayInterface.java:268)
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.invoke(GatewayInterface.java:894)
	at com.inductiveautomation.ignition.client.sqltags.impl.db.DatasourceTagManager.read(DatasourceTagManager.java:434)
	... 61 more
Exception in thread "AWT-EventQueue-2" java.lang.RuntimeException: com.inductiveautomation.ignition.client.gateway_interface.GatewayException: Unable to locate function 'SQLTags.read'
	at com.inductiveautomation.ignition.client.sqltags.impl.db.DatasourceTagManager.read(DatasourceTagManager.java:436)
	at com.inductiveautomation.ignition.client.sqltags.impl.ClientTagManagerImpl.read(ClientTagManagerImpl.java:192)
	at com.inductiveautomation.ignition.examples.ce.components.StandardTank.drawTag(StandardTank.java:103)
	at com.inductiveautomation.ignition.examples.ce.components.StandardTank.paintComponent(StandardTank.java:91)
	at javax.swing.JComponent.paint(Unknown Source)
	at javax.swing.JComponent.paintChildren(Unknown Source)
	at com.inductiveautomation.vision.api.client.components.model.AbstractVisionPanel.paintChildren(AbstractVisionPanel.java:279)
	at javax.swing.JComponent.paint(Unknown Source)
	at javax.swing.JComponent.paintChildren(Unknown Source)
	at com.inductiveautomation.vision.api.client.components.model.AbstractVisionPanel.paintChildren(AbstractVisionPanel.java:279)
	at javax.swing.JComponent.paint(Unknown Source)
	at javax.swing.JComponent.paintChildren(Unknown Source)
	at com.inductiveautomation.vision.api.client.components.model.AbstractVisionPanel.paintChildren(AbstractVisionPanel.java:279)
	at javax.swing.JComponent.paint(Unknown Source)
	at javax.swing.JComponent.paintChildren(Unknown Source)
	at com.inductiveautomation.vision.api.client.components.model.AbstractVisionPanel.paintChildren(AbstractVisionPanel.java:279)
	at javax.swing.JComponent.paint(Unknown Source)
	at javax.swing.JComponent.paintChildren(Unknown Source)
	at com.inductiveautomation.vision.api.client.components.model.AbstractVisionPanel.paintChildren(AbstractVisionPanel.java:279)
	at javax.swing.JComponent.paint(Unknown Source)
	at javax.swing.JComponent.paintChildren(Unknown Source)
	at com.inductiveautomation.vision.api.client.components.model.AbstractVisionPanel.paintChildren(AbstractVisionPanel.java:279)
	at javax.swing.JComponent.paint(Unknown Source)
	at javax.swing.JComponent.paintToOffscreen(Unknown Source)
	at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source)
	at javax.swing.RepaintManager$PaintManager.paint(Unknown Source)
	at javax.swing.RepaintManager.paint(Unknown Source)
	at javax.swing.JComponent._paintImmediately(Unknown Source)
	at javax.swing.JComponent.paintImmediately(Unknown Source)
	at javax.swing.RepaintManager$4.run(Unknown Source)
	at javax.swing.RepaintManager$4.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
	at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
	at javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source)
	at javax.swing.RepaintManager.access$1200(Unknown Source)
	at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source)
	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.awt.EventQueue.access$500(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: com.inductiveautomation.ignition.client.gateway_interface.GatewayException: Unable to locate function 'SQLTags.read'
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.newGatewayException(GatewayInterface.java:341)
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.sendMessage(GatewayInterface.java:315)
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.sendMessage(GatewayInterface.java:268)
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.invoke(GatewayInterface.java:894)
	at com.inductiveautomation.ignition.client.sqltags.impl.db.DatasourceTagManager.read(DatasourceTagManager.java:434)
	... 51 more

```

This is the whole trace. The offending line is a copy/paste of Colby’s code.

I found this thread: [Client module with sql tag read?](http://forum.inductiveautomation.com/t/client-module-with-sql-tag-read/12699)

And was able to get it to work by using

`Tag tag = getAppContext().getTagManager().getTag(TagPathParser.parse("", tagPath));`

So seems like it is a bug on Ignitions end that has been known about since Feb '17 but not fixed yet.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 9, 2018, 7:34pm UTC](https://forum.inductiveautomation.com/t/is-there-a-way-to-read-tags-inside-a-component/10392/8 "2018-04-09T19:34:39Z")

</div>

Oops, yep, doesn’t look like we ever fixed that.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 9, 2018, 7:36pm UTC](https://forum.inductiveautomation.com/t/is-there-a-way-to-read-tags-inside-a-component/10392/9 "2018-04-09T19:36:04Z")

</div>

Sounds like a bug that is extremely low priority because it can only be triggered by a module developer, and has a work-around.

Side note: you’re trying to do this inside of a paint() operation? That’s just crazy, as a a visual update should never have to wait for a gateway message/reply. Ideally, painting should never have to involve anything outside the component. You’re begging to have random freezes in your UI.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 9, 2018, 7:41pm UTC](https://forum.inductiveautomation.com/t/is-there-a-way-to-read-tags-inside-a-component/10392/10 "2018-04-09T19:41:29Z")

</div>

> [@pturmel](#):
>
> Sounds like a bug that is extremely low priority because it can only be triggered by a module developer, and has a work-around.

So low priority it seems we never made a ticket for it...

I just fixed it though... due in ??? for 7.9.??? 😵

---

<div class="post-metadata">

**Author:** ![salbrechtsen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/salbrechtsen/32/18660_2.png) [@salbrechtsen](https://forum.inductiveautomation.com/u/salbrechtsen)\
**Post date:** [April 9, 2018, 8:24pm UTC](https://forum.inductiveautomation.com/t/is-there-a-way-to-read-tags-inside-a-component/10392/11 "2018-04-09T20:24:31Z")

</div>

No worries Kevin 🙂 Thanks for replying.

---

<div class="post-metadata">

**Author:** ![salbrechtsen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/salbrechtsen/32/18660_2.png) [@salbrechtsen](https://forum.inductiveautomation.com/u/salbrechtsen)\
**Post date:** [April 9, 2018, 8:28pm UTC](https://forum.inductiveautomation.com/t/is-there-a-way-to-read-tags-inside-a-component/10392/12 "2018-04-09T20:28:08Z")

</div>

Right, fully aware of this. Just getting my feet wet with the SDK and wanted to just read a single tag and display it.

Now that I got the tag read working, I have moved this functionality to a tag subscription that updates the value displayed in the component as the new tag value comes in.
