Spring boot with two datasources - java

I'm trying to set up a spring boot project with two datasources.
one for loading and one for storing.
application prop.
# Primary DataSource
datasource.primary.url=url
datasource.primary.username=root
datasource.primary.password=password
datasource.primary.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
# Secondary DataSource
datasource.secondary.url=url
datasource.secondary.username=root
datasource.secondary.password=password
datasource.secondary.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
configuration class for primary db
package com.anders.cphbusiness.db;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.PersistenceContext;
import javax.sql.DataSource;
#Configuration
#EnableTransactionManagement
#EnableJpaRepositories(basePackages = "com.anders.cphbusiness.entitiesModel", entityManagerFactoryRef = "entityManager")
public class LoadDataSourceConfig {
#Bean(name = "dataSource")
#Primary
#ConfigurationProperties(prefix = "datasource.primary")
public DataSource loadingDataSource() {
return DataSourceBuilder.create().build();
}
#PersistenceContext(unitName = "primary")
#Primary
#Bean(name = "entityManager")
public LocalContainerEntityManagerFactoryBean loadingEntityManagerFactory(EntityManagerFactoryBuilder builder) {
return builder.dataSource(loadingDataSource()).persistenceUnit("primary").packages("com.anders.cphbusiness.entitiesModel").build();
}
}
configuration class for secondary db
package com.anders.cphbusiness.db;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.PersistenceContext;
import javax.sql.DataSource;
#Configuration
#EnableTransactionManagement
#EnableJpaRepositories(basePackages = "com.anders.cphbusiness.storingModel", entityManagerFactoryRef = "secondaryEntityManager", transactionManagerRef = "secondaryTransactionManager")
public class StoreDataSourceConfig {
#Bean
#ConfigurationProperties(prefix = "datasource.secondary")
public DataSource storingDataSource() {
return DataSourceBuilder.create().build();
}
#PersistenceContext(unitName = "secondary")
#Bean(name = "secondaryEntityManager")
public LocalContainerEntityManagerFactoryBean storingEntityManagerFactory(
EntityManagerFactoryBuilder builder) {
return builder
.dataSource(storingDataSource())
.packages("com.anders.cphbusiness.storingModel")
.persistenceUnit("secondary")
.build();
}
#Bean(name = "secondaryTransactionManager")
public PlatformTransactionManager transactionManager(EntityManagerFactoryBuilder builder) {
JpaTransactionManager tm = new JpaTransactionManager();
tm.setEntityManagerFactory(storingEntityManagerFactory(builder).getObject());
tm.setDataSource(storingDataSource());
return tm;
}
}
my repo in controller that it's complaining about.
#Autowired
private wagerBoardMarksRepo repo;
the actual repo
package com.anders.cphbusiness.repositories;
import com.anders.cphbusiness.entitiesModel.WagerBoard;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
#Repository
public interface WagerBoardRepo extends JpaRepository<WagerBoard, String> {
}
error :
2017-02-02 15:19:53.035 INFO 6804 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2017-02-02 15:19:53.035 INFO 6804 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.11
2017-02-02 15:19:53.172 INFO 6804 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-02-02 15:19:53.172 INFO 6804 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3048 ms
2017-02-02 15:19:53.452 INFO 6804 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-02-02 15:19:53.462 INFO 6804 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'metricsFilter' to: [/*]
2017-02-02 15:19:53.462 INFO 6804 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-02-02 15:19:53.462 INFO 6804 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-02-02 15:19:53.462 INFO 6804 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-02-02 15:19:53.462 INFO 6804 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-02-02 15:19:53.462 INFO 6804 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'webRequestLoggingFilter' to: [/*]
2017-02-02 15:19:53.462 INFO 6804 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'applicationContextIdFilter' to: [/*]
2017-02-02 15:19:56.837 INFO 6804 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'primary'
2017-02-02 15:19:56.857 INFO 6804 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: primary
...]
2017-02-02 15:19:57.008 INFO 6804 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.11.Final}
2017-02-02 15:19:57.009 INFO 6804 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2017-02-02 15:19:57.011 INFO 6804 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2017-02-02 15:19:57.071 INFO 6804 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2017-02-02 15:19:57.185 INFO 6804 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.SQLServerDialect
2017-02-02 15:19:57.666 WARN 6804 --- [ main] org.hibernate.mapping.RootClass : HHH000038: Composite-id class does not override equals(): com.anders.cphbusiness.entitiesModel.PK_poolgameTransaction
2017-02-02 15:19:57.667 WARN 6804 --- [ main] org.hibernate.mapping.RootClass : HHH000039: Composite-id class does not override hashCode(): com.anders.cphbusiness.entitiesModel.PK_poolgameTransaction
2017-02-02 15:19:57.667 WARN 6804 --- [ main] org.hibernate.mapping.RootClass : HHH000038: Composite-id class does not override equals(): com.anders.cphbusiness.entitiesModel.PK_WagerBoardMarks
2017-02-02 15:19:57.667 WARN 6804 --- [ main] org.hibernate.mapping.RootClass : HHH000039: Composite-id class does not override hashCode(): com.anders.cphbusiness.entitiesModel.PK_WagerBoardMarks
2017-02-02 15:19:57.668 WARN 6804 --- [ main] org.hibernate.mapping.RootClass : HHH000038: Composite-id class does not override equals(): com.anders.cphbusiness.entitiesModel.PK_wagerBoard
2017-02-02 15:19:57.668 WARN 6804 --- [ main] org.hibernate.mapping.RootClass : HHH000039: Composite-id class does not override hashCode(): com.anders.cphbusiness.entitiesModel.PK_wagerBoard
2017-02-02 15:19:58.050 INFO 6804 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'primary'
2017-02-02 15:19:58.090 INFO 6804 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'secondary'
2017-02-02 15:19:58.090 INFO 6804 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: secondary
...]
2017-02-02 15:20:00.790 INFO 6804 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.SQLServerDialect
2017-02-02 15:20:00.962 INFO 6804 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'secondary'
2017-02-02 15:20:00.982 WARN 6804 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'restController': Unsatisfied dependency expressed through field 'repo'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.anders.cphbusiness.repositories.wagerBoardMarksRepo' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true), #org.springframework.beans.factory.annotation.Qualifier(value=wagerRepo)}
2017-02-02 15:20:00.982 INFO 6804 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'secondary'
2017-02-02 15:20:00.982 INFO 6804 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'primary'
2017-02-02 15:20:01.002 INFO 6804 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-02-02 15:20:01.152 ERROR 6804 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field repo in com.anders.cphbusiness.controller.restController required a bean of type 'com.anders.cphbusiness.repositories.wagerBoardMarksRepo' that could not be found.
Action:
Consider defining a bean of type 'com.anders.cphbusiness.repositories.wagerBoardMarksRepo' in your configuration.
tried to follow the example at http://docs.spring.io/spring-boot/docs/current/reference/html/howto-data-access.html#howto-use-two-entity-managers
Any suggestions - hints - guides for setting up spring boot with multiple datasources (preferable a working git with project the utilize two datasources)

Related

HikariCP - Multiple datasources, only primary datasource's pool started (spring boot)

So, I've configured my spring boot application to handle multiple datasource everything is good, but I noticed that when I launch the application, the primary datasource's pool is started but not the others, only when they are needed (which sometimes results in nullpointer...)
2020-03-05 15:34:02.478 INFO 11172 --- [ main] be.MyApp.ESPI.EspiApplication :
Starting EspiApplication on BESVC-HQ2000928 with PID 11172 (C:\Users\...\Documents\MyApp\Others\ESPI\ESPI\target\classes started by ... in C:\Users\...\Documents\MyApp\Others\ESPI\ESPI)
2020-03-05 15:34:02.483 INFO 11172 --- [ main] be.MyApp.ESPI.EspiApplication : The following profiles are active: dev
2020-03-05 15:34:03.149 INFO 11172 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-03-05 15:34:03.233 INFO 11172 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 65ms. Found 2 JPA repository interfaces.
2020-03-05 15:34:03.811 INFO 11172 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-03-05 15:34:04.433 INFO 11172 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-03-05 15:34:04.444 INFO 11172 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-03-05 15:34:04.444 INFO 11172 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.30]
2020-03-05 15:34:04.603 INFO 11172 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-03-05 15:34:04.603 INFO 11172 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2047 ms
2020-03-05 15:34:04.761 WARN 11172 --- [ main] com.zaxxer.hikari.HikariConfig : FirstPool - maxLifetime is less than 30000ms, setting to default 1800000ms.
2020-03-05 15:34:04.761 INFO 11172 --- [ main] com.zaxxer.hikari.HikariDataSource : FirstPool - Starting...
2020-03-05 15:34:05.095 INFO 11172 --- [ main] com.zaxxer.hikari.pool.PoolBase : FirstPool - Driver does not support get/set network timeout for connections. (oracle.jdbc.driver.T4CConnection.getNetworkTimeout()I)
2020-03-05 15:34:05.099 INFO 11172 --- [ main] com.zaxxer.hikari.HikariDataSource : FirstPool - Start completed.
2020-03-05 15:34:05.159 INFO 11172 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-03-05 15:34:05.243 INFO 11172 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.4.10.Final}
2020-03-05 15:34:05.414 INFO 11172 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-03-05 15:34:05.554 INFO 11172 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.Oracle12cDialect
2020-03-05 15:34:06.519 INFO 11172 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-03-05 15:34:06.526 INFO 11172 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-03-05 15:34:06.853 WARN 11172 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-03-05 15:34:06.947 INFO 11172 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-03-05 15:34:07.115 INFO 11172 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2020-03-05 15:34:07.116 INFO 11172 --- [ main] be.myapp.ESPI.EspiApplication : Started EspiApplication in 5.135 seconds (JVM running for 5.744)
2020-03-05 15:34:17.044 INFO 11172 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-03-05 15:34:17.044 INFO 11172 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2020-03-05 15:34:17.052 INFO 11172 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 8 ms
2020-03-05 15:34:17.087 WARN 11172 --- [nio-8080-exec-1] com.zaxxer.hikari.HikariConfig : SecondPool- maxLifetime is less than 30000ms, setting to default 1800000ms.
2020-03-05 15:34:17.087 INFO 11172 --- [nio-8080-exec-1] com.zaxxer.hikari.HikariDataSource : SecondPool- Starting...
2020-03-05 15:34:17.176 INFO 11172 --- [nio-8080-exec-1] com.zaxxer.hikari.pool.PoolBase : SecondPool- Driver does not support get/set network timeout for connections. (oracle.jdbc.driver.T4CConnection.getNetworkTimeout()I)
2020-03-05 15:34:17.178 INFO 11172 --- [nio-8080-exec-1] com.zaxxer.hikari.HikariDataSource : SecondPool- Start completed.
As you can see FirstPool is started. Spring Application starts. Then, only when needed, the SecondPool is started... I wonder how I can force the pool to start before the application starts ?
EDIT :
My properties file are like this :
# DataSource definitions :
first.datasource.jdbc-url=jdbc:oracle:thin:#*a host*
first.datasource.username=user1
first.datasource.password=xxxxxxxxx
first.datasource.poolName=FirstPool
first.datasource.maximumPoolSize=100
first.datasource.maxLifetime=10000
second.datasource.jdbc-url=jdbc:oracle:thin:#*another host*
second.datasource.username=user2
second.datasource.password=xxxxxxxxx
second.datasource.poolName=SecondPool
second.datasource.maximumPoolSize=100
second.datasource.maxLifetime=10000
Second part :
# Profile definition
spring.profiles.active=#spring.profiles.active#
# JPA definitions
spring.jpa.show-sql=true
spring.jpa.database=oracle
# DataSource
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.hikari.dataSourceClassName=oracle.jdbc.pool.OracleDataSource
spring.datasource.hikari.dataSourceProperties.implicitCachingEnabled=true
spring.datasource.hikari.dataSourceProperties.fastConnectionFailoverEnabled=true
# Oracle specifics
oracle.net.tns_admin=${ORACLE_HOME}/NETWORK/ADMIN
The configuration class that handle the DB Configuration :
#Configuration
#PropertySource({ "classpath:application.properties", "classpath:application-${spring.profiles.active}.properties"})
#Primary
public class DBConfiguration {
#Bean(name = "FirstDataSource")
#ConfigurationProperties("first.datasource")
#Primary
public HikariDataSource FirstDataSource() {
return (HikariDataSource) DataSourceBuilder.create().build();
}
#Bean(name = "SecondDataSource")
#ConfigurationProperties("second.datasource")
public HikariDataSource SecondDataSource() {
return (HikariDataSource) DataSourceBuilder.create().build();
}
#Bean(name="FirstTM")
#Autowired
#Primary
DataSourceTransactionManager FirstTM(#Qualifier ("FirstDataSource") DataSource datasource) {
DataSourceTransactionManager txm = new DataSourceTransactionManager(datasource);
return txm;
}
#Bean(name="SecondTM")
#Autowired
DataSourceTransactionManager SecondTM(#Qualifier("SecondDataSource") DataSource datasource) {
DataSourceTransactionManager txm = new DataSourceTransactionManager(datasource);
return txm;
}
}
I've found the answer.
So, first, the dataSources are all created, BUT, the pool attached to it are not created until asked. So the idea is to force their initialization when starting the application.
This can be achieved like this (see How to configure hikari pool for eager initialization? ):
You can use an ApplicationLoader and get a connection at startup:
#Component
public class HikariLoader implements ApplicationRunner {
private final HikariDataSource hikariDataSource;
#Autowired
public HikariLoader(HikariDataSource hikariDataSource) {
this.hikariDataSource = hikariDataSource;
}
#Autowired
public void run(ApplicationArguments args) throws SQLException {
hikariDataSource.getConnection();
}
}
Try the following approach, It works for me with both data sources.
first.datasource.jdbc-url=jdbc-url
first.datasource.username=username
first.datasource.password=password
.
.
.
.
=================== In Java Configuration File ==================
#Primary
#Bean(name = "firstDataSource")
#ConfigurationProperties(prefix = "first.datasource")
public DataSource dataSource() {
return DataSourceBuilder.create().build();
}
#Primary
#Bean(name = "firstEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean barEntityManagerFactory(EntityManagerFactoryBuilder builder,
#Qualifier("firstDataSource") DataSource dataSource) {
Map<String, String> props = new HashMap<String, String>();
props.put("spring.jpa.database-platform", "org.hibernate.dialect.Oracle12cDialect");
.
.
.
return builder.dataSource(dataSource).packages("com.first.entity").persistenceUnit("firstDB")
.properties(props)
.build();
}
#Primary
#Bean(name = "firstTransactionManager")
public PlatformTransactionManager firstTransactionManager(
#Qualifier("firstEntityManagerFactory") EntityManagerFactory firstEntityManagerFactory) {
return new JpaTransactionManager(firstEntityManagerFactory);
}
second.datasource.jdbc-url=jdbc-url
second.datasource.username=username
second.datasource.password=password
.
.
.
.
=================== In Java Configuration File ==================
#Bean(name = "secondDataSource")
#ConfigurationProperties(prefix = "second.datasource")
public DataSource dataSource() {
return DataSourceBuilder.create().build();
}
#Bean(name = "secondEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean barEntityManagerFactory(EntityManagerFactoryBuilder builder,
#Qualifier("secondDataSource") DataSource dataSource) {
Map<String, String> props = new HashMap<String, String>();
props.put("spring.jpa.database-platform", "org.hibernate.dialect.Oracle12cDialect");
.
.
.
return builder.dataSource(dataSource).packages("com.second.entity").persistenceUnit("secondDB")
.properties(props)
.build();
}
#Bean(name = "secondTransactionManager")
public PlatformTransactionManager secondTransactionManager(
#Qualifier("secondEntityManagerFactory") EntityManagerFactory secondEntityManagerFactory) {
return new JpaTransactionManager(secondEntityManagerFactory);
}

Cant reach Endpoint in Controller, despite it beeing intialised

I read this
and this
The main ideas are that somebody has the wrong structure and components are not beeing scanned, I have a correct one.
My controller is beeing initialised normaly. I tested it debugging and seting the breakpoint on the contructor. It is beiing runned. DEspite of the that the endpoint could not be reached by my tests nor by postman, nor in the browser. I am getting a 404.
I am using gradle. structured my code like this. Already spent 3 Hours trying to fix this, but without success.
My controller looks like this.
package com.fressnapf.microservices.orderhistory.controller.impl;
#RestController
#RequestMapping("/customer")
public class OrderHistoryController implements IOrderHistoryController {
...
#Override
#ResponseStatus(value = HttpStatus.OK)
#RequestMapping(value = "/{customerid}/orders}", method = RequestMethod.GET, produces = "application/json")
public String getOrders(#PathVariable("customerid") String customerid, #RequestParam(required = false) String timeFrom,
#RequestParam(required = false) String timeTo, #RequestParam(required = false) String openOnly) {
...
}
}
Aplplication class
package com.fressnapf.microservices.orderhistory;
#SpringBootApplication()
#ImportResource({"classpath*:applicationContext.xml"})
#Configuration()
public class Application {
public static void main(String[] args) {
ApplicationContext ctx = SpringApplication.run(Application.class, args);
}
}
this is the response I am getting
{
"timestamp": "2020-03-03T16:00:33.489+0000",
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/customer/000000000/orders"
}
this is the log I am getting in the app
2020-03-03 16:59:27.595 INFO 10406 --- [ main] c.f.m.orderhistory.Application : Starting Application on debian-sgtechedge with PID 10406 (/home/sergeygerodes/projects/scporderhistoryservice/build/classes/java/main started by sgerodes in /home/sergeygerodes/projects/scporderhistoryservice)
2020-03-03 16:59:27.602 INFO 10406 --- [ main] c.f.m.orderhistory.Application : No active profile set, falling back to default profiles: default
2020-03-03 16:59:28.414 INFO 10406 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-03-03 16:59:28.441 INFO 10406 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 16ms. Found 0 JPA repository interfaces.
2020-03-03 16:59:28.768 INFO 10406 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-03-03 16:59:29.035 INFO 10406 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-03-03 16:59:29.046 INFO 10406 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-03-03 16:59:29.047 INFO 10406 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.29]
2020-03-03 16:59:29.140 INFO 10406 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-03-03 16:59:29.140 INFO 10406 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1475 ms
2020-03-03 16:59:29.294 INFO 10406 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-03-03 16:59:29.405 INFO 10406 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-03-03 16:59:29.424 INFO 10406 --- [ main] o.s.b.a.h2.H2ConsoleAutoConfiguration : H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:orderhistory'
2020-03-03 16:59:29.517 INFO 10406 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-03-03 16:59:29.565 INFO 10406 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.4.9.Final}
2020-03-03 16:59:29.660 INFO 10406 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-03-03 16:59:29.741 INFO 10406 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2020-03-03 16:59:29.886 INFO 10406 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-03-03 16:59:29.892 INFO 10406 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-03-03 17:00:28.614 WARN 10406 --- [l-1 housekeeper] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=59s108ms538?s586ns).
2020-03-03 17:00:28.685 WARN 10406 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-03-03 17:00:28.845 INFO 10406 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-03-03 17:00:29.052 INFO 10406 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2020-03-03 17:00:29.060 INFO 10406 --- [ main] c.f.m.orderhistory.Application : Started Application in 61.937 seconds (JVM running for 62.493)
2020-03-03 17:00:33.395 INFO 10406 --- [nio-8080-exec-2] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-03-03 17:00:33.395 INFO 10406 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2020-03-03 17:00:33.404 INFO 10406 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : Completed initialization in 9 ms
the whole applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="loggerService"
class="com.fressnapf.sdk.logger.service.impl.DefaultLogService" />
<bean id="dataService"
class="com.fressnapf.sdk.dataaccess.services.impl.H2DataProvider">
<constructor-arg index="0" value="${spring.datasource.url}"/>
<constructor-arg index="1" value="${spring.datasource.username}"/>
<constructor-arg index="2" value="${spring.datasource.password}"/>
</bean>
</beans>
If you copied your controller code and pasted it here...
There is a close bracket too much. I tested it on one of my controllers and it shows the same behaviour.
#RequestMapping(value = "/{customerid}/orders-->}<--"...

Spring Boot Not Deploying WAR From IntelliJ

I was trying to deploy my first Spring Boot application to WAR file but it's not working. There is no error showing but also not finding any WAR file.
I have followed all the steps found on Spring Boot documentation and all over StackOverflow. Here are these:
Step 1: I have extended SpringBootServletInitializer
#SpringBootApplication
public class SpringBoot1Application extends SpringBootServletInitializer
{
public static void main(String[] args) throws Exception
{
SpringApplication.run(SpringBoot1Application.class, args);
}
}
Step 2: Added apply plugin: 'war' and dependencies in the build.gradle file
buildscript {
ext {
springBootVersion = '2.0.3.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'
group = 'com.ranadepto'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-web')
runtime('org.springframework.boot:spring-boot-devtools')
runtime('mysql:mysql-connector-java')
testCompile('org.springframework.boot:spring-boot-starter-test')
provided 'org.springframework.boot:spring-boot-starter-tomcat'
providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
}
war {
baseName = 'SpringBoot1'
}
I am also including console output messages:
:: Spring Boot :: (v2.0.3.RELEASE)
2018-07-06 20:50:49.322 INFO 3489 --- [ restartedMain] c.r.SpringBoot1.SpringBoot1Application : Starting SpringBoot1Application on Rana-Depto-MacBook-Pro.local with PID 3489 (/Users/ranadepto/Desktop/SpringBoot1/out/production/classes started by ranadepto in /Users/ranadepto/Desktop/SpringBoot1)
2018-07-06 20:50:49.324 INFO 3489 --- [ restartedMain] c.r.SpringBoot1.SpringBoot1Application : No active profile set, falling back to default profiles: default
2018-07-06 20:50:49.375 INFO 3489 --- [ restartedMain] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#7acf6bce: startup date [Fri Jul 06 20:50:49 BDT 2018]; root of context hierarchy
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/Users/ranadepto/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/5.0.7.RELEASE/54b731178d81e66eca9623df772ff32718208137/spring-core-5.0.7.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2018-07-06 20:50:50.215 INFO 3489 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$f69149ff] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-07-06 20:50:50.461 INFO 3489 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2018-07-06 20:50:50.476 INFO 3489 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-07-06 20:50:50.477 INFO 3489 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.31
2018-07-06 20:50:50.480 INFO 3489 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/Users/ranadepto/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
2018-07-06 20:50:50.527 INFO 3489 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-07-06 20:50:50.527 INFO 3489 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1157 ms
2018-07-06 20:50:50.612 INFO 3489 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2018-07-06 20:50:50.615 INFO 3489 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-07-06 20:50:50.615 INFO 3489 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-07-06 20:50:50.615 INFO 3489 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-07-06 20:50:50.615 INFO 3489 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-07-06 20:50:50.710 INFO 3489 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2018-07-06 20:50:50.841 INFO 3489 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2018-07-06 20:50:50.866 INFO 3489 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2018-07-06 20:50:50.873 INFO 3489 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2018-07-06 20:50:50.908 INFO 3489 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate Core {5.2.17.Final}
2018-07-06 20:50:50.909 INFO 3489 --- [ restartedMain] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2018-07-06 20:50:50.931 INFO 3489 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2018-07-06 20:50:50.995 INFO 3489 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
2018-07-06 20:50:51.305 INFO 3489 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2018-07-06 20:50:51.523 INFO 3489 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-07-06 20:50:51.682 INFO 3489 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#7acf6bce: startup date [Fri Jul 06 20:50:49 BDT 2018]; root of context hierarchy
2018-07-06 20:50:51.700 WARN 3489 --- [ restartedMain] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2018-07-06 20:50:51.722 INFO 3489 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/reports],methods=[GET]}" onto public java.util.List<com.ranadepto.SpringBoot1.ReportModel> com.ranadepto.SpringBoot1.ReportController.getAllReports()
2018-07-06 20:50:51.723 INFO 3489 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/reports/{id}],methods=[GET]}" onto public com.ranadepto.SpringBoot1.ReportModel com.ranadepto.SpringBoot1.ReportController.getReportById(java.lang.String)
2018-07-06 20:50:51.724 INFO 3489 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/reports],methods=[POST]}" onto public com.ranadepto.SpringBoot1.ReportModel com.ranadepto.SpringBoot1.ReportController.createReport(com.ranadepto.SpringBoot1.ReportModel)
2018-07-06 20:50:51.724 INFO 3489 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/reports/{id}],methods=[PUT]}" onto public com.ranadepto.SpringBoot1.ReportModel com.ranadepto.SpringBoot1.ReportController.updateReport(java.lang.String,com.ranadepto.SpringBoot1.ReportModel)
2018-07-06 20:50:51.724 INFO 3489 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/reports/{id}],methods=[DELETE]}" onto public org.springframework.http.ResponseEntity<?> com.ranadepto.SpringBoot1.ReportController.deleteReport(java.lang.String)
2018-07-06 20:50:51.726 INFO 3489 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-07-06 20:50:51.726 INFO 3489 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-07-06 20:50:51.746 INFO 3489 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-07-06 20:50:51.746 INFO 3489 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-07-06 20:50:51.921 INFO 3489 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2018-07-06 20:50:51.942 INFO 3489 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-07-06 20:50:51.943 INFO 3489 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'dataSource' has been autodetected for JMX exposure
2018-07-06 20:50:51.947 INFO 3489 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Located MBean 'dataSource': registering with JMX server as MBean [com.zaxxer.hikari:name=dataSource,type=HikariDataSource]
2018-07-06 20:50:51.972 INFO 3489 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2018-07-06 20:50:51.976 INFO 3489 --- [ restartedMain] c.r.SpringBoot1.SpringBoot1Application : Started SpringBoot1Application in 2.93 seconds (JVM running for 3.809)
And finally this is a screenshot of IntelliJ directory hierarchy:
I have been spending for hour on debugging and searching on the web and finally ended up here with a question. Please help me out with how can I get rid of this.

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure AND BeanEntityManager error

Have had to cut the first error message quite abit since it contained to many characters, but the full thing can be found here: https://github.com/kableiv/FullSpringError
Bit of backstory:
Completing an assignment and need to create a small website where 2 predefined users can login, one with user privileges and one with admin, the privileges are buttons that redirect you to pages where you edit, delete and register new info. At first I did it without spring security and no database, using arraylists and files. When I logged in with the user it only had the user privileges like it was supposed to, however when I logged in with the admin and then went onto any of the other html pages like the one used to edit something and then clicked on the return button, the admin privileges were gone. Im assuming this was because i, in my method to login, sat its admin value to true(so the html page knew what to display and what not to) and then when that method was done and a new one was starting like the editing method the value was back to null.
Because of this I decided to try and switch to using a MySQL database with spring security.
My IDE of choice is intellij ultimate and I used MySQL Workbench to setup the database and added it into intellij using the database feature.
Now when trying to run the project i get the following error:
2018-05-04 16:59:10.780 INFO 8364 --- [ main] com.rfboernehave.demo.DemoApplication : Starting DemoApplication on DESKTOP-QB8IIQF with PID 8364 (C:\Users\nerdi\SpringbootWebAppMiniproject1\target\classes started by nerdi in C:\Users\nerdi\SpringbootWebAppMiniproject1)
2018-05-04 16:59:10.783 INFO 8364 --- [ main] com.rfboernehave.demo.DemoApplication : No active profile set, falling back to default profiles: default
2018-05-04 16:59:11.390 INFO 8364 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#516be40f: startup date [Fri May 04 16:59:11 CEST 2018]; root of context hierarchy
2018-05-04 16:59:14.723 INFO 8364 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 5000 (http)
2018-05-04 16:59:14.747 INFO 8364 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-05-04 16:59:14.747 INFO 8364 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.16
2018-05-04 16:59:15.021 INFO 8364 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-05-04 16:59:15.021 INFO 8364 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3638 ms
2018-05-04 16:59:15.343 INFO 8364 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-05-04 16:59:15.343 INFO 8364 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-05-04 16:59:15.343 INFO 8364 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-05-04 16:59:15.343 INFO 8364 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-05-04 16:59:15.343 INFO 8364 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2018-05-04 16:59:15.347 INFO 8364 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2018-05-04 16:59:18.235 ERROR 8364 --- [ main] o.a.tomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425) ~[mysql-connector-java-5.1.43.jar:5.1.43]
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:989) ~[mysql-connector-java-5.1.43.jar:5.1.43]
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:341) ~[mysql-connector-java-5.1.43.jar:5.1.43]
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2196) ~[mysql-connector-java-5.1.43.jar:5.1.43]
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2229) ~[mysql-connector-java-5.1.43.jar:5.1.43]
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2024) ~[mysql-connector-java-5.1.43.jar:5.1.43]
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:779) ~[mysql-connector-java-5.1.43.jar:5.1.43]
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47) ~[mysql-connector-java-5.1.43.jar:5.1.43]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425) ~[mysql-connector-java-5.1.43.jar:5.1.43]
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:389) ~[mysql-connector-java-5.1.43.jar:5.1.43]
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330) ~[mysql-connector-java-5.1.43.jar:5.1.43]
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:310) ~[tomcat-jdbc-8.5.16.jar:na]
at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:203) ~[tomcat-jdbc-8.5.16.jar:na]
at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:735) [tomcat-jdbc-8.5.16.jar:na]
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:667) [tomcat-jdbc-8.5.16.jar:na]
at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:482) [tomcat-jdbc-8.5.16.jar:na]
at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:154) [tomcat-jdbc-8.5.16.jar:na]
at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:118) [tomcat-jdbc-8.5.16.jar:na]
at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:107) [tomcat-jdbc-8.5.16.jar:na]
at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:131) [tomcat-jdbc-8.5.16.jar:na]
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111) [spring-jdbc-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77) [spring-jdbc-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:326) [spring-jdbc-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:366) [spring-jdbc-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.boot.autoconfigure.orm.jpa.DatabaseLookup.getDatabase(DatabaseLookup.java:72) [spring-boot-autoconfigure-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.autoconfigure.orm.jpa.JpaProperties.determineDatabase(JpaProperties.java:139) [spring-boot-autoconfigure-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.jpaVendorAdapter(JpaBaseConfiguration.java:105) [spring-boot-autoconfigure-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration$$EnhancerBySpringCGLIB$$e4aac97b.CGLIB$jpaVendorAdapter$5(<generated>) [spring-boot-autoconfigure-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration$$EnhancerBySpringCGLIB$$e4aac97b$$FastClassBySpringCGLIB$$6844864e.invoke(<generated>) [spring-boot-autoconfigure-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) [spring-core-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358) [spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1078) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:857) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at com.rfboernehave.demo.DemoApplication.main(DemoApplication.java:10) [classes/:na]
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) ~[spring-orm-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:353) ~[spring-orm-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:370) ~[spring-orm-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:359) ~[spring-orm-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
NOW I have tried adding hibernating dependencies:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.1.4.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.2.3.Final</version>
</dependency>
Which gave me this other error instead:
:: Spring Boot :: (v1.5.6.RELEASE)
2018-05-04 16:36:20.358 INFO 19272 --- [ main] com.rfboernehave.demo.DemoApplication : Starting DemoApplication on DESKTOP-QB8IIQF with PID 19272 (C:\Users\nerdi\SpringbootWebAppMiniproject1\target\classes started by nerdi in C:\Users\nerdi\SpringbootWebAppMiniproject1)
2018-05-04 16:36:20.358 INFO 19272 --- [ main] com.rfboernehave.demo.DemoApplication : No active profile set, falling back to default profiles: default
2018-05-04 16:36:21.064 INFO 19272 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#77be656f: startup date [Fri May 04 16:36:21 CEST 2018]; root of context hierarchy
2018-05-04 16:36:23.488 INFO 19272 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 5000 (http)
2018-05-04 16:36:23.501 INFO 19272 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-05-04 16:36:23.501 INFO 19272 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.16
2018-05-04 16:36:23.722 INFO 19272 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-05-04 16:36:23.722 INFO 19272 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2658 ms
2018-05-04 16:36:23.935 INFO 19272 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-05-04 16:36:23.935 INFO 19272 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-05-04 16:36:23.935 INFO 19272 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-05-04 16:36:23.935 INFO 19272 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-05-04 16:36:23.938 INFO 19272 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2018-05-04 16:36:23.939 INFO 19272 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2018-05-04 16:36:24.010 WARN 19272 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'homeController' defined in file [C:\Users\nerdi\SpringbootWebAppMiniproject1\target\classes\com\rfboernehave\demo\controller\HomeController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'brugerServiceImpl' defined in file [C:\Users\nerdi\SpringbootWebAppMiniproject1\target\classes\com\rfboernehave\demo\services\BrugerServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'brugerRepository': Cannot create inner bean '(inner bean)#703feacd' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#703feacd': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available
2018-05-04 16:36:24.012 INFO 19272 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2018-05-04 16:36:24.036 INFO 19272 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-05-04 16:36:24.114 ERROR 19272 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in com.rfboernehave.demo.services.BrugerServiceImpl required a bean named 'entityManagerFactory' that could not be found.
Action:
Consider defining a bean named 'entityManagerFactory' in your configuration.
NOW I also got rid of this thing(not sure if did it correctly though) but it gave me a similair error but asking me to define a bean of type package. I decided to remove the dependencies and are therefore currently sitting with the first error of the post.
Below is my current pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.rfboernhave</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<org.springframework.security.version>3.2.3.RELEASE</org.springframework.security.version>
<org.springframework.version>4.0.4.RELEASE</org.springframework.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.7</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml</groupId>
<artifactId>oss-parent</artifactId>
<version>27</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>2.0.1.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
My application.properties:
server.port=5000
spring.datasource.url=jdbc:mysql://localhost:5000/test_db
spring.datasource.username=root
spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
My Config.java class:
package com.rfboernehave.demo.Security;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import javax.sql.DataSource;
#Configuration
#EnableWebSecurity
public class Config extends WebSecurityConfigurerAdapter {
#Autowired
DataSource dataSource;
#Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception{
auth.jdbcAuthentication().dataSource(dataSource)
.usersByUsernameQuery("select username, password from user where username=?")
.authoritiesByUsernameQuery("select username, rolle from user where username=?");
}
#Override
protected void configure(HttpSecurity http) throws Exception{
http
.authorizeRequests()
.antMatchers("/login*").anonymous()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.defaultSuccessUrl("/home")
.and()
.logout().logoutSuccessUrl("/login");
}
}
My entity(MyUser) class : I apologize for the variables being in a foreign language quick translation:
MinBruger is (MyUser)
brugernavn is (username)
adgangskode is (password)
rolle is (role)
package com.rfboernehave.demo.domains;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
#Entity
public class MinBruger {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private String brugernavn;
private String adgangskode;
private String rolle;
private int id;
public MinBruger() {
}
public MinBruger(int id, String brugernavn, String adgangskode, String rolle) {
this.id = id;
this.brugernavn = brugernavn;
this.adgangskode = adgangskode;
this.rolle = rolle;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getBrugernavn() {
return brugernavn;
}
public void setBrugernavn(String brugernavn) {
this.brugernavn = brugernavn;
}
public String getAdgangskode() {
return adgangskode;
}
public void setAdgangskode(String adgangskode) {
this.adgangskode = adgangskode;
}
public String getRolle(){return rolle;}
public void setRolle(String rolle) {
this.rolle = rolle;
}
#Override
public String toString() {
return "MinBruger{" +
"id=" + id +
", brugernavn='" + brugernavn + '\'' +
", adgangskode='" + adgangskode + '\'' +
", rolle=" + rolle + '\'' +
'}';
}
Below is my UserRepository:
Translation:
BrugerRepository is (UserRepository)
package com.rfboernehave.demo.repositories;
import com.rfboernehave.demo.domains.MinBruger;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
#Repository
public interface BrugerRepository extends CrudRepository<MinBruger, String> {
}
How can I fix this?
Thx in Advance.
UPDATE: Ok so I sat the property:
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
Aside from that I also changed the following:
spring.datasource.url=jdbc:mysql://localhost:3306/
TO:
spring.datasource.url=jdbc:mysql://localhost:3306/test_db?useSSL=false
This seemed to do part of the trick, my project now runs, however a new problem arisen, when trying to login it fails and sets the url from: http://localhost:5000/login
TO: http://localhost:5000/login?error
Below is my HomeController.java:
package com.rfboernehave.demo.controller;
import com.rfboernehave.demo.domains.Barn;
import com.rfboernehave.demo.domains.MinBruger;
import com.rfboernehave.demo.services.BarnServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import java.io.FileNotFoundException;
import java.util.ArrayList;
#Controller
public class HomeController {
private final Logger log = LoggerFactory.getLogger(this.getClass());
#Autowired
private BarnServiceImpl barnService;
public HomeController() {
}
#RequestMapping(value = {"", "/", "index"}, method = RequestMethod.GET)
public String index() {
log.info("index method called...");
return "login";
}
#RequestMapping(value = "/login", method = RequestMethod.GET)
public String login() {
log.info("login method called with: ");
if (SecurityContextHolder.getContext().getAuthentication().getAuthorities().contains(new SimpleGrantedAuthority("admin"))) {
return "redirect:/home";
}
return "login";
}
//
//
#RequestMapping(value = "/home", method = RequestMethod.GET)
public String home(Model model) {
log.info("home action called...");
model.addAttribute("boern", barnService.hentAlleBoern());
log.info("home action ended...");
return "home";
}
#GetMapping("/registrer")
public String registrer(Model model) {
log.info("registrer action called...");
model.addAttribute("barn", new Barn());
return "registrer";
}
#PostMapping("/registrer")
public String registrer(#ModelAttribute Barn barn, Model model) throws FileNotFoundException {
log.info("registrer post action called...");
String home = Integer.toString(barnService.hentAlleBoern().size());
barn.setId(Integer.parseInt(home));
barnService.hentAlleBoern().add(barn);
barnService.printToFile();
model.addAttribute("boern", barnService.hentAlleBoern());
return "/home";
}
#GetMapping("/detaljer/{id}")
public String detaljer(#PathVariable("id") int id, Model model) {
log.info("detaljer action called...");
Barn lille = null;
for (Barn barn : barnService.hentAlleBoern()) {
if (barn.getId() == id) {
lille = barn;
break;
}
}
model.addAttribute("barn", lille);
model.addAttribute("boern", barnService.hentAlleBoern());
return "detaljer";
}
#GetMapping("/afmeld/{id}")
public String afmeld(#PathVariable("id") int id, Model model) {
log.info("afmeld action called...");
model.addAttribute("barn",barnService.hentAlleBoern().get(id));
model.addAttribute("boern", barnService.hentAlleBoern());
return "afmeld";
}
#PostMapping("/afmeld")
public String afmeld(#ModelAttribute Barn barn, Model model) throws FileNotFoundException {
log.info("afmeld post action called...");
int id = barn.getId();
barnService.hentAlleBoern().remove(barn.getId());
leftShiftId(barnService.hentAlleBoern(), id);
barnService.printToFile();
model.addAttribute("boern", barnService.hentAlleBoern());
return "/home";
}
#GetMapping("/rediger/{id}")
public String rediger(#PathVariable("id") int id, Model model) {
log.info("rediger action called...");
model.addAttribute("barn", barnService.hentAlleBoern().get(id));
model.addAttribute("boern", barnService.hentAlleBoern());
return "rediger";
}
#PostMapping("/rediger")
public String rediger(#ModelAttribute Barn barn, Model model) throws FileNotFoundException {
log.info("rediger post action called...");
for (int i = 0; i < barnService.hentAlleBoern().size(); i++) {
if (barn.getId() == barnService.hentAlleBoern().get(i).getId()) {
barnService.hentAlleBoern().set(i, barn);
break;
}
}
barnService.printToFile();
model.addAttribute("boern", barnService.hentAlleBoern());
return "/home";
}
private void leftShiftId(ArrayList<Barn> list, int id) {
log.info("leftshift method called...");
for (int i = id; i < list.size(); i++) {
Barn barn = list.get(i);
barn.setId(barn.getId() - 1);
}
}
}
Below is the terminal output:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.6.RELEASE)
2018-05-08 13:18:32.979 INFO 1872 --- [ main] com.rfboernehave.demo.DemoApplication : Starting DemoApplication on DESKTOP-QB8IIQF with PID 1872 (C:\Users\nerdi\SpringbootWebAppMiniproject1\target\classes started by nerdi in C:\Users\nerdi\SpringbootWebAppMiniproject1)
2018-05-08 13:18:32.982 INFO 1872 --- [ main] com.rfboernehave.demo.DemoApplication : No active profile set, falling back to default profiles: default
2018-05-08 13:18:33.671 INFO 1872 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#516be40f: startup date [Tue May 08 13:18:33 CEST 2018]; root of context hierarchy
2018-05-08 13:18:36.652 INFO 1872 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 5000 (http)
2018-05-08 13:18:36.666 INFO 1872 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-05-08 13:18:36.667 INFO 1872 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.16
2018-05-08 13:18:36.878 INFO 1872 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-05-08 13:18:36.878 INFO 1872 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3210 ms
2018-05-08 13:18:37.170 INFO 1872 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-05-08 13:18:37.170 INFO 1872 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-05-08 13:18:37.170 INFO 1872 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-05-08 13:18:37.170 INFO 1872 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-05-08 13:18:37.172 INFO 1872 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2018-05-08 13:18:37.172 INFO 1872 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2018-05-08 13:18:37.907 INFO 1872 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2018-05-08 13:18:37.929 INFO 1872 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2018-05-08 13:18:38.204 INFO 1872 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final}
2018-05-08 13:18:38.205 INFO 1872 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2018-05-08 13:18:38.207 INFO 1872 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2018-05-08 13:18:38.256 INFO 1872 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2018-05-08 13:18:38.425 INFO 1872 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2018-05-08 13:18:39.001 INFO 1872 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2018-05-08 13:18:39.571 INFO 1872 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher#1, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#11b5f4e2, org.springframework.security.web.context.SecurityContextPersistenceFilter#33e0c716, org.springframework.security.web.header.HeaderWriterFilter#634ca3e7, org.springframework.security.web.csrf.CsrfFilter#6ee88e21, org.springframework.security.web.authentication.logout.LogoutFilter#d653e41, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#17222c11, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#6274f21c, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#12952aff, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#6bcae9, org.springframework.security.web.session.SessionManagementFilter#b14b60a, org.springframework.security.web.access.ExceptionTranslationFilter#50b734c4, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#67688110]
2018-05-08 13:18:40.196 INFO 1872 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#516be40f: startup date [Tue May 08 13:18:33 CEST 2018]; root of context hierarchy
2018-05-08 13:18:40.337 INFO 1872 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[ || / || /index],methods=[GET]}" onto public java.lang.String com.rfboernehave.demo.controller.HomeController.index()
2018-05-08 13:18:40.338 INFO 1872 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/home],methods=[GET]}" onto public java.lang.String com.rfboernehave.demo.controller.HomeController.home(org.springframework.ui.Model)
2018-05-08 13:18:40.339 INFO 1872 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/rediger],methods=[POST]}" onto public java.lang.String com.rfboernehave.demo.controller.HomeController.rediger(com.rfboernehave.demo.domains.Barn,org.springframework.ui.Model) throws java.io.FileNotFoundException
2018-05-08 13:18:40.339 INFO 1872 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/rediger/{id}],methods=[GET]}" onto public java.lang.String com.rfboernehave.demo.controller.HomeController.rediger(int,org.springframework.ui.Model)
2018-05-08 13:18:40.340 INFO 1872 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/detaljer/{id}],methods=[GET]}" onto public java.lang.String com.rfboernehave.demo.controller.HomeController.detaljer(int,org.springframework.ui.Model)
2018-05-08 13:18:40.341 INFO 1872 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/login],methods=[GET]}" onto public java.lang.String com.rfboernehave.demo.controller.HomeController.login()
2018-05-08 13:18:40.342 INFO 1872 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/registrer],methods=[POST]}" onto public java.lang.String com.rfboernehave.demo.controller.HomeController.registrer(com.rfboernehave.demo.domains.Barn,org.springframework.ui.Model) throws java.io.FileNotFoundException
2018-05-08 13:18:40.342 INFO 1872 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/registrer],methods=[GET]}" onto public java.lang.String com.rfboernehave.demo.controller.HomeController.registrer(org.springframework.ui.Model)
2018-05-08 13:18:40.343 INFO 1872 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/afmeld],methods=[POST]}" onto public java.lang.String com.rfboernehave.demo.controller.HomeController.afmeld(com.rfboernehave.demo.domains.Barn,org.springframework.ui.Model) throws java.io.FileNotFoundException
2018-05-08 13:18:40.344 INFO 1872 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/afmeld/{id}],methods=[GET]}" onto public java.lang.String com.rfboernehave.demo.controller.HomeController.afmeld(int,org.springframework.ui.Model)
2018-05-08 13:18:40.347 INFO 1872 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-05-08 13:18:40.348 INFO 1872 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-05-08 13:18:40.398 INFO 1872 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-05-08 13:18:40.400 INFO 1872 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-05-08 13:18:40.477 INFO 1872 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-05-08 13:18:41.111 INFO 1872 --- [ main] b.a.s.AuthenticationManagerConfiguration :
Using default security password: 4f2b3afb-8328-4fa1-a16c-e16003f15618
2018-05-08 13:18:41.294 INFO 1872 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-05-08 13:18:41.396 INFO 1872 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 5000 (http)
2018-05-08 13:18:41.403 INFO 1872 --- [ main] com.rfboernehave.demo.DemoApplication : Started DemoApplication in 8.91 seconds (JVM running for 9.612)

Spring Boot Failing to Start Correctly [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
My Spring Boot application is failing at startup, with the log below. What does this mean?
I'm using Hibernate Core v5.0.11.Final.
<pre>
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.4.1.RELEASE)
2016-09-27 02:55:31.899 INFO 5329 --- [ main] c.t.application.TaqnihomeApplication : Starting TaqnihomeApplication on Songlines-MacBook-Air.local with PID 5329 (/Users/songline/Downloads/assignment-2/target/classes started by songline in /Users/songline/Downloads/assignment-2)
2016-09-27 02:55:31.904 INFO 5329 --- [ main] c.t.application.TaqnihomeApplication : No active profile set, falling back to default profiles: default
2016-09-27 02:55:32.092 INFO 5329 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#7722c3c3: startup date [Tue Sep 27 02:55:32 IST 2016]; root of context hierarchy
2016-09-27 02:55:33.792 INFO 5329 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'dataSource' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Generic; factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Generic.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari; factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]]
2016-09-27 02:55:34.412 INFO 5329 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$8ec63a75] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-09-27 02:55:35.085 INFO 5329 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2016-09-27 02:55:35.103 INFO 5329 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2016-09-27 02:55:35.104 INFO 5329 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.5
2016-09-27 02:55:35.280 INFO 5329 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2016-09-27 02:55:35.280 INFO 5329 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3192 ms
2016-09-27 02:55:35.492 INFO 5329 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2016-09-27 02:55:35.497 INFO 5329 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-09-27 02:55:35.498 INFO 5329 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2016-09-27 02:55:35.498 INFO 5329 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2016-09-27 02:55:35.498 INFO 5329 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2016-09-27 02:55:35.798 INFO 5329 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2016-09-27 02:55:35.818 INFO 5329 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2016-09-27 02:55:35.917 INFO 5329 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.11.Final}
2016-09-27 02:55:35.919 INFO 5329 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2016-09-27 02:55:35.921 INFO 5329 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2016-09-27 02:55:35.990 INFO 5329 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2016-09-27 02:55:36.268 INFO 5329 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Started.
2016-09-27 02:55:36.528 INFO 5329 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
2016-09-27 02:55:37.223 INFO 5329 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000228: Running hbm2ddl schema update
2016-09-27 02:55:37.266 INFO 5329 --- [ main] rmationExtractorJdbcDatabaseMetaDataImpl : HHH000262: Table not found: game_library
2016-09-27 02:55:37.363 WARN 5329 --- [ main] ationConfigEmbeddedWebApplicationContext : 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/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
2016-09-27 02:55:37.364 INFO 5329 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Close initiated...
2016-09-27 02:55:37.370 INFO 5329 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Closed.
2016-09-27 02:55:37.372 INFO 5329 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat
2016-09-27 02:55:37.390 INFO 5329 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2016-09-27 02:55:37.398 ERROR 5329 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1583) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1076) ~[spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:851) ~[spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) ~[spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at com.taqnihome.application.TaqnihomeApplication.main(TaqnihomeApplication.java:34) [classes/:na]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:954) ~[hibernate-entitymanager-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:882) ~[hibernate-entitymanager-5.0.11.Final.jar:5.0.11.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) ~[spring-orm-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:353) ~[spring-orm-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:373) ~[spring-orm-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:362) ~[spring-orm-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1642) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1579) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
... 16 common frames omitted
Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Unable to execute schema management to JDBC target [alter table game_library add column game_id varchar(255) not null]
at org.hibernate.tool.schema.internal.TargetDatabaseImpl.accept(TargetDatabaseImpl.java:59) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlString(SchemaMigratorImpl.java:431) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlStrings(SchemaMigratorImpl.java:449) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.tool.schema.internal.SchemaMigratorImpl.migrateTable(SchemaMigratorImpl.java:253) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigrationToTargets(SchemaMigratorImpl.java:170) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration(SchemaMigratorImpl.java:60) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:134) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:101) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:472) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879) ~[hibernate-entitymanager-5.0.11.Final.jar:5.0.11.Final]
... 22 common frames omitted
Caused by: java.sql.SQLSyntaxErrorException: Table 'testingjpa.game_library' doesn't exist
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:686) ~[mysql-connector-java-6.0.3.jar:6.0.3]
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:663) ~[mysql-connector-java-6.0.3.jar:6.0.3]
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:653) ~[mysql-connector-java-6.0.3.jar:6.0.3]
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:115) ~[mysql-connector-java-6.0.3.jar:6.0.3]
at com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2041) ~[mysql-connector-java-6.0.3.jar:6.0.3]
at com.mysql.cj.jdbc.StatementImpl.executeUpdateInternal(StatementImpl.java:1608) ~[mysql-connector-java-6.0.3.jar:6.0.3]
at com.mysql.cj.jdbc.StatementImpl.executeLargeUpdate(StatementImpl.java:2630) ~[mysql-connector-java-6.0.3.jar:6.0.3]
at com.mysql.cj.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1534) ~[mysql-connector-java-6.0.3.jar:6.0.3]
at com.zaxxer.hikari.pool.ProxyStatement.executeUpdate(ProxyStatement.java:120) ~[HikariCP-2.4.7.jar:na]
at com.zaxxer.hikari.pool.HikariProxyStatement.executeUpdate(HikariProxyStatement.java) ~[HikariCP-2.4.7.jar:na]
at org.hibernate.tool.schema.internal.TargetDatabaseImpl.accept(TargetDatabaseImpl.java:56) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
... 32 common frames omitted
</pre>
Log TLDR;
HHH000228: Running hbm2ddl schema update
HHH000262: Table not found: game_library
GameLibrary class:
#Entity
#Table(name = "game_library")
public class GameLibrary {
#Id
#Column(name = "game_id")
private String gameId;
#Column(name = "game_name")
private String gameName;
#Column(name = "game_genre")
private String gameGenre;
#ManyToOne
#JoinColumn(name = "game_category", nullable = false)
private GameCategory gameCategory;
#Column(name = "game_version")
private String gameVersion;
#Column(name = "game_publiher")
private String gamePublisher;
#Column(name = "game_studio")
private String gameStudio;
#Column(name = "game_release_date")
private Long gameReleaseDate;
#Column
private Double gameRating;
#Column
private String gamePlatform;
#Column
private Long creationDate;
#Column
private String googlePlayUrl;
#Column
private Long approvedDate;
#Column
private Boolean isApproved;
#Column
private String packageName;
#ManyToMany(mappedBy = "gameLibrary", cascade = CascadeType.ALL)
private List<GameProfile> gameProfiles;
// getters and setters
}
new log when update change with create field value ddl-auto
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.4.1.RELEASE)
2016-09-27 12:47:50.815 INFO 5812 --- [ main] c.t.application.TaqnihomeApplication : Starting TaqnihomeApplication on Songlines-MacBook-Air.local with PID 5812 (/Users/songline/Downloads/assignment-2/target/classes started by songline in /Users/songline/Downloads/assignment-2)
2016-09-27 12:47:50.818 INFO 5812 --- [ main] c.t.application.TaqnihomeApplication : No active profile set, falling back to default profiles: default
2016-09-27 12:47:50.939 INFO 5812 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#7722c3c3: startup date [Tue Sep 27 12:47:50 IST 2016]; root of context hierarchy
2016-09-27 12:47:52.624 INFO 5812 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'dataSource' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Generic; factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Generic.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari; factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]]
2016-09-27 12:47:53.213 INFO 5812 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$8ec63a75] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-09-27 12:47:53.853 INFO 5812 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2016-09-27 12:47:53.874 INFO 5812 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2016-09-27 12:47:53.876 INFO 5812 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.5
2016-09-27 12:47:54.085 INFO 5812 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2016-09-27 12:47:54.085 INFO 5812 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3153 ms
2016-09-27 12:47:54.275 INFO 5812 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2016-09-27 12:47:54.281 INFO 5812 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-09-27 12:47:54.281 INFO 5812 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2016-09-27 12:47:54.282 INFO 5812 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2016-09-27 12:47:54.282 INFO 5812 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2016-09-27 12:47:54.529 INFO 5812 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2016-09-27 12:47:54.552 INFO 5812 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2016-09-27 12:47:54.640 INFO 5812 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.11.Final}
2016-09-27 12:47:54.642 INFO 5812 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2016-09-27 12:47:54.644 INFO 5812 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2016-09-27 12:47:54.691 INFO 5812 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2016-09-27 12:47:54.965 INFO 5812 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Started.
2016-09-27 12:47:55.253 INFO 5812 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
2016-09-27 12:47:56.049 INFO 5812 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export
2016-09-27 12:47:56.441 INFO 5812 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete
2016-09-27 12:47:56.489 INFO 5812 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2016-09-27 12:47:57.575 INFO 5812 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/login],methods=[POST]}" onto public org.springframework.http.ResponseEntity com.taqnihome.controller.HomeController.login(com.taqnihome.domain.User)
2016-09-27 12:47:57.577 INFO 5812 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/signup],methods=[POST]}" onto public org.springframework.http.ResponseEntity com.taqnihome.controller.HomeController.saveData(com.taqnihome.domain.User)
2016-09-27 12:47:57.577 INFO 5812 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/search],methods=[POST]}" onto public org.springframework.http.ResponseEntity com.taqnihome.controller.HomeController.checkMacAddress(com.taqnihome.domain.User)
2016-09-27 12:47:57.577 INFO 5812 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/addGameToProfile],methods=[POST]}" onto public org.springframework.http.ResponseEntity com.taqnihome.controller.HomeController.addGameToProfile(com.taqnihome.domain.GameProfile)
2016-09-27 12:47:57.578 INFO 5812 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/updateGameToProfile],methods=[PUT]}" onto public org.springframework.http.ResponseEntity com.taqnihome.controller.HomeController.updateGameToProfile(com.taqnihome.domain.GameProfile)
2016-09-27 12:47:57.578 INFO 5812 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/addGameRequestToLibrary],methods=[POST]}" onto public org.springframework.http.ResponseEntity com.taqnihome.controller.HomeController.addGameRequestToLibrary(java.lang.String,java.lang.String)
2016-09-27 12:47:57.578 INFO 5812 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/getAllLibraryGames],methods=[GET]}" onto public org.springframework.http.ResponseEntity com.taqnihome.controller.HomeController.getAllGames()
2016-09-27 12:47:57.578 INFO 5812 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/getGameProfileByUser],methods=[GET]}" onto public org.springframework.http.ResponseEntity com.taqnihome.controller.HomeController.getAllProfileGames(com.taqnihome.domain.User)
2016-09-27 12:47:57.579 INFO 5812 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/v2/api-docs],methods=[GET],produces=[application/json || application/hal+json]}" onto public org.springframework.http.ResponseEntity springfox.documentation.swagger2.web.Swagger2Controller.getDocumentation(java.lang.String,javax.servlet.http.HttpServletRequest)
2016-09-27 12:47:57.584 INFO 5812 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/swagger-resources/configuration/ui]}" onto org.springframework.http.ResponseEntity springfox.documentation.swagger.web.ApiResourceController.uiConfiguration()
2016-09-27 12:47:57.590 INFO 5812 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/swagger-resources/configuration/security]}" onto org.springframework.http.ResponseEntity springfox.documentation.swagger.web.ApiResourceController.securityConfiguration()
2016-09-27 12:47:57.591 INFO 5812 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/swagger-resources]}" onto org.springframework.http.ResponseEntity> springfox.documentation.swagger.web.ApiResourceController.swaggerResources()
2016-09-27 12:47:57.595 INFO 5812 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2016-09-27 12:47:57.595 INFO 5812 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2016-09-27 12:47:57.914 INFO 5812 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#7722c3c3: startup date [Tue Sep 27 12:47:50 IST 2016]; root of context hierarchy
2016-09-27 12:47:58.017 INFO 5812 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-09-27 12:47:58.017 INFO 5812 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-09-27 12:47:58.068 INFO 5812 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-09-27 12:47:58.430 INFO 5812 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2016-09-27 12:47:58.437 INFO 5812 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'dataSource' has been autodetected for JMX exposure
2016-09-27 12:47:58.443 INFO 5812 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located MBean 'dataSource': registering with JMX server as MBean [com.zaxxer.hikari:name=dataSource,type=HikariDataSource]
2016-09-27 12:47:58.449 INFO 5812 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 2147483647
2016-09-27 12:47:58.449 INFO 5812 --- [ main] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
2016-09-27 12:47:58.476 INFO 5812 --- [ main] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
2016-09-27 12:47:58.487 INFO 5812 --- [ main] s.d.s.w.s.ApiListingReferenceScanner : Scanning for api listing references
2016-09-27 12:47:58.843 INFO 5812 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2016-09-27 12:47:58.850 INFO 5812 --- [ main] c.t.application.TaqnihomeApplication : Started TaqnihomeApplication in 8.563 seconds (JVM running for 8.995)
Hibernate is pitching a fit because you told it to do this (intentionally or not):
alter table game_library add column game_id varchar(255) not null
However, Table 'testingjpa.game_library' doesn't exist.
Either fix your DB or fix your game_library object definition or mapping.
It's probably gone from your DB, or you're pointing it at a wrong or older DB.
Have a look at the error message that Hibernate is providing you:
java.sql.SQLSyntaxErrorException: Table 'testingjpa.game_library' doesn't exist
You're referring to a table that doesn't yet exist in your database, or that your DB user does not have access to. This is causing Spring to fail when it's setting up your Entity Manager Factory, and ultimately the entire Spring context. The errant SQL statement seems to be:
alter table game_library add column game_id varchar(255) not null
If this is in a schema.sql file, or some other schema configuration file that you're running to setup your database, you'll have to ensure that the table is created correctly before you run this alter statement.
Have a look at the Spring Boot doc on Database initialization. If you're expecting the table to be auto-generated, ensure that you have the spring.jpa.generate-ddl flag set to true in your application.properties file.

Categories