Changing route to JPA entities causing FlowableClassLoadingException class not found '**'

I have a deployed system and would like to deploy a new version, in this new version the spring service has had a substantial refactor, with many files changing location.

When I deploy the new spring service and carry out an engine action it falls over due to FlowableClassLoadingException class not found '**' (see full logs below). The logs are looking for the classes in their new locations however the engine mustn’t be using these new classpaths and is expecting the old ones. This error is only coming up for the spring JPA entities NOT other files whose classpath has changed, services, delegates etc. If I move the entities back to their old classpath and redeploy the engine is happy. Delegates and services work fine with their new classpath as long as those entities are using their old classpaths.

Why is engine referencing old classpath and not updated ones, and why is this error isolated to only JPA entities?

Error querying database. Cause: org.flowable.common.engine.api.FlowableClassLoadingException: Class not found:

| ### The error may exist in org/flowable/db/mapping/entity/Execution.xml
| ### The error may involve org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl.selectProcessInstanceWithVariablesByQueryCriteria
| ### The error occurred while handling results

| at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedWebappClassLoader.loadClass( ~[spring-boot-1.5.22.RELEASE.jar!/:1.5.22.RELEASE]
| at org.apache.catalina.loader.WebappClassLoaderBase.loadClass( ~[tomcat-embed-core-8.5.43.jar!/:8.5.43]
| at java.lang.Class.forName0(Native Method) ~[na:1.8.0_212]
| at java.lang.Class.forName( ~[na:1.8.0_212]
| at org.flowable.common.engine.impl.util.ReflectUtil.loadClass( ~[flowable-engine-common-6.4.1.jar!/:6.4.1]
| at org.flowable.common.engine.impl.util.ReflectUtil.loadClass( ~[flowable-engine-common-6.4.1.jar!/:6.4.1]
| at org.flowable.variable.service.impl.types.JPAEntityMappings.getJPAEntity( ~[flowable-variable-service-6.4.1.jar!/:6.4.1]
| at org.flowable.variable.service.impl.types.JPAEntityVariableType.getValue( ~[flowable-variable-service-6.4.1.jar!/:6.4.1]
| at org.flowable.variable.service.impl.persistence.entity.VariableInstanceEntityImpl.getValue( ~[flowable-variable-service-6.4.1.jar!/:6.4.1

Can anybody provide help/advice?

That’s correct: the reason is because the delegates use the id of the bean as reference.
For JPA entities, this doesn’t work like that because the class name is stored in the actual variable: flowable-engine/ at main · flowable/flowable-engine · GitHub
This means that for JPA variables, these classes cannot be changed (unless you’d update the variable in the database).