So I have a project I want to start work with. The senior developer sent me a zip package of the project and database.sql file for initializing the local database for me to just launch the project. But we are facing the error.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/spring/spring-database.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to open JDBC Connection for DDL execution
All entities are exactly the same as in the local database. I have changed the XML file config to match my password and URL. Spend 2 days trying to run the project. Will appreciate any help. Please feel free to ask any questions.
<!-- Configure the entity manager factory bean -->
<bean id="entityManagerFactory"
>
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter" ref="hibernateJpaVendorAdapter" />
<!-- Set JPA properties -->
<property name="jpaProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.ProgressDialect</prop>
</props>
</property>
<property name="packagesToScan" value="nl.impressie.grazer.hibernate" />
</bean>
CodePudding user response:
Sounds like hibernate is failing to initialize due to a failure to connect to the DB.
Are you sure you have a Postgresql DB running? Is Spring configured correctly to interface with that DB? (i.e. is the host, port, databaseschema, username and password set?)
CodePudding user response:
If this is a new project, you shouldn't be using any of this XML configuration at all. Instead, create a template project at https://start.spring.io that includes the JPA starter, set your spring.datasource.url
, and be running in 2 minutes.