E ai Amigos Hipsters…
Eis que eu estava programando ontem a noite e me deparei com o seguinte erro numa aplicação do Spring Boot…
2020-07-17 00:23:20.066 INFO 18684 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-07-17 00:23:20.136 INFO 18684 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.15.Final
2020-07-17 00:23:20.289 INFO 18684 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-07-17 00:23:20.464 INFO 18684 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
Hibernate:
drop table if exists categoria CASCADE
Hibernate:
drop table if exists produto CASCADE
Hibernate:
drop table if exists produto_categoria CASCADE
Hibernate:
create table categoria (
id integer generated by default as identity,
nome varchar(255),
primary key (id)
)
Hibernate:
create table produto (
id integer generated by default as identity,
nome varchar(255),
preco double,
primary key (id)
)
Hibernate:
create table produto_categoria (
produto_id integer not null,
categoria_id integer not null
)
Hibernate:
alter table produto_categoria
add constraint FKq3g33tp7xk2juh53fbw6y4y57
foreign key (categoria_id)
references categoria
Hibernate:
alter table produto_categoria
add constraint FK1c0y58d3n6x3m6euv2j3h64vt
foreign key (produto_id)
references produto
2020-07-17 00:23:21.391 INFO 18684 --- [ restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-07-17 00:23:21.401 INFO 18684 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-07-17 00:23:21.441 INFO 18684 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2020-07-17 00:23:21.807 WARN 18684 --- [ 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
2020-07-17 00:23:22.010 INFO 18684 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-07-17 00:23:22.298 INFO 18684 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2020-07-17 00:23:22.304 INFO 18684 --- [ restartedMain] c.c.c.CursoSpringbootApplication : Started CursoSpringbootApplication in 5.269 seconds (JVM running for 6.77)
Hibernate:
insert
into
categoria
(id, nome)
values
(null, ?)
Hibernate:
insert
into
categoria
(id, nome)
values
(null, ?)
2020-07-17 00:23:22.392 INFO 18684 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-07-17 00:23:22.405 ERROR 18684 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
java.lang.IllegalStateException: Failed to execute CommandLineRunner
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:787) ~[spring-boot-2.2.7.RELEASE.jar:2.2.7.RELEASE]
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:768) ~[spring-boot-2.2.7.RELEASE.jar:2.2.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:322) ~[spring-boot-2.2.7.RELEASE.jar:2.2.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.2.7.RELEASE.jar:2.2.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.2.7.RELEASE.jar:2.2.7.RELEASE]
at com.cardoso.cursospringboot.CursoSpringbootApplication.main(CursoSpringbootApplication.java:23) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.2.7.RELEASE.jar:2.2.7.RELEASE]
Caused by: java.lang.NullPointerException: null
at com.cardoso.cursospringboot.CursoSpringbootApplication.run(CursoSpringbootApplication.java:47) ~[classes/:na]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:784) ~[spring-boot-2.2.7.RELEASE.jar:2.2.7.RELEASE]
... 10 common frames omitted
2020-07-17 00:23:22.409 INFO 18684 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2020-07-17 00:23:22.410 INFO 18684 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2020-07-17 00:23:22.410 INFO 18684 --- [ restartedMain] .SchemaDropperImpl$DelayedDropActionImpl : HHH000477: Starting delayed evictData of schema as part of SessionFactory shut-down'
Hibernate:
drop table if exists categoria CASCADE
Hibernate:
drop table if exists produto CASCADE
Hibernate:
drop table if exists produto_categoria CASCADE
2020-07-17 00:23:22.422 INFO 18684 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2020-07-17 00:23:22.500 INFO 18684 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdoawn completed.
Segundo o erro, é da do CommandLineRunner na Aplicação Master do Spring Boot, destrinchei todas as classes do meu projeto e não encontrei o erro.
Quem pode me dar uma orientação melhor?
Abraços
Thiago