CF 2018 - Random Crash When Initializing ORM Entities
Hi all,
We are seeing a really weird, totally random crash on 2018. This is with code that is currently running fine in production on 2016, and ran fine on 11. Here are definitions for three simple objects that produce the crash:
BaseEntity.cfc
component mappedSuperClass="true" accessors="true" {
property name="id" fieldtype="id" generator="identity";
}
BaseType.cfc
component mappedSuperClass="true" accessors="true" extends="BaseEntity" {
property name="title" fieldtype="column" ormtype="string";
}
PersonType.cfc
component accessors="true" extends="BaseType" persistent="true" {
property name="People" fieldtype="one-to-many" cfc="Person" inverse="true" inverseJoinColumn="PersonTypeID" singularname="Person";
}
PersonType.cfc here is just an example. The third component in the chain could be totally empty (so only containing the inherited ID and Title).
What we are seeing is that Coldfusion 2018 will crash at a random time, with an exception trying to initialize a component that extends BaseType. If the page I am loading doesn't load a PersonType, but maybe loads an object of AnimalType that also extends BaseType, it could crash on that component instead. Once the crash has occurred, any code that tries to load any object that extends BaseType will crash. The only remedy is to shut down the Coldfusion service, clear the files cached in cfusion/wwwroot/WEB-INF/cfclasses, and restart the service.
When I say random, I mean that you could refresh the same page numerous times loading the same component, but at some indeterminate point it will crash with the exception.
When you drill down the exception dump to find the root cause, it always comes back to something in Coldfusion's internals:
Caused by: java.lang.ClassCastException: coldfusion.runtime.AttributeCollection cannot be cast to java.base/java.lang.String at coldfusion.runtime.TemplateProxy.findAbstractMethodsRecursively(TemplateProxy.java:1590) at coldfusion.runtime.TemplateProxy.validateAbstractContract(TemplateProxy.java:1903) at coldfusion.runtime.TemplateProxy.validateComponent(TemplateProxy.java:1541) at coldfusion.runtime.TemplateProxy.verifyInterfacesImpl(TemplateProxy.java:1952) at coldfusion.cfc.ComponentProxyFactory.getProxy(ComponentProxyFactory.java:82) at coldfusion.cfc.ComponentProxyFactory.getProxy(ComponentProxyFactory.java:56) at coldfusion.orm.hibernate.CFCTuplizer$CFCinstantiator.instantiate(CFCTuplizer.java:198) ... 125 more
It seems like this is happening when Coldfusion decides it needs to recompile/recache the component. Turning on Trusted Cache drastically reduces the chances of it happening.
Has anyone else run into this? This is a showstopper for us migrating from 2016 to 2018.
