# Cannot coerce value into type: inteface java.util.map

**URL:** <https://forum.inductiveautomation.com/t/cannot-coerce-value-into-type-inteface-java-util-map/110612>\
**Category:** Ignition\
**Tags:** perspective, database, scripting\
**Created:** [September 14, 2025, 7:30pm UTC](https://forum.inductiveautomation.com/t/cannot-coerce-value-into-type-inteface-java-util-map/110612 "2025-09-14T19:30:14Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 14, 2025, 7:30pm UTC](https://forum.inductiveautomation.com/t/cannot-coerce-value-into-type-inteface-java-util-map/110612/1 "2025-09-14T19:30:14Z")

</div>

I'm passing parameters into a named query. I'm getting this error on the gateway logs.

> **Gateway log extract (with line breaks for ease of reading)**
>
> ```python
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (Unknown Source) at java.base/java.lang.reflect.Method.invoke (Unknown Source) java.lang.ClassCastException:
> jJava.lang.ClassCastException:
> Cannot coerce value '[{
> 'Panel_type': u'ROBOT',
> 'Description': u'',
> 'Switch_name': u'ABCDEFG',
> 'Panel_id': u' ',
> 'Asset_type': u'General IoT abc',
> 'VLAN': u'210',
> 'Edited_by': u'bloggs_joe',
> 'Device_type': u' ',
> 'Edit_date’: Sun Sep 14 19:17:18 BST 2025,
> 'Manufacturer': u'Myopic',
> 'Asset_name': u'\\J45',
> 'MAC address’: u'00:01:02:E7:D6:FA',
> 'Notes': u'Notes test. ',
> 'Drawing_number': u'DWG-1039',
> 'Floor': u'20.5m',
> 'Patch_port': u'85',
> 'Port_num': u'Gi1/2/34',
> 'Panel_drawing_ref': u'',
> 'Serial_number': u'N/A',
> 'Equipment_type': u'Case maker',
> 'Process_type': u'Forming',
> 'Model': u'Superior 11',
> 'Id': 20,
> 'IP_integer': OL,
> 'IP_integer_legacy': OL,
> 'Location’: u'East Fab'
> }]' 
> into type: interface java.util.Map
> 
> ```

(I've edited any sensitive text strings. There are three integer columns in the database: Id, IP\_integer and IP\_integer\_legacy.)

Can anyone spot a blunder?  
Thanks!

---

<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:** [September 14, 2025, 7:44pm UTC](https://forum.inductiveautomation.com/t/cannot-coerce-value-into-type-inteface-java-util-map/110612/2 "2025-09-14T19:44:36Z")

</div>

Looks like you've passed a list containing a dictionary and not a dictionary.

---

<div class="post-metadata">

**Author:** ![David\_Stone](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/david_stone/32/79749_2.png) [@David\_Stone](https://forum.inductiveautomation.com/u/David_Stone)\
**Post date:** [September 14, 2025, 7:44pm UTC](https://forum.inductiveautomation.com/t/cannot-coerce-value-into-type-inteface-java-util-map/110612/3 "2025-09-14T19:44:52Z")

</div>

There’s a lot of mismatched backticks, single quotes and double quotes, if you clean them up does it still error?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 14, 2025, 7:49pm UTC](https://forum.inductiveautomation.com/t/cannot-coerce-value-into-type-inteface-java-util-map/110612/4 "2025-09-14T19:49:37Z")

</div>

> [@Kevin.Herron](#):
>
> Looks like you've passed a list ...

I noticed that too, but the code is,

```python
parameters = {'Id': ..... }
system.db.runNamedQuery(project, query, parameters)

```

I'm definitely passing a dictionary - or trying!

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 14, 2025, 7:52pm UTC](https://forum.inductiveautomation.com/t/cannot-coerce-value-into-type-inteface-java-util-map/110612/5 "2025-09-14T19:52:35Z")

</div>

> [@David\_Stone](#):
>
> There’s a lot of mismatched backticks

Oops. I'm working through a jump server onto a machine with no Internet connection and no clipboard cut'n'paste. I used OCR to convert a screengrab for my post. It has randomised the types of backticks and I didn't notice. In the error message there are only standard apostrophes. I'll fix up my original post.  
Thanks for the eyes!

Cleanup done. 🧹

---

<div class="post-metadata">

**Author:** ![David\_Stone](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/david_stone/32/79749_2.png) [@David\_Stone](https://forum.inductiveautomation.com/u/David_Stone)\
**Post date:** [September 14, 2025, 8:05pm UTC](https://forum.inductiveautomation.com/t/cannot-coerce-value-into-type-inteface-java-util-map/110612/6 "2025-09-14T20:05:08Z")

</div>

There’s a random Pipe character just before patch port.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 14, 2025, 8:11pm UTC](https://forum.inductiveautomation.com/t/cannot-coerce-value-into-type-inteface-java-util-map/110612/7 "2025-09-14T20:11:39Z")

</div>

> [@David\_Stone](#):
>
> Pipe character

Another missed OCR artifact. Fixed, thanks.

---

<div class="post-metadata">

**Author:** ![David\_Stone](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/david_stone/32/79749_2.png) [@David\_Stone](https://forum.inductiveautomation.com/u/David_Stone)\
**Post date:** [September 14, 2025, 8:39pm UTC](https://forum.inductiveautomation.com/t/cannot-coerce-value-into-type-inteface-java-util-map/110612/8 "2025-09-14T20:39:47Z")

</div>

Is it normal for the timestamp to not be a n escaped string in the readback?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 14, 2025, 8:45pm UTC](https://forum.inductiveautomation.com/t/cannot-coerce-value-into-type-inteface-java-util-map/110612/9 "2025-09-14T20:45:04Z")

</div>

I had wondered about the date format. (What's an "n escaped string"?) The date parameter is generated by

```python
parameters = {..., "Edit_date": system.date.now(), ...}

```

and the error message returns,  
`'Edit_date’: Sun Sep 14 19:17:18 BST 2025`

---

<div class="post-metadata">

**Author:** ![David\_Stone](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/david_stone/32/79749_2.png) [@David\_Stone](https://forum.inductiveautomation.com/u/David_Stone)\
**Post date:** [September 14, 2025, 8:48pm UTC](https://forum.inductiveautomation.com/t/cannot-coerce-value-into-type-inteface-java-util-map/110612/10 "2025-09-14T20:48:57Z")

</div>

I think that is correct as long as the parameter in the named query is expecting a timestamp not a string. When errors print to logs they assert .toString() from memory.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 14, 2025, 9:14pm UTC](https://forum.inductiveautomation.com/t/cannot-coerce-value-into-type-inteface-java-util-map/110612/11 "2025-09-14T21:14:44Z")

</div>

Hmm!  
The named query (Query type: Update query) is expecting `Edit_date / DateTime` parameter.  
The MS SQL database column is `datetime2` which should handle it.

---

<div class="post-metadata">

**Author:** ![David\_Stone](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/david_stone/32/79749_2.png) [@David\_Stone](https://forum.inductiveautomation.com/u/David_Stone)\
**Post date:** [September 14, 2025, 10:55pm UTC](https://forum.inductiveautomation.com/t/cannot-coerce-value-into-type-inteface-java-util-map/110612/12 "2025-09-14T22:55:28Z")

</div>

```python
parameters = {
	"Panel_type": u'ROBOT',
	'Description': u'',
	'Switch_name': u'ABCDEFG',
	'Panel_id': u' ',
	'Asset_type': u'General IoT abc',
	'VLAN': u'210',
	'Edited_by': u'bloggs_joe',
	'Device_type': u' ',
	'Edit_date': system.date.now(),
	'Manufacturer': u'Myopic',
	'Asset_name': u'\\J45',
	'MAC address': u'00:01:02:E7:D6:FA',
	'Notes': u'Notes test. ',
	'Drawing_number': u'DWG-1039',
	'Floor': u'20.5m',
	'Patch_port': u'85',
	'Port_num': u'Gi1/2/34',
	'Panel_drawing_ref': u'',
	'Serial_number': u'N/A',
	'Equipment_type': u'Case maker',
	'Process_type': u'Forming',
	'Model': u'Superior 11',
	'Id': 20,
	'IP_integer': 0L,
	'IP_integer_legacy': 0L,
	'Location': u'East Fab'
}
results = system.db.runNamedQuery("test",parameters=parameters)

```

I can run that code above with no errors in my docker test gateway.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 14, 2025, 11:03pm UTC](https://forum.inductiveautomation.com/t/cannot-coerce-value-into-type-inteface-java-util-map/110612/13 "2025-09-14T23:03:40Z")

</div>

I think I found the problem. I've fallen victim to the project name syntax trap.  
`results = system.db.runNamedQuery("PROJECTNAME", "test",parameters=parameters)`  
Phil has commented on this in several posts and pointed out that it is odd in that the projected name should be _after_ the named query and parameters rather than first in the list.

I was using the gateway scope syntax. I've removed the project name from the function and it seems to work. It's midnight here. Time for sleep. I'll continue debugging tomorrow.

Thank you very much for taking the time to try it out.

---

<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:** [September 14, 2025, 11:22pm UTC](https://forum.inductiveautomation.com/t/cannot-coerce-value-into-type-inteface-java-util-map/110612/14 "2025-09-14T23:22:08Z")

</div>

> [@Transistor](#):
>
> pointed out that it is odd

It is fixed in the replacement `system.db.exec*()` functions in v8.3.
