Hi Team, I upgraded the spring boot project and hibernate. I use postgresdb and have some entities with ENUM-type columns.
like:-
@Enumerated(EnumType.STRING)
@Column(columnDefinition = "status_enum")
@Type(PostgreSQLEnumType.class)
private Status status
package - import com.vladmihalcea.hibernate.type.basic.PostgreSQLEnumType
and on start it is throwing NULL pointer exception. I am sharing stack trace and MVN tree dependency. Please suggest or let me know if I am doing something wrong here.
stack trace:- Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaSharedEM_entityManagerFactory': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:377)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:135)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:688)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:512)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1332)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1162)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:325)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:323)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:365)
... 95 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Cannot invoke "org.hibernate.boot.spi.MetadataBuildingContext.getMetadataCollector()" because "this.metadataBuildingContext" is null
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1770)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:325)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:323)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:365)
... 107 common frames omitted
Caused by: java.lang.NullPointerException: Cannot invoke "org.hibernate.boot.spi.MetadataBuildingContext.getMetadataCollector()" because "this.metadataBuildingContext" is null
at org.hibernate.type.spi.TypeConfiguration$Scope.getDialect(TypeConfiguration.java:459)
at org.hibernate.type.EnumType$LocalJdbcTypeIndicators.getDialect(EnumType.java:516)
at org.hibernate.type.descriptor.jdbc.VarcharJdbcType.shouldUseMaterializedLob(VarcharJdbcType.java:90)
at org.hibernate.type.descriptor.jdbc.VarcharJdbcType.resolveIndicatedType(VarcharJdbcType.java:79)
at org.hibernate.type.descriptor.java.BasicJavaType.getRecommendedJdbcType(BasicJavaType.java:33)
at org.hibernate.type.descriptor.java.StringJavaType.getRecommendedJdbcType(StringJavaType.java:56)
at org.hibernate.type.EnumType.configureUsingReader(EnumType.java:180)
at org.hibernate.type.EnumType.setParameterValues(EnumType.java:142)
at com.vladmihalcea.hibernate.type.basic.PostgreSQLEnumType.setParameterValues(PostgreSQLEnumType.java:46)
at org.hibernate.mapping.MappingHelper.injectParameters(MappingHelper.java:111)
at org.hibernate.mapping.BasicValue.setExplicitCustomType(BasicValue.java:836)
at org.hibernate.boot.model.internal.BasicValueBinder.fillSimpleValue(BasicValueBinder.java:1363)
at org.hibernate.boot.model.internal.SetBasicValueTypeSecondPass.doSecondPass(SetBasicValueTypeSecondPass.java:27)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1870)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1815)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:331)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1380)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1451)
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:75)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:376)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:352)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1817)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1766)
... 114 common frames omitted
mvn tree:-
+- org.springframework.boot:spring-boot-starter-web:jar:3.1.4:compile
+- org.postgresql:postgresql:jar:42.4.1:runtime
| \- org.checkerframework:checker-qual:jar:3.5.0:runtime
+- com.vladmihalcea:hibernate-types-60:jar:2.21.1:compile
| +- javax.xml.bind:jaxb-api:jar:2.3.0:compile
| \- jakarta.xml.bind:jakarta.xml.bind-api:jar:4.0.1:compile
| \- jakarta.activation:jakarta.activation-api:jar:2.1.2:compile
+- org.hibernate.orm:hibernate-core:jar:6.3.1.Final:compile
| +- jakarta.persistence:jakarta.persistence-api:jar:3.1.0:compile
| +- jakarta.transaction:jakarta.transaction-api:jar:2.0.1:compile
| +- org.jboss.logging:jboss-logging:jar:3.5.3.Final:compile
| +- io.smallrye:jandex:jar:3.1.2:runtime
| +- com.fasterxml:classmate:jar:1.5.1:compile
| +- net.bytebuddy:byte-buddy:jar:1.14.8:runtime
| +- org.glassfish.jaxb:jaxb-runtime:jar:4.0.3:runtime
| | \- org.glassfish.jaxb:jaxb-core:jar:4.0.3:runtime
| | +- org.eclipse.angus:angus-activation:jar:2.0.1:runtime
| | +- org.glassfish.jaxb:txw2:jar:4.0.3:runtime
| | \- com.sun.istack:istack-commons-runtime:jar:4.1.2:runtime
| +- jakarta.inject:jakarta.inject-api:jar:2.0.1:runtime
| \- org.antlr:antlr4-runtime:jar:4.10.1:compile
+- org.hibernate.common:hibernate-commons-annotations:jar:6.0.6.Final:compile
+- io.hypersistence:hypersistence-utils-hibernate-62:jar:3.5.3:compile
| \- io.hypersistence:hypersistence-tsid:jar:2.1.1:compile
+- org.hibernate.validator:hibernate-validator:jar:8.0.1.Final:compile
| \- jakarta.validation:jakarta.validation-api:jar:3.0.2:compile