Skip to content

NoClassDefFoundError: org/hibernate/community/dialect/CommunityDatabase when no default datasource #50141

@HerrDerb

Description

@HerrDerb

Describe the bug

With PR #48130 the usage of the class CommunityDatabase got introduce in the HibernateProcessorUtil#L241

When building a project with no default datasource (multi tenancy, in which we provide the tenant datasources at runtime), this causes

	[error]: Build step io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor#configurationDescriptorBuilding threw an exception: java.lang.NoClassDefFoundError: org/hibernate/community/dialect/CommunityDatabase
        	at io.quarkus.hibernate.orm.deployment.util.HibernateProcessorUtil.lambda$supportedDatabaseKindFromProductName$2(HibernateProcessorUtil.java:241)
        	at java.base/java.util.Optional.flatMap(Optional.java:289)
        	at io.quarkus.hibernate.orm.deployment.util.HibernateProcessorUtil.supportedDatabaseKindFromProductName(HibernateProcessorUtil.java:236)
        	at io.quarkus.hibernate.orm.deployment.util.HibernateProcessorUtil.lambda$determineDatabaseKind$0(HibernateProcessorUtil.java:228)

The reason for this seems that no JdbcDataSourceBuildItem with default = true exists, of which the db kind can be read from.
This causes the dbKindOptional HibernateProcessorUtil.java#L226 to be empty, hence calling the method HibernateProcessorUtil.supportedDatabaseKindFromProductName. This again will cause the NoClassDefFoundError as, without the hibernate-orm-derby extension, the class CommunityDatabase is not provided (current providing of the hibernate-community-dialects might be probably an issue itself)

Quarkus version or git rev

3.26.4

Expected behaviour

Without a default datasource, the db kind still should be read from the configuration property

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions