Skip to content

java.lang.InstantiationError after upgrading to Spring Boot 2.4.4 (spring data commons 2.4.6) #3608

Closed
@svpr3m0

Description

@svpr3m0

In a Spring Boot application we use Spring Data Mongo to map some documents. Some of them have embedded documents with a hierarchy, e.g.:

@Document("projects")
@TypeAlias("project")
data class Project(
       ...
       val budget: ProjectBudget)
abstract class ProjectBudget {

    abstract fun getCurrentBudget(): MonetaryAmount?

}
@TypeAlias("projectProjectBudget")
class ClosedProjectBudget(... ) : ProjectBudget() {}

Up to Spring Boot 2.4.3 when retrieving a Project instance the corresponding ProjectBudget subclass what built correctly. However after the upgrade to Boot 2.4.4 we get this exception:

Caused by: java.lang.InstantiationError: xxx.ProjectBudget
	at xxx.ProjectBudget_Instantiator_srp3na.newInstance(Unknown Source)
	at org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator$EntityInstantiatorAdapter.createInstance(ClassGeneratingEntityInstantiator.java:238)
	at org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator.createInstance(ClassGeneratingEntityInstantiator.java:87)
	at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:344)

There seems to be a regression when instantiating subclasses.

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: stackoverflowA question that's better suited to stackoverflow.com

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions