ClassCastException: Cannot coerce value 'java.lang.Object@

Greetings, I hope this info keeps someone from pulling their hair out. Too late for me…

Most have seen the 'Cannot coerce value" error, and it’s usually the result of something we’ve done. I’m not sure this falls into that category. I have a bunch of windows that are very similar… same components, same templates, etc. After creating the latest ‘clone’ the following error popped up on a few templates… actually, 22 errors on 3 distinct templates. And these templates are being used on dozens of other screens without error. These errors would only happen a single time when opening the screen, in both the designer and client. After the initial opening, no more errors and the screen performed as expected.

java.lang.ClassCastException: Cannot coerce value 'java.lang.Object@7840452c' into type: class java.lang.Boolean
	at com.inductiveautomation.ignition.common.TypeUtilities.coerce(
	at com.inductiveautomation.factorypmi.application.binding.DynamicPropertyDescriptor.setValue(
	at com.inductiveautomation.factorypmi.application.binding.util.DynamicPropertyUtil.setPropertyValue(
	at com.inductiveautomation.factorypmi.application.components.template.TemplateHolder.startupTemplate(
	at com.inductiveautomation.factorypmi.application.components.template.TemplateHolder.onStartup(
	at com.inductiveautomation.factorypmi.application.components.util.ComponentVisitor$StartupVisitor.visit(
	at com.inductiveautomation.factorypmi.application.components.util.ComponentVisitor.walk(
	at com.inductiveautomation.factorypmi.application.components.util.ComponentVisitor.walk(
	at com.inductiveautomation.factorypmi.application.FPMIWindow.startup(
	at com.inductiveautomation.factorypmi.designer.workspace.WindowWorkspace$DesigntimeWindowOpener.openWindow(
	at com.inductiveautomation.factorypmi.designer.workspace.WindowWorkspace.openWindow(
	at com.inductiveautomation.factorypmi.designer.model.navtree.WindowNode.onDoubleClick(
	at com.inductiveautomation.ignition.designer.navtree.NavTreePanel$MouseListener$
	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$ Source)
	at java.awt.EventQueue$ Source)
	at Method)
	at$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 Source)

Ignition v7.9.7 (b2018032914)
Java: Oracle Corporation 1.8.0_171

I searched the forum, but nothing was popping up that was similar to “java.lang.Object@”. So I toiled for quite a while trying to find a cause… without success. Ugh…

Finally, I duplicated the screen, deleted the old, and renamed the duplicated screen to the old deleted screen. Now when opening the new screen, the errors went from 22 to 9. (?) Now, only two templates were throwing an error, but further duplication did not resolve the lingering issues. I ultimately had to go to a screen with the same templates, copy/paste them, copy the bindings to them, then delete the ‘bad’ templates. This completely resolved the issue. Funny thing is… these templates were originally copied/pasted from other screens to make the ‘bad’ one.

Perhaps someone can decipher the error message to target the cause, but, I’m not that someone.

As you were…

Ignition 7.9.7
Java 1.8.0_171-b11

I can’t definitively answer, but it has something to do with the value being assigned to a boolean custom property within your template, and the initial value saved in the window was a non-null, non-boolean.

Yeah, I think I got that part figured out, but sure could not find a cause. I would have thought that subsequently saved edits of the screen would have fixed any issue with a non-boolean value. Perhaps I do not understand what you mean by “the initial value saved in the window”. All templates in question were bound to working and connected UDT tags.

I appreciate your insight.

The same thing happened to me today on the window with many templates. When I first open the window I get over 500 errors…

Duplicating the window doesn’t help.
The only way to get reed of this errors is to manually edit every property tag binding on every template instance on that screen…:roll_eyes:

It might be interesting to diff the xml of the broken window versus the xml of the good window.

Here are two .zip files with .xml: (96.2 KB)
, (94.9 KB)

I can’t find anything usefull…

Hi Anton… I assumed this was a one-off event so I never posted back. The way I was able to resolve the issue was to duplicate the template, then do a find for the instance path of the original template and replace with the duplicated path. Then repeat the process of find/replace to change the instance path back to the original template. Then delete duplicate template. It sure beat rebinding everything. Hope this works in your case also.

As you were…


Hello everyone
I got a similar error which said I was trying to coerce a string into a number when mapping some numbers to strings, I had to delete the reference tag and create it again on the UDT with the same information. For me it was a mistake when the tag was created: I had it as an integer instead of a string. Changing it kept on popping the error until I deleted and created it again.

A post was split to a new topic: Type coercion error on opening window