Unable to build Hibernate SessionFactory, NullPointerException at org.hibernate.mapping.Column.getSqlTypeCode(Column.java:198)

Viewed 248

Please help me.

I'm currently using SQLite to seed data to local db file in any existing project, which already configured multiple spring data modules, like H2 database, redis and elasticsearch, I hit this issue. I'm stuck for 2 days, and couldn't figure out how to fix this issue.

2020-12-12 16:34:30,288 [restartedMain][Job: ][Task: ]  INFO  o.s.c.c.c.ConfigServicePropertySourceLocator - Fetching config from server at : http://localhost:8888 
2020-12-12 16:34:30,490 [restartedMain][Job: ][Task: ]  INFO  o.s.c.c.c.ConfigServicePropertySourceLocator - Connect Timeout Exception on Url - http://localhost:8888. Will be trying the next url if available 
2020-12-12 16:34:30,490 [restartedMain][Job: ][Task: ]  WARN  o.s.c.c.c.ConfigServicePropertySourceLocator - Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/scheduler/default": Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused) 
2020-12-12 16:34:30,495 [restartedMain][Job: ][Task: ]  INFO  c.u.o.c.CloudTestSchedulerApplication - The following profiles are active: test 
2020-12-12 16:34:34,273 [restartedMain][Job: ][Task: ]  INFO  o.s.d.r.c.RepositoryConfigurationDelegate - Multiple Spring Data modules found, entering strict repository configuration mode! 
2020-12-12 16:34:34,273 [restartedMain][Job: ][Task: ]  INFO  o.s.d.r.c.RepositoryConfigurationDelegate - Bootstrapping Spring Data JPA repositories in DEFAULT mode. 
2020-12-12 16:34:34,598 [restartedMain][Job: ][Task: ]  INFO  o.s.d.r.c.RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 307ms. Found 1 JPA repository interfaces. 
2020-12-12 16:34:35,783 [restartedMain][Job: ][Task: ]  INFO  o.s.c.context.scope.GenericScope - BeanFactory id=6aa784a4-6774-3eca-8028-65330de99bc4 
2020-12-12 16:34:35,841 [restartedMain][Job: ][Task: ]  INFO  o.s.i.c.DefaultConfiguringBeanFactoryPostProcessor - No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created. 
2020-12-12 16:34:35,924 [restartedMain][Job: ][Task: ]  INFO  o.s.i.c.DefaultConfiguringBeanFactoryPostProcessor - No bean named 'integrationHeaderChannelRegistry' has been explicitly defined. Therefore, a default DefaultHeaderChannelRegistry will be created. 
2020-12-12 16:34:36,328 [restartedMain][Job: ][Task: ]  INFO  o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'org.springframework.integration.config.IntegrationManagementConfiguration' of type [org.springframework.integration.config.IntegrationManagementConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 
2020-12-12 16:34:36,361 [restartedMain][Job: ][Task: ]  INFO  o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'integrationChannelResolver' of type [org.springframework.integration.support.channel.BeanFactoryChannelResolver] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 
2020-12-12 16:34:36,365 [restartedMain][Job: ][Task: ]  INFO  o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'integrationDisposableAutoCreatedBeans' of type [org.springframework.integration.config.annotation.Disposables] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 
2020-12-12 16:34:37,438 [restartedMain][Job: ][Task: ]  INFO  o.s.b.w.e.tomcat.TomcatWebServer - Tomcat initialized with port(s): 0 (http) 
2020-12-12 16:34:37,458 [restartedMain][Job: ][Task: ]  INFO  o.a.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-auto-1"] 
2020-12-12 16:34:37,459 [restartedMain][Job: ][Task: ]  INFO  o.a.catalina.core.StandardService - Starting service [Tomcat] 
2020-12-12 16:34:37,459 [restartedMain][Job: ][Task: ]  INFO  o.a.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/9.0.37] 
2020-12-12 16:34:37,771 [restartedMain][Job: ][Task: ]  INFO  o.a.c.c.C.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext 
2020-12-12 16:34:37,771 [restartedMain][Job: ][Task: ]  INFO  o.s.b.w.s.c.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 7192 ms 
2020-12-12 16:34:38,510 [restartedMain][Job: ][Task: ]  INFO  o.h.jpa.internal.util.LogHelper - HHH000204: Processing PersistenceUnitInfo [name: default] 
2020-12-12 16:34:38,623 [restartedMain][Job: ][Task: ]  INFO  org.hibernate.Version - HHH000412: Hibernate ORM core version 5.4.24.Final 
2020-12-12 16:34:38,974 [restartedMain][Job: ][Task: ]  INFO  o.h.annotations.common.Version - HCANN000001: Hibernate Commons Annotations {5.1.2.Final} 
2020-12-12 16:34:39,224 [restartedMain][Job: ][Task: ]  INFO  com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting... 
2020-12-12 16:34:39,524 [restartedMain][Job: ][Task: ]  INFO  com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Start completed. 
2020-12-12 16:34:39,557 [restartedMain][Job: ][Task: ]  INFO  org.hibernate.dialect.Dialect - HHH000400: Using dialect: my.demo.storage.configuration.SQLiteDialect 
2020-12-12 16:34:40,143 [restartedMain][Job: ][Task: ]  INFO  o.h.id.enhanced.TableGenerator - HHH000398: Explicit segment value for id generator [SEQ_GEN.PREFIX] suggested; using default [id_entity] 
2020-12-12 16:34:41,567 [restartedMain][Job: ][Task: ]  WARN  o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is java.lang.NullPointerException 
2020-12-12 16:34:41,567 [restartedMain][Job: ][Task: ]  INFO  com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown initiated... 
2020-12-12 16:34:41,574 [restartedMain][Job: ][Task: ]  INFO  com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown completed. 
2020-12-12 16:34:41,576 [restartedMain][Job: ][Task: ]  INFO  o.a.catalina.core.StandardService - Stopping service [Tomcat] 
2020-12-12 16:34:41,609 [restartedMain][Job: ][Task: ]  INFO  o.s.b.a.l.ConditionEvaluationReportLoggingListener - 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 
2020-12-12 16:34:41,617 [restartedMain][Job: ][Task: ]  ERROR o.s.boot.SpringApplication - Application run failed 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is java.lang.NullPointerException
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1794)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1109)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
    at my.demo.TestMemoApplication.main(TestMemoApplication.java:37)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is java.lang.NullPointerException
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:403)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:378)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1853)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1790)
    ... 20 common frames omitted
Caused by: java.lang.NullPointerException: null
    at org.hibernate.mapping.Column.getSqlTypeCode(Column.java:198)
    at org.hibernate.hql.spi.id.AbstractMultiTableBulkIdStrategyImpl.buildIdTableCreateStatement(AbstractMultiTableBulkIdStrategyImpl.java:146)
    at org.hibernate.hql.spi.id.persistent.PersistentTableBulkIdStrategy.buildIdTableInfo(PersistentTableBulkIdStrategy.java:130)
    at org.hibernate.hql.spi.id.persistent.PersistentTableBulkIdStrategy.buildIdTableInfo(PersistentTableBulkIdStrategy.java:43)
    at org.hibernate.hql.spi.id.AbstractMultiTableBulkIdStrategyImpl.prepare(AbstractMultiTableBulkIdStrategyImpl.java:84)
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:309)
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:469)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1259)
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:391)
    ... 24 common frames omitted

Process finished with exit code 0

configuration file:

application.properties:
spring.jpa.database-platform=my.demo.storage.configuration.SQLiteDialect
spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.EJB3NamingStrategy
spring.jpa.hibernate.ddl-auto=update
spring.datasource.username=xxx
spring.datasource.password=xxx
spring.datasource.initialization-mode=always
test.scheduler.sqlite.file=/Users/username/Downloads/sqllite-database-test.db
spring.data.redis.repositories.enabled=false
spring.data.elasticsearch.repositories.enabled=false
spring.h2.console.enabled=false

Followed this tutorial, https://www.baeldung.com/spring-boot-sqlite

0 Answers
Related