I am just building a new App based on Spring-Boot 2.0.3.RELEASE, Hibernate and Java 9.
Since last night I had some issues for what I just have rebuilt it again to find step by step where the problem is located.
I am constantly facing the same issue and I cannot fix it by myself.
The Error:
2018-07-19 10:32:38.949 INFO 9080 --- [ main] com.tmtest.demo.DemoApplication : Starting DemoApplication on DESKTOP-MKTBJ7O with PID 9080 (D:\Git\test2\target\classes started by N-rG in D:\Git\test2)
2018-07-19 10:32:38.952 INFO 9080 --- [ main] com.tmtest.demo.DemoApplication : No active profile set, falling back to default profiles: default
2018-07-19 10:32:39.012 INFO 9080 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#2c07545f: startup date [Thu Jul 19 10:32:39 CEST 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:/C:/Users/N-rG/.m2/repository/org/springframework/spring-core/5.0.7.RELEASE/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-19 10:32:39.967 INFO 9080 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$53763105] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-07-19 10:32:40.174 INFO 9080 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2018-07-19 10:32:40.198 INFO 9080 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-07-19 10:32:40.198 INFO 9080 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.31
2018-07-19 10:32:40.207 INFO 9080 --- [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: [D:\Program Files\Java\jdk-10.0.1\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS\;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS\;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;D:\Program Files\nodejs\;D:\Program Files\Git\cmd;C:\Users\N-rG\AppData\Local\Programs\Python\Python36-32\Scripts\;C:\Users\N-rG\AppData\Local\Programs\Python\Python36-32\;C:\Users\N-rG\AppData\Local\Microsoft\WindowsApps;C:\Users\N-rG\AppData\Roaming\npm;.]
2018-07-19 10:32:40.279 INFO 9080 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-07-19 10:32:40.279 INFO 9080 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1272 ms
2018-07-19 10:32:40.372 INFO 9080 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-07-19 10:32:40.372 INFO 9080 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-07-19 10:32:40.372 INFO 9080 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-07-19 10:32:40.372 INFO 9080 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-07-19 10:32:40.372 INFO 9080 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2018-07-19 10:32:40.372 INFO 9080 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2018-07-19 10:32:40.467 INFO 9080 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2018-07-19 10:32:40.531 INFO 9080 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2018-07-19 10:32:40.557 INFO 9080 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2018-07-19 10:32:40.566 INFO 9080 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2018-07-19 10:32:40.603 INFO 9080 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.3.2.Final}
2018-07-19 10:32:40.604 INFO 9080 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2018-07-19 10:32:40.650 INFO 9080 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.4.Final}
2018-07-19 10:32:40.727 INFO 9080 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2018-07-19 10:32:40.838 WARN 9080 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.tmtest.demo.Backend.Factory.FactoryWorker.factoryPublisher in com.tmtest.demo.Backend.Factory.FactoryPublisher.factoryWorkerList
2018-07-19 10:32:40.839 INFO 9080 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2018-07-19 10:32:40.849 INFO 9080 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2018-07-19 10:32:40.850 INFO 9080 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2018-07-19 10:32:40.860 INFO 9080 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-07-19 10:32:40.867 ERROR 9080 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.tmtest.demo.Backend.Factory.FactoryWorker.factoryPublisher in com.tmtest.demo.Backend.Factory.FactoryPublisher.factoryWorkerList
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1708) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:581) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1089) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:859) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at com.tmtest.demo.DemoApplication.main(DemoApplication.java:12) [classes/:na]
Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.tmtest.demo.Backend.Factory.FactoryWorker.factoryPublisher in com.tmtest.demo.Backend.Factory.FactoryPublisher.factoryWorkerList
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:782) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:733) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:54) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1696) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1664) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:287) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:904) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:935) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:57) ~[spring-orm-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:390) ~[spring-orm-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:377) ~[spring-orm-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) ~[spring-orm-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1767) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1704) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
... 16 common frames omitted
Process finished with exit code 1
My POM
<?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.tmtest</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>2.0.3.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>10</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</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>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.3.1-1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.0.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.3.2.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.3.2.Final</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
The FactoryPublisher class
#Entity
#Getter
#Setter
#EqualsAndHashCode
public class FactoryPublisher {
#OneToMany(mappedBy = "factoryPublisher", cascade = CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval = true)
private final List<FactoryWorker> factoryWorkerList = new ArrayList<>();
private final VirtualTimer virtualTimer = VirtualTimer.CounterFactory.getNewCounter();
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
public FactoryPublisher() {
for (int i = 0; i < 2; i++) {
factoryWorkerList.add(new FactoryWorker());
}
new Thread(virtualTimer).start();
}
public synchronized void updateWorkers() {
factoryWorkerList.forEach(factoryWorker -> factoryWorker.updateWorker(virtualTimer.getCurrentValue()));
}
}
and the Worker:
#Entity
#Getter
#Setter
public class FactoryWorker {
#GeneratedValue(strategy = GenerationType.AUTO)
#Id
private long iD;
public void updateWorker(final int timeData) {
//System.out.println("worker: " + iD + " was updated with data: " + timeData);
}
}
the main:
#SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
The exception message is giving a hint already:
mappedBy reference an unknown target entity property: com.tmtest.demo.Backend.Factory.FactoryWorker.factoryPublisher in com.tmtest.demo.Backend.Factory.FactoryPublisher.factoryWorkerList
The mappedBy property can be used to define a bi-directional mapping, where you define the relation on one side (eg #ManyToOne) and use the mappedBy property on the other side so it knows how the relation works.
However, in your case you don't have a bi-directional mapping. In fact, you don't have a field called factoryPublisher in your FactoryWorker entity, so it can't resolve your mapping.
To solve this, you want to map the factoryPublisher field within FactoryWorker, for example:
#Entity
#Getter
#Setter
public class FactoryWorker {
#GeneratedValue(strategy = GenerationType.AUTO)
#Id
private long iD;
// Add this
#ManyToOne
private FactoryPublisher factoryPublisher;
// ...
}
Alternatively, if you don't want a bi-directional mapping, you can remove the mappedBy property on #OneToMany.
Related
I try to save object in Postgresql database but unsuccesfully. Application starts normally, no exception is thrown and companiesRepository is not null. The database has been created manually.
This is my Application.class:
#SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
This is my Service.class:
#org.springframework.stereotype.Service
public class Service {
#Autowired
CompaniesRepository companiesRepository;
public void start() {
Companies companies = new Companies();
companies.setSomeString("some");
companies.setId(1);
companiesRepository.save(companies);
log.info("Companies saved in DB");
}
}
This is my Companies.class:
#Entity
#Data
public class Companies {
#GeneratedValue(strategy = GenerationType.IDENTITY)
#Id
Integer id;
String someString;
}
This is my CompaniesRepository interface:
#Repository
public interface CompaniesRepository extends CrudRepository<Companies, Integer> {
}
This is my Controller.class:
#RestController
public class Controller {
#Autowired
private Service service;
#RequestMapping("/")
public String start() throws Exception {
service.start();
return "App Started";
}
}
The configuration I have in bootstrap.yaml file works properly in another project:
spring:
jpa:
database-platform: org.hibernate.dialect.PostgreSQLDialect
show-sql: false
generate-ddl: true
time_zone: UTC
hibernate:
ddl-auto: update
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
hbm2ddl:
auto: update
jdbc:
lob:
non_contextual_creation: true
enable_lazy_load_no_trans: true
datasource:
url: jdbc:postgresql://localhost:5432/dos?createDatabaseIfNotExist=true&serverTimezone=UTC
driver-class-name: org.postgresql.Driver
username: "postgres"
password: "123"
initialization-mode: always
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
jdbc:
time_zone: UTC
I tried to:
annottate String and id in Companies.class with #Column(nullable = false),
changed table name for Companies.class with #Table(name = "some_table").
add #Autowired CompaniesRepository repository; in Controller.class
EDIT:
Those are the console logs:
2020-03-07 15:35:11.620 INFO 2484 --- [ main] com.xtb.tradebot.Application : Starting Application on MWNB00049 with PID 2484 (C:\Users\Piotr\Documents\trade-bot\trade-bot\target\classes started by Piotr in C:\Users\Piotr\Documents\trade-bot\trade-bot)
2020-03-07 15:35:11.622 INFO 2484 --- [ main] com.xtb.tradebot.Application : No active profile set, falling back to default profiles: default
2020-03-07 15:35:12.179 INFO 2484 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-03-07 15:35:12.255 INFO 2484 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 63ms. Found 1 JPA repository interfaces.
2020-03-07 15:35:12.638 INFO 2484 --- [ 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-07 15:35:13.123 INFO 2484 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-03-07 15:35:13.137 INFO 2484 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-03-07 15:35:13.137 INFO 2484 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.30]
2020-03-07 15:35:13.226 INFO 2484 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-03-07 15:35:13.226 INFO 2484 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1563 ms
2020-03-07 15:35:13.390 INFO 2484 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-03-07 15:35:13.673 INFO 2484 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-03-07 15:35:13.735 INFO 2484 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-03-07 15:35:13.830 INFO 2484 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.4.10.Final}
2020-03-07 15:35:13.995 INFO 2484 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-03-07 15:35:14.131 INFO 2484 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2020-03-07 15:35:14.731 INFO 2484 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-03-07 15:35:14.735 INFO 2484 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-03-07 15:35:15.011 WARN 2484 --- [ 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-07 15:35:15.134 INFO 2484 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-03-07 15:35:15.369 INFO 2484 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2020-03-07 15:35:15.371 INFO 2484 --- [ main] com.xtb.tradebot.Application : Started Application in 4.035 seconds (JVM running for 4.357)
Logs after controller "/" endpoint called:
2020-03-07 16:28:40.365 INFO 20336 --- [nio-8080-exec-2] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-03-07 16:28:40.365 INFO 20336 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2020-03-07 16:28:40.374 INFO 20336 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : Completed initialization in 9 ms
This is 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.xtb</groupId>
<artifactId>trade-bot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>trade-bot</name>
<description>trade-bot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I deleted h2.database dependency and I added:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
<version>2.0.2.RELEASE</version>
</dependency>
And I added in bootstrap.yaml:
spring:
main:
allow-bean-definition-overriding: true
And now it works fine.
Spring doesn't create the table specified in my #Entity class in my MySQL database.
I've tried a lot of solutions given here in StackOverflow, like some changes in the application.properties, changing the dialect, setting up the schema etc. I've checked my database permissions and also the user/password information, and it's all fine.
application.properties:
spring.datasource.url=jdbc:mysql://localhost/MyBank?serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.hibernate.ddl-auto=create
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>MyBanc</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>MyBanc</name>
<description>JEE spring boot Web Project by Zied </description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-security</artifactId>-->
<!-- </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.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Client.java
package com.example.entities;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Collection;
#Entity
public class Client implements Serializable {
#Id #GeneratedValue
private long code;
private String nom;
private String email;
#OneToMany(mappedBy = "client",fetch = FetchType.LAZY)
private Collection<Compte> comptes;
public Client() {
super();
}
public Client(String nom, String email) {
super();
this.nom = nom;
this.email = email;
}
public long getCode() {
return code;
}
public void setCode(long code) {
this.code = code;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Collection<Compte> getComptes() {
return comptes;
}
public void setComptes(Collection<Compte> comptes) {
this.comptes = comptes;
}
}
terminal:
2019-12-16 14:24:38.857 INFO 6812 --- [ restartedMain] com.example.MyBank.MyBankApplication : Starting MyBankApplication on DESKTOP-BLK0G7N with PID 6812 (C:\Users\ziedb\OneDrive\Bureau\aa\MyBank\target\classes started by Zied BenOthman in C:\Users\ziedb\OneDrive\Bureau\aa\MyBank)
2019-12-16 14:24:38.862 INFO 6812 --- [ restartedMain] com.example.MyBank.MyBankApplication : No active profile set, falling back to default profiles: default
2019-12-16 14:24:38.935 INFO 6812 --- [ restartedMain] o.s.b.devtools.restart.ChangeableUrls : The Class-Path manifest attribute in C:\Users\ziedb\.m2\repository\org\glassfish\jaxb\jaxb-runtime\2.3.2\jaxb-runtime-2.3.2.jar referenced one or more files that do not exist: file:/C:/Users/ziedb/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/jakarta.xml.bind-api-2.3.2.jar,file:/C:/Users/ziedb/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/txw2-2.3.2.jar,file:/C:/Users/ziedb/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/istack-commons-runtime-3.0.8.jar,file:/C:/Users/ziedb/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/stax-ex-1.8.1.jar,file:/C:/Users/ziedb/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/FastInfoset-1.2.16.jar,file:/C:/Users/ziedb/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/jakarta.activation-api-1.2.1.jar
2019-12-16 14:24:38.936 INFO 6812 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2019-12-16 14:24:38.936 INFO 6812 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2019-12-16 14:24:39.539 INFO 6812 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2019-12-16 14:24:39.557 INFO 6812 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 10ms. Found 0 JPA repository interfaces.
2019-12-16 14:24:39.809 INFO 6812 --- [ restartedMain] 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)
2019-12-16 14:24:40.083 INFO 6812 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-12-16 14:24:40.091 INFO 6812 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-12-16 14:24:40.091 INFO 6812 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.29]
2019-12-16 14:24:40.169 INFO 6812 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-12-16 14:24:40.169 INFO 6812 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1233 ms
2019-12-16 14:24:40.288 INFO 6812 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2019-12-16 14:24:40.346 INFO 6812 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate Core {5.4.9.Final}
2019-12-16 14:24:40.469 INFO 6812 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2019-12-16 14:24:40.627 INFO 6812 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2019-12-16 14:24:40.754 INFO 6812 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2019-12-16 14:24:40.769 INFO 6812 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2019-12-16 14:24:40.977 INFO 6812 --- [ restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2019-12-16 14:24:40.984 INFO 6812 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2019-12-16 14:24:41.019 INFO 6812 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2019-12-16 14:24:41.072 WARN 6812 --- [ restartedMain] 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
2019-12-16 14:24:41.236 INFO 6812 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-12-16 14:24:41.388 WARN 6812 --- [ restartedMain] ion$DefaultTemplateResolverConfiguration : Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration)
2019-12-16 14:24:41.550 INFO 6812 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2019-12-16 14:24:41.553 INFO 6812 --- [ restartedMain] com.example.MyBank.MyBankApplication : Started MyBankApplication in 3.075 seconds (JVM running for 3.971)
Based on the tutorial that I'm following, this setup should result in the creation of the table in the MySQL database, but it doesn't happen.
There are some possible causes for this:
The application.properties file is not in the correct location. It
should be located in src/main/resources
Second problem: The entity class. You should add #Column on top of
the attributes
Move the entity package to become like org.example.entities and run
the app
In spring application you should create one pakcage for the one layer(entity, repository,service ...)
I think you can simplify this to achieve first a JDBC CRUD:
Remove all the unnecessary maven dependencies, only have following to begin with :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- MySQL connector -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- in case you wanna add Junits-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</plugin>
</plugins>
Then have following in your application.properties
spring.datasource.url=jdbc:mysql://localhost:yourMySQLPort/MyBank?serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=
spring.jpa.hibernate.use-new-id-generator-mappings=false
spring.jpa.hibernate.ddl-auto=create
Take care of auto-generation of id of your entity:
#Entity
public class Client implements Serializable {
#Id #GeneratedValue(strategy = GenerationType.AUTO)
private long code;
...
And to keep things simple initially, maintain the Main class i.e Spring boot starter class annotated with #SpringBootApplication in the same package as your entity Client
I've noticed that you haven't mentioned the MySQL server port in your URL, see if thats something that is not initiating the connection. Once you get this sorted, you can add up the rest of the features in your app (thymeleaf based viewing tech etc)
Hope this helps!
I'm trying to develop a Spring Boot application with Iginte Hibernate L2 Cache.
Before I start my Spring Boot application, I run my server node. When I'm trying to run the Spring Boot Application I got the following error:
Output
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.3.RELEASE)
2018-11-28 18:14:50.291 INFO 20868 --- [ main] c.o.apache.ignite.learn.Application : Starting Application on DESKTOP-UNSVMQG with PID 20868 (C:\Users\patri\HibernateL2Cache\target\classes started by patri in C:\Users\patri\HibernateL2Cache)
2018-11-28 18:14:50.293 INFO 20868 --- [ main] c.o.apache.ignite.learn.Application : No active profile set, falling back to default profiles: default
2018-11-28 18:14:50.324 INFO 20868 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#50a638b5: startup date [Wed Nov 28 18:14:50 CET 2018]; root of context hierarchy
2018-11-28 18:14:51.353 INFO 20868 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2018-11-28 18:14:51.365 INFO 20868 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2018-11-28 18:14:51.366 INFO 20868 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.14
2018-11-28 18:14:51.463 INFO 20868 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-11-28 18:14:51.464 INFO 20868 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1142 ms
2018-11-28 18:14:51.565 INFO 20868 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2018-11-28 18:14:51.568 INFO 20868 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-11-28 18:14:51.569 INFO 20868 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-11-28 18:14:51.569 INFO 20868 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-11-28 18:14:51.570 INFO 20868 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-11-28 18:14:52.065 INFO 20868 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2018-11-28 18:14:52.074 INFO 20868 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2018-11-28 18:14:52.123 INFO 20868 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final}
2018-11-28 18:14:52.124 INFO 20868 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2018-11-28 18:14:52.125 INFO 20868 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2018-11-28 18:14:52.159 INFO 20868 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2018-11-28 18:14:52.248 INFO 20868 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2018-11-28 18:14:52.460 WARN 20868 --- [ 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
2018-11-28 18:14:52.536 INFO 20868 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-11-28 18:14:52.543 ERROR 20868 --- [ 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:1628) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1081) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:856) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at com.ontius.apache.ignite.learn.Application.main(Application.java:13) [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.12.Final.jar:5.0.12.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:882) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) ~[spring-orm-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:353) ~[spring-orm-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:370) ~[spring-orm-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:359) ~[spring-orm-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
... 16 common frames omitted
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.spi.CacheImplementor]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:264) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:228) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:207) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.getService(SessionFactoryServiceRegistryImpl.java:68) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:244) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
... 22 common frames omitted
Caused by: org.apache.ignite.IgniteIllegalStateException: Ignite instance with provided name doesn't exist. Did you call Ignition.start(..) to start an Ignite instance? [name=HibernateL2CacheGrid]
at org.apache.ignite.internal.IgnitionEx.grid(IgnitionEx.java:1383) ~[ignite-core-2.6.0.jar:2.6.0]
at org.apache.ignite.Ignition.ignite(Ignition.java:535) ~[ignite-core-2.6.0.jar:2.6.0]
at org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.start(HibernateAccessStrategyFactory.java:112) ~[ignite-hibernate-core-2.6.0.jar:2.6.0]
at org.apache.ignite.cache.hibernate.HibernateRegionFactory.start(HibernateRegionFactory.java:92) ~[ignite-hibernate_5.1-2.6.0.jar:2.6.0]
at org.hibernate.internal.CacheImpl.<init>(CacheImpl.java:49) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:28) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:20) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.initiateService(SessionFactoryServiceRegistryImpl.java:49) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:254) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
... 28 common frames omitted
Process finished with exit code 1
In order to get a better understanding of my code, I list the relvant code snippets below.
CacheConfigurationFactory
public class CacheConfigurationFactory {
public static List<CacheConfiguration> createCacheList() {
List<CacheConfiguration> cacheList = new ArrayList<CacheConfiguration>();
cacheList.add(createTransactionalCache("com.ontius.apache.ignite.learn.model.Person"));
cacheList.add(createAtomicCache("org.hibernate.cache.spi.UpdateTimestampsCache"));
cacheList.add(createAtomicCache("org.hibernate.cache.internal.StandardQueryCache"));
return cacheList;
}
private static CacheConfiguration createAtomicCache(String cacheName) {
CacheConfiguration cacheConfiguration = new CacheConfiguration();
cacheConfiguration.setCacheMode(CacheMode.PARTITIONED);
cacheConfiguration.setAtomicityMode(CacheAtomicityMode.ATOMIC);
cacheConfiguration.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
cacheConfiguration.setName(cacheName);
return cacheConfiguration;
}
private static CacheConfiguration createTransactionalCache(String cacheName) {
CacheConfiguration cacheConfiguration = new CacheConfiguration();
cacheConfiguration.setCacheMode(CacheMode.PARTITIONED);
cacheConfiguration.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
cacheConfiguration.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
cacheConfiguration.setName(cacheName);
return cacheConfiguration;
}
}
ServerConfigurationFactory
public class ServerConfigurationFactory {
public static IgniteConfiguration createConfiguration() {
IgniteConfiguration igniteConfiguration = new IgniteConfiguration();
igniteConfiguration.setClientMode(false);
igniteConfiguration.setIgniteInstanceName("HibernateL2CacheGrid");
igniteConfiguration.setPeerClassLoadingEnabled(true);
TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi();
TcpDiscoveryMulticastIpFinder ipFinder = new TcpDiscoveryMulticastIpFinder();
ipFinder.setAddresses(Arrays.asList("127.0.0.1:47500:47509"));
discoverySpi.setIpFinder(ipFinder);
igniteConfiguration.setDiscoverySpi(discoverySpi);
List<CacheConfiguration> cacheList = CacheConfigurationFactory.createCacheList();
igniteConfiguration.setCacheConfiguration(cacheList.toArray(new CacheConfiguration[cacheList.size()]));
return igniteConfiguration;
}
}
ClientConfigurationFactory
public class ClientConfigurationFactory {
public static IgniteConfiguration createConfiguration() {
IgniteConfiguration igniteConfiguration = new IgniteConfiguration();
igniteConfiguration.setClientMode(true);
igniteConfiguration.setIgniteInstanceName("HibernateL2CacheGrid");
igniteConfiguration.setPeerClassLoadingEnabled(true);
TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi();
TcpDiscoveryMulticastIpFinder ipFinder = new TcpDiscoveryMulticastIpFinder();
ipFinder.setAddresses(Arrays.asList("127.0.0.1:47500:47509"));
discoverySpi.setIpFinder(ipFinder);
igniteConfiguration.setDiscoverySpi(discoverySpi);
List<CacheConfiguration> cacheList = CacheConfigurationFactory.createCacheList();
igniteConfiguration.setCacheConfiguration(cacheList.toArray(new CacheConfiguration[cacheList.size()]));
return igniteConfiguration;
}
}
SessionFactoryConfiguration
#EnableAutoConfiguration
public class SessionFactoryConfiguration {
#Bean
public HibernateJpaSessionFactoryBean sessionFactory(EntityManagerFactory entityManagerFactory) {
HibernateJpaSessionFactoryBean hibernateJpaSessionFactoryBean = new HibernateJpaSessionFactoryBean();
hibernateJpaSessionFactoryBean.setEntityManagerFactory(entityManagerFactory);
return hibernateJpaSessionFactoryBean;
}
}
ServerNodeStartup
public class ServerNodeStartup {
public static void main(String[] args) {
Ignition.start(ServerConfigurationFactory.createConfiguration());
}
}
Application
#SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
#Bean
public IgniteSpringBean igniteInstance() {
IgniteSpringBean igniteSpringBean = new IgniteSpringBean();
igniteSpringBean.setConfiguration(ClientConfigurationFactory.createConfiguration());
return igniteSpringBean;
}
}
application.yml
spring:
application:
name: HibernateL2Cache
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/demo_app?useSSL=false
username: root
password: demo
jpa:
properties:
hibernate:
show_sql: true
generate_statistics: true
cache:
use_query_cache: true
use_second_level_cache: true
region:
factory_class: org.apache.ignite.cache.hibernate.HibernateRegionFactory
org:
apache:
ignite:
hibernate:
ignite_instance_name: HibernateL2CacheGrid
default_access_type: READ_WRITE
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.ontius.apache.ignite.learn</groupId>
<artifactId>hibernate-l2-cache</artifactId>
<version>1.0-SNAPSHOT</version>
<name>HibernateL2Cache</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<ignite.version>2.6.0</ignite.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.3.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- Apache Ignite -->
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-core</artifactId>
<version>${ignite.version}</version>
</dependency>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-spring</artifactId>
<version>${ignite.version}</version>
</dependency>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-hibernate_5.1</artifactId>
<version>${ignite.version}</version>
</dependency>
<!-- MySQL -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.13</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I think I have to start ignite in the Spring Boot Application before the entityManagerFactory is initialized. But I don't know how I can achieve this.
First, you have a typo in your addresses: 127.0.0.1:47500:47509 should be 127.0.0.1:47500..47509.
Second, you have two options to link Hibernate L2 Cache to Ignite - start the Ignite node manually in the same JVM prior to Hibernate initialization or make Hibernate start it automatically.
Since you're using Spring Boot, and Ignite always starts last in the Spring contexts, it would probably be easier to go with the second approach.
To enable automatic Ignite startup you need to set org.apache.ignite.hibernate.grid_config property to a path of an Ignite XML configuration. Unfortunately, it seems that you can't use Java-based configuration here, only XML. You can convert your client configuration to an XML, put it into a resource under META-INF, say META-INF/ignite-client.xml, and then reference it (now without META-INF) - org.apache.ignite.hibernate.grid_config: ignite-client.xml. You should also remove the ignite_instance_name property (because it is overridden by grid_config) and the Ignite bean in the client application (because it is now started by Hibernate).
I know this is an old post. But let me put my view on this issue here.
The reason for this issue is Spring Boot is staring before Ignite. To fix it, we need to make sure Ignite is starting before Spring Boot.
If you change your "Application.java" as below, it should work.
#SpringBootApplication
public class Application {
public static void main(String[] args) {
IgniteSpringBean igniteSpringBean = new IgniteSpringBean();
igniteSpringBean.setConfiguration(ClientConfigurationFactory.createConfiguration());
SpringApplication.run(Application.class, args);
}
}
I am learning SpringBoot. using Spring JavaPersistenceAPI(JPA) and apache derby as the database. I am having trouble mapping a URL to a method.
I have Topics:
#Entity
public class Topic {
#Id
private String id;
private String name;
private String description;
public Topic() {
}
public Topic(String id, String name, String description) {
this.id = id;
this.name = name;
this.description = description;
} ... getters & setters...
And I have a Topic controller. It works fine:
#RestController
public class TopicController {
#Autowired
private TopicService topicServ;
#RequestMapping("/topics")
public List<Topic> getAllTopics() {
return topicServ.getAllTopics();
}
#RequestMapping("/topics/{topicId}")
public Topic getTopic(#PathVariable String topicId) {
return topicServ.getTopic(topicId);
}... more methods (they work fine)
Every topic has courses:
#Entity
public class Course {
private String id;
private String name;
private String description;
#ManyToOne
private Topic topic;
public Course() {
}
public Course(String id, String name, String description, String topicId) {
this.id = id;
this.name = name;
this.description = description;
this.setTopic(new Topic(topicId, "CourseConstructorNAME", "CourseConstructorDESCRIPTION"));
} ... getters & setters ...
And I have the courses controller, where I am finding the problem:
#RestController
public class CourseController {
#Autowired
private CourseService courseServ;
#GetMapping(value = "/topics/{topicId}/courses")
public List<Course> getAllCourses(#PathVariable("topicId") String topicId){
System.out.println("Hi"); *<-- does not print anything*
return courseServ.getAllCourses(topicId);
}
The problem is that, issuing a GET request to http://localhost:8080/topics/java/courses , returns a 404 error message:
{
"timestamp": "2018-11-26T19:30:08.871+0000",
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/topics/java/courses"
}
I expect a list of courses corresponding to the topic id fetched from the URL. The failure confuses me because the topic controller works fine and it is almost the same.
So, because the sysout I put above doesn't print anything, I must be doing something really dumb; but just in case, here is the code for courseServ:
#Service
public class CourseService {
#Autowired
private CourseRepository courseRepo;
public List<Course> getAllCourses(String topicId){
System.out.println("Calling get all courses from course service");
List<Course> theList = new ArrayList<Course>();
courseRepo.findByTopic_Id(topicId).forEach(theList::add);
System.out.println(theList.toString());
return theList;
}
and here is courseRepo:
public interface CourseRepository extends CrudRepository<Course, String> {
public List<Course> findByTopic_Id(String topicId);
}
Here is the spring console log:
2018-11-26 13:29:25.142 INFO 16252 --- [ main] P.ProjectNameWithJpaApplication : Starting ProjectNameWithJpaApplication on JulioPHX with PID 16252 (C:\SpringToolSuite\workspace\ProjectNameWithJPA\target\classes started by JulioPHX in C:\SpringToolSuite\workspace\ProjectNameWithJPA)
2018-11-26 13:29:25.148 INFO 16252 --- [ main] P.ProjectNameWithJpaApplication : No active profile set, falling back to default profiles: default
2018-11-26 13:29:27.107 INFO 16252 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2018-11-26 13:29:27.238 INFO 16252 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 116ms. Found 1 repository interfaces.
2018-11-26 13:29:28.254 INFO 16252 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$c18d73e6] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-11-26 13:29:29.466 INFO 16252 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2018-11-26 13:29:29.501 INFO 16252 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-11-26 13:29:29.502 INFO 16252 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/9.0.12
2018-11-26 13:29:29.525 INFO 16252 --- [ main] 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: [C:\Program Files\Java\jre1.8.0_191\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre1.8.0_191/bin/server;C:/Program Files/Java/jre1.8.0_191/bin;C:/Program Files/Java/jre1.8.0_191/lib/amd64;C:\Scripts\;C:\;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Python37\;C:\Python37\Scripts;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS\;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Git\cmd;C:\Program Files\RedHat\java-1.8.0-openjdk-1.8.0.161-1\bin;C:\WINDOWS\System32\OpenSSH\;C:\MinGW\bin;C:\Program Files\MicrosoftVSCode\bin;C:\cygwin64\bin;C:\Program Files\apache-maven-3.5.4\bin;C:\Users\JulioPHX\AppData\Local\Microsoft\WindowsApps;;C:\Users\JulioPHX\Microsoft VS Code\bin;C:\SpringToolSuite\sts-bundle\sts-3.9.6.RELEASE;;.]
2018-11-26 13:29:29.773 INFO 16252 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-11-26 13:29:29.774 INFO 16252 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 4461 ms
2018-11-26 13:29:29.852 INFO 16252 --- [ main] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2018-11-26 13:29:29.861 INFO 16252 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-11-26 13:29:29.862 INFO 16252 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-11-26 13:29:29.862 INFO 16252 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'formContentFilter' to: [/*]
2018-11-26 13:29:29.862 INFO 16252 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-11-26 13:29:30.698 INFO 16252 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2018-11-26 13:29:30.703 WARN 16252 --- [ main] com.zaxxer.hikari.util.DriverDataSource : Registered driver with driverClassName=org.apache.derby.jdbc.EmbeddedDriver was not found, trying direct instantiation.
2018-11-26 13:29:31.587 INFO 16252 --- [ main] com.zaxxer.hikari.pool.PoolBase : HikariPool-1 - Driver does not support get/set network timeout for connections. (Feature not implemented: No details.)
2018-11-26 13:29:31.596 INFO 16252 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2018-11-26 13:29:31.764 INFO 16252 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2018-11-26 13:29:31.925 INFO 16252 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.3.7.Final}
2018-11-26 13:29:31.929 INFO 16252 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2018-11-26 13:29:32.247 INFO 16252 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.4.Final}
2018-11-26 13:29:32.586 INFO 16252 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.DerbyTenSevenDialect
2018-11-26 13:29:34.603 WARN 16252 --- [ main] o.h.t.s.i.ExceptionHandlerLoggedImpl : GenerationTarget encountered exception accepting command : Error executing DDL "drop table topic" via JDBC Statement
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "drop table topic" via JDBC Statement
Caused by: java.sql.SQLSyntaxErrorException: Schema 'SA' does not exist
Caused by: org.apache.derby.iapi.error.StandardException: Schema 'SA' does not exist
2018-11-26 13:29:34.718 INFO 16252 --- [ main] o.h.t.schema.internal.SchemaCreatorImpl : HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl#74b00247'
2018-11-26 13:29:34.725 INFO 16252 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2018-11-26 13:29:36.108 INFO 16252 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2018-11-26 13:29:36.251 WARN 16252 --- [ main] 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-11-26 13:29:36.757 INFO 16252 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2018-11-26 13:29:36.763 INFO 16252 --- [ main] P.ProjectNameWithJpaApplication : Started ProjectNameWithJpaApplication in 12.543 seconds (JVM running for 13.617)
2018-11-26 13:29:42.083 INFO 16252 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2018-11-26 13:29:42.084 INFO 16252 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2018-11-26 13:29:42.100 INFO 16252 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 16 ms
2018-11-26 13:29:42.298 INFO 16252 --- [nio-8080-exec-1] o.h.h.i.QueryTranslatorFactoryInitiator : HHH000397: Using ASTQueryTranslatorFactory
And the 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>PackageNameWithJPA</groupId>
<artifactId>ProjectNameWithJPA</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>ProjectNameWithJPA</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.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>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Project structure:
Thank you in advance for any help.
I have same problem .It is because your Properties default is set to:
"spring.jpa.hibernate.ddl-auto=create-drop"
change it
in application.properties file.if this not over there add this
"spring.jpa.hibernate.ddl-auto=update"
line in your application.properties file.It work fine.
Even I have encountered the same error while using Apache Derby. This is because of the default properties of spring which is -spring.jpa.hibernate.ddl-auto=create-drop.
Solution: Create an application.properties file in src/main/resources folder and change the property to spring.jpa.hibernate.ddl-auto=update and run the app again, it should work.
The reason being the second controller in package "ProjectNameWithJPA.course" is giving 404 error because spring is not able to scan controller in "ProjectNameWithJPA.course".
By default, Spring-Boot scans the controller under the same package hierarchy like it can be "PackageNameWithJPA.course"
Read this for more understanding spring docs [https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-using-springbootapplication-annotation.html]
You can always define a custom component scan in a spring boot project. By default #SpringBootApplication annotation handles the component scanning for the application. However, let’s say one of the components is defined in another package then you can define in your configuration class like :
#ComponentScan({"com.springboot.basics.springbootPA1","com.springboot.springbootPA2"})
#SpringBootApplication
public class testApplication{
I am trying to run Spring boot application but I am facing a problem. Help me please. Why do I have this error?
pom.xml
<groupId>com.bwebmedia.laughtercounter</groupId>
<artifactId>laughtercounter</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>laughtercounter</name>
<description></description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.1.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.0.0</version>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.6.0</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.BUILD-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
`AppConfig
#Configuration
#EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
#ComponentScan
#EnableAsync
#EnableCaching
#EnableScheduling
public class AppConfig {
}
Application
#EnableDiscoveryClient
#SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
application.properties
server.port=8888
spring.main.banner-mode=off
#database config
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.url= jdbc:postgresql://localhost:5432/laughterDB
spring.datasource.username=postgres
spring.datasource.password=postgres
spring.jpa.hibernate.ddl-auto=create-drop
#rabbit config
rabbit.host=localhost
rabbit.port=5672
rabbit.username=guest
rabbit.password=guest
#60 sec
spring.datasource.hikari.connection-timeout=60000
# max 5
spring.datasource.hikari.maximum-pool-size=5
Controller
#RestController
public class ClientController {
final private ClientService clientService;
#Autowired
public ClientController(ClientService clientService) {
this.clientService = clientService;
}
#RequestMapping(value = "/create", method = RequestMethod.POST)
public void create(#RequestBody List<Client> client,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
throw new InvalidRequestException("Not correct request data");
}
clientService.create(client);
}
}
Model
#Data
#Builder
#AllArgsConstructor
#NoArgsConstructor
public class Client {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private int seat;
private String gender;
private int cameraId;
private int height;
private int topY;
private int width;
private int leftX;
private long smile;
}
Repository
#Repository
public interface ClientRepository extends JpaRepository<Client, Long> {
}
Service
#Service
#Slf4j
public class ClientServiceImpl implements ClientService {
private ClientRepository clientRepository;
#Autowired
public ClientServiceImpl(ClientRepository clientRepository) {
this.clientRepository = clientRepository;
}
#Override
public void create(List<Client> client) {
client.forEach(x -> clientRepository.save(x));
}
}
Error output
Connected to the target VM, address: '127.0.0.1:37019', transport: 'socket'
2017-03-02 17:47:09.286 INFO 8561 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#294e5088: startup date [Thu Mar 02 17:47:09 EET 2017]; root of context hierarchy
2017-03-02 17:47:10.066 INFO 8561 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2017-03-02 17:47:10.188 INFO 8561 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [class org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$332fe413] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-02 17:47:11.174 INFO 8561 --- [ main] c.bwebmedia.laughtercounter.Application : No active profile set, falling back to default profiles: default
2017-03-02 17:47:11.212 INFO 8561 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#3aefae67: startup date [Thu Mar 02 17:47:11 EET 2017]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#294e5088
2017-03-02 17:47:14.472 INFO 8561 --- [ 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$Hikari; factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.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$Tomcat; factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]]
2017-03-02 17:47:14.546 WARN 8561 --- [ main] o.s.c.a.ConfigurationClassPostProcessor : Cannot enhance #Configuration bean definition 'refreshScope' since its singleton instance has been created too early. The typical cause is a non-static #Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as 'static'.
2017-03-02 17:47:14.947 INFO 8561 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=ffa7c2d3-1b2b-3c4f-b2a5-e20a48541c23
2017-03-02 17:47:15.024 INFO 8561 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2017-03-02 17:47:15.293 INFO 8561 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.amqp.rabbit.annotation.RabbitBootstrapConfiguration' of type [class org.springframework.amqp.rabbit.annotation.RabbitBootstrapConfiguration$$EnhancerBySpringCGLIB$$dd819f44] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-02 17:47:15.390 INFO 8561 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.retry.annotation.RetryConfiguration' of type [class org.springframework.retry.annotation.RetryConfiguration$$EnhancerBySpringCGLIB$$cd9793b] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-02 17:47:15.462 INFO 8561 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$1715e116] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-02 17:47:15.574 INFO 8561 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cache.annotation.ProxyCachingConfiguration' of type [class org.springframework.cache.annotation.ProxyCachingConfiguration$$EnhancerBySpringCGLIB$$60281734] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-02 17:47:15.649 INFO 8561 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration' of type [class org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration$$EnhancerBySpringCGLIB$$549bdbd8] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-02 17:47:15.740 INFO 8561 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'spring.cache-org.springframework.boot.autoconfigure.cache.CacheProperties' of type [class org.springframework.boot.autoconfigure.cache.CacheProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-02 17:47:15.764 INFO 8561 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.cache.CacheManagerCustomizers' of type [class org.springframework.boot.autoconfigure.cache.CacheManagerCustomizers] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-02 17:47:15.775 INFO 8561 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.cache.SimpleCacheConfiguration' of type [class org.springframework.boot.autoconfigure.cache.SimpleCacheConfiguration$$EnhancerBySpringCGLIB$$f6374eb9] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-02 17:47:15.833 INFO 8561 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'cacheManager' of type [class org.springframework.cache.concurrent.ConcurrentMapCacheManager] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-02 17:47:15.835 INFO 8561 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'cacheAutoConfigurationValidator' of type [class org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration$CacheManagerValidator] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-02 17:47:16.048 INFO 8561 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [class org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$332fe413] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-02 17:47:17.019 INFO 8561 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8888 (http)
2017-03-02 17:47:17.044 INFO 8561 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2017-03-02 17:47:17.047 INFO 8561 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.5
2017-03-02 17:47:17.303 INFO 8561 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-03-02 17:47:17.304 INFO 8561 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 6092 ms
2017-03-02 17:47:17.878 INFO 8561 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-03-02 17:47:17.887 INFO 8561 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-03-02 17:47:17.888 INFO 8561 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-03-02 17:47:17.889 INFO 8561 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-03-02 17:47:17.890 INFO 8561 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-03-02 17:47:18.914 INFO 8561 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2017-03-02 17:47:18.961 INFO 8561 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2017-03-02 17:47:19.407 INFO 8561 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.11.Final}
2017-03-02 17:47:19.413 INFO 8561 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2017-03-02 17:47:19.417 INFO 8561 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2017-03-02 17:47:19.646 INFO 8561 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2017-03-02 17:47:20.841 INFO 8561 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL94Dialect
2017-03-02 17:47:21.174 INFO 8561 --- [ main] o.h.e.j.e.i.LobCreatorBuilderImpl : HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
2017-03-02 17:47:21.179 INFO 8561 --- [ main] org.hibernate.type.BasicTypeRegistry : HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType#3b4f1eb
2017-03-02 17:47:21.569 INFO 8561 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export
2017-03-02 17:47:21.572 INFO 8561 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete
2017-03-02 17:47:21.633 INFO 8561 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2017-03-02 17:47:21.731 WARN 8561 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'clientController' defined in file [/home/spanky/IdeaProjects/laughter-counter-server/target/classes/com/bwebmedia/laughtercounter/controller/ClientController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'clientServiceImpl' defined in file [/home/spanky/IdeaProjects/laughter-counter-server/target/classes/com/bwebmedia/laughtercounter/service/impl/ClientServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean found for dependency [com.bwebmedia.laughtercounter.repository.ClientRepository]: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2017-03-02 17:47:21.732 INFO 8561 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2017-03-02 17:47:21.732 INFO 8561 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export
2017-03-02 17:47:21.733 INFO 8561 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete
2017-03-02 17:47:21.745 INFO 8561 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat
2017-03-02 17:47:21.797 INFO 8561 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-03-02 17:47:22.103 ERROR 8561 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in com.bwebmedia.laughtercounter.service.impl.ClientServiceImpl required a bean of type 'com.bwebmedia.laughtercounter.repository.ClientRepository' that could not be found.
Action:
Consider defining a bean of type 'com.bwebmedia.laughtercounter.repository.ClientRepository' in your configuration.
Disconnected from the target VM, address: '127.0.0.1:37019', transport: 'socket'
Process finished with exit code 1
Error in not #Autowired repository. Not find models and other parts. I'm use Linux(Ubuntu dist). Sometimes write error with context. Why I am facing this error?
Do not exclude DataSourceAutoConfiguration.class in your AppConfig class.