Skip to content

Report unsupported DBMS instead of throwing NPE - #5555

Merged
knstvk merged 1 commit into
jmix-framework:masterfrom
makssent:unsupported-dbms-error
Jul 31, 2026
Merged

Report unsupported DBMS instead of throwing NPE#5555
knstvk merged 1 commit into
jmix-framework:masterfrom
makssent:unsupported-dbms-error

Conversation

@makssent

Copy link
Copy Markdown
Contributor

When jmix.data.dbms-type is set to a value that has no DbmsFeatures implementation on the classpath, the application fails with a bare NPE:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'entityManagerFactory' ... Cannot invoke "io.jmix.data.persistence.DbmsFeatures.getJpaParameters()"
because the return value of "io.jmix.data.persistence.DbmsSpecifics.getDbmsFeatures(String)" is nu
      at io.jmix.data.impl.JmixBaseEntityManagerFactoryBean.setupJpaProperties(JmixBaseEntityManag

The message mentions neither the DBMS type nor the property that produced it, so the
actual cause is not discoverable from the log. This is easy to hit with a typo in a supported DBMS name -postgres instead of
postgresql, mssqlserver instead of mssql.

Cause and fix

DbmsSpecifics.get(Class, String, String) behaves differently depending on the requested interface: for DbmsFeatures and DbTypeConverter it silently returns null, while for the rest it delegates to applicationContext.getBean(name) and gets a NoSuchBeanDefinitionException with a meaningful message. On top of that, the internal findDbmsFeatures is annotated @nullable, but the public getDbmsFeatures() wrapping it is not, and JmixBaseEntityManagerFactoryBean dereferences the result without a check.

Now all three lookups throw an IllegalStateException naming the DBMS type and the missing interface:

Unsupported DBMS 'firebird': no DbmsFeatures implementation found

This matches the neighbouring DbmsType.getType(), which already throws the same exception when the DBMS cannot be determined.

@makssent
makssent marked this pull request as ready for review July 30, 2026 08:18
@makssent
makssent force-pushed the unsupported-dbms-error branch from 053747f to a1154f5 Compare July 30, 2026 08:22
@knstvk knstvk self-assigned this Jul 30, 2026
@knstvk
knstvk merged commit ff75bc3 into jmix-framework:master Jul 31, 2026
@makssent
makssent deleted the unsupported-dbms-error branch July 31, 2026 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants