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(TypeUtilities.java:1292)
	at com.inductiveautomation.factorypmi.application.binding.DynamicPropertyDescriptor.setValue(DynamicPropertyDescriptor.java:59)
	at com.inductiveautomation.factorypmi.application.binding.util.DynamicPropertyUtil.setPropertyValue(DynamicPropertyUtil.java:260)
	at com.inductiveautomation.vision.api.client.components.model.AbstractVisionPanel.setPropertyValue(AbstractVisionPanel.java:164)
	at com.inductiveautomation.factorypmi.application.components.template.TemplateHolder.startupTemplate(TemplateHolder.java:396)
	at com.inductiveautomation.factorypmi.application.components.template.TemplateHolder.onStartup(TemplateHolder.java:517)
	at com.inductiveautomation.vision.api.client.components.model.AbstractVisionPanel.startupComponent(AbstractVisionPanel.java:208)
	at com.inductiveautomation.factorypmi.application.components.util.ComponentVisitor$StartupVisitor.visit(ComponentVisitor.java:322)
	at com.inductiveautomation.factorypmi.application.components.util.ComponentVisitor.walk(ComponentVisitor.java:91)
	at com.inductiveautomation.factorypmi.application.components.util.ComponentVisitor.walk(ComponentVisitor.java:69)
	at com.inductiveautomation.factorypmi.application.FPMIWindow.startup(FPMIWindow.java:357)
	at com.inductiveautomation.factorypmi.designer.workspace.WindowWorkspace$DesigntimeWindowOpener.openWindow(WindowWorkspace.java:3554)
	at com.inductiveautomation.factorypmi.designer.workspace.WindowWorkspace.openWindow(WindowWorkspace.java:1322)
	at com.inductiveautomation.factorypmi.designer.model.navtree.WindowNode.onDoubleClick(WindowNode.java:269)
	at com.inductiveautomation.ignition.designer.navtree.NavTreePanel$MouseListener$1.run(NavTreePanel.java:719)
	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)

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…
Steve

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: StatusBulky_broken.zip (96.2 KB)
, StatusBulky_fixed.zip (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…
Steve

3 Likes

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