My h2 working, but i cant connect inside of h2-console - java

Yoo coder, have one issue with h2-console.When i created some entitys on start,my h2 worked and i could open my h2-console and saw there tables ,but after some time i want connect again and doesn't work now.Meanwhile i added some lines and classes,but idk why doesn't work my h2-console,cause i don't touch application properties.
After lick on conect or testconect i got this error
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Mon Mar 14 19:12:33 CET 2022
There was an unexpected error (type=Forbidden, status=403).
My github project: https://github.com/Wynnyy/bookingdoctor-project.git
logs
2022-03-14 19:12:16.222 INFO 23108 --- [ main] s.w.b.BookingdoctorApplication : Starting BookingdoctorApplication using Java 17.0.2 on DESKTOP-K3O8I67 with PID 23108 (C:\Users\Patrik Severín\IdeaProjects\bookingdoctor\target\classes started by Wynny in C:\Users\Patrik Severín\IdeaProjects\bookingdoctor)
2022-03-14 19:12:16.224 INFO 23108 --- [ main] s.w.b.BookingdoctorApplication : No active profile set, falling back to 1 default profile: "default"
2022-03-14 19:12:16.928 INFO 23108 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-03-14 19:12:16.986 INFO 23108 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 47 ms. Found 2 JPA repository interfaces.
2022-03-14 19:12:17.670 INFO 23108 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2022-03-14 19:12:17.682 INFO 23108 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-03-14 19:12:17.682 INFO 23108 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.58]
2022-03-14 19:12:17.780 INFO 23108 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-03-14 19:12:17.780 INFO 23108 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1503 ms
2022-03-14 19:12:17.829 INFO 23108 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2022-03-14 19:12:18.068 INFO 23108 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2022-03-14 19:12:18.080 INFO 23108 --- [ main] o.s.b.a.h2.H2ConsoleAutoConfiguration : H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:wynny'
2022-03-14 19:12:18.277 INFO 23108 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2022-03-14 19:12:18.331 INFO 23108 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.5.Final
2022-03-14 19:12:18.497 INFO 23108 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2022-03-14 19:12:18.627 INFO 23108 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2022-03-14 19:12:19.225 INFO 23108 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2022-03-14 19:12:19.232 INFO 23108 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2022-03-14 19:12:19.540 WARN 23108 --- [ 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
2022-03-14 19:12:19.708 INFO 23108 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Will not secure any request
2022-03-14 19:12:20.112 INFO 23108 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2022-03-14 19:12:20.211 INFO 23108 --- [ main] s.w.b.BookingdoctorApplication : Started BookingdoctorApplication in 4.362 seconds (JVM running for 4.745)
2022-03-14 19:12:24.415 INFO 23108 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2022-03-14 19:12:24.415 INFO 23108 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2022-03-14 19:12:24.417 INFO 23108 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 2 ms

By default, spring-security will protect each and every end-point - So, for /error you need to manually configure like the following -
#EnableWebSecurity
public class AppSecurityConfig extends WebSecurityConfigurerAdapter {
#Override
public void configure(HttpSecurity auth) {
auth.csrf().disable()
.authorizeRequests()
.antMatchers("/error/**").permitAll() // permit-all for /error page
.anyRequest().authenticated();
}
}

For future reference:
In Spring Boot 3.0 / Spring Security 6.0 http.antMatcher() is not longer available and was replaced with http.securityMatcher().
So Subham's answer would look like that:
#Configuration
public class SecurityConfiguration {
#Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.authorizeHttpRequests((authz) -> authz.anyRequest().permitAll())
.csrf().disable()
.securityMatcher("/error/**")
.httpBasic(withDefaults());
return http.build();
}
}

Related

why I see this when compiling my project in bootstrap? "Found 0 JPA repository interfaces."

I have created a Bootstrap project in which I have 3 repositories. When I compile the project I do not receive any errors but unfortunately I can not see my controllers in Swagger!!!
I have found out that line 4 says:
Finished Spring Data repository scanning in 4 ms. Found 0 JPA
repository interfaces.
I think this the reason that I can not see the controllers. Any idea to solve this? Thank you in advance.
2021-12-14 00:26:13.768 INFO 5472 --- [ main] WBSthesis.rotab.RotabApplication
: No active profile set, falling back to default profiles: default
2021-12-14 00:26:14.648 INFO 5472 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-12-14 00:26:14.661 INFO 5472 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : ***Finished Spring Data repository scanning in 4 ms. Found 0 JPA repository interfaces.***
2021-12-14 00:26:15.592 INFO 5472 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2021-12-14 00:26:15.609 INFO 5472 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-12-14 00:26:15.609 INFO 5472 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.54]
2021-12-14 00:26:15.718 INFO 5472 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-12-14 00:26:15.718 INFO 5472 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1885 ms
2021-12-14 00:26:15.975 INFO 5472 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-12-14 00:26:16.051 INFO 5472 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.32.Final
2021-12-14 00:26:16.226 INFO 5472 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-12-14 00:26:16.356 INFO 5472 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-12-14 00:26:16.562 INFO 5472 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-12-14 00:26:16.580 INFO 5472 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL55Dialect
2021-12-14 00:26:16.856 INFO 5472 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-12-14 00:26:16.866 INFO 5472 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-12-14 00:26:17.090 WARN 5472 --- [ 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
2021-12-14 00:26:17.225 INFO 5472 --- [ main] pertySourcedRequestMappingHandlerMapping : Mapped URL path [/v2/api-docs] onto method [springfox.documentation.swagger2.web.Swagger2Controller#getDocumentation(String, HttpServletRequest)]
2021-12-14 00:26:17.490 INFO 5472 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2021-12-14 00:26:17.491 INFO 5472 --- [ main] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
2021-12-14 00:26:17.511 INFO 5472 --- [ main] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
2021-12-14 00:26:17.544 INFO 5472 --- [ main] s.d.s.w.s.ApiListingReferenceScanner : Scanning for api listing references
2021-12-14 00:26:17.698 INFO 5472 --- [ main] WBSthesis.rotab.RotabApplication : Started RotabApplication in 4.468 seconds (JVM running for 4.958)
More info of your project would be helpful, but maybe your interfaces are not inside the right package. I was facing this once...
Here is an example.
Notice that all sub-packages are on the same level as the #SpringBootApplication.

Intellij Community Edition showing this error on schema.sql file as can see on image that I droped here

When I run the application this shutdown and don't allow me enter on H2 database on localhost h2 URL.
Is anyone else having this same problem?
:: Spring Boot :: (v2.4.1)
2020-12-22 15:23:08.377 INFO 4937 --- [ restartedMain] c.l.suraapp.SuraAppApplication : Starting SuraAppApplication using Java 15 on goemon with PID 4937 (/home/leporoni/Documents/JavaProjects/SuraApp/target/classes started by leporoni in /home/leporoni/Documents/JavaProjects/SuraApp)
2020-12-22 15:23:08.381 INFO 4937 --- [ restartedMain] c.l.suraapp.SuraAppApplication : No active profile set, falling back to default profiles: default
2020-12-22 15:23:08.554 INFO 4937 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2020-12-22 15:23:10.115 INFO 4937 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-12-22 15:23:10.228 INFO 4937 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 84 ms. Found 1 JPA repository interfaces.
2020-12-22 15:23:11.011 INFO 4937 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-12-22 15:23:11.580 INFO 4937 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-12-22 15:23:11.836 INFO 4937 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-12-22 15:23:11.972 INFO 4937 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.25.Final
2020-12-22 15:23:12.653 INFO 4937 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2020-12-22 15:23:12.967 INFO 4937 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2020-12-22 15:23:13.927 INFO 4937 --- [ restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-12-22 15:23:13.941 INFO 4937 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-12-22 15:23:13.959 INFO 4937 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2020-12-22 15:23:14.520 INFO 4937 --- [ restartedMain] c.l.suraapp.SuraAppApplication : Started SuraAppApplication in 7.451 seconds (JVM running for 9.275)
2020-12-22 15:23:14.529 INFO 4937 --- [extShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2020-12-22 15:23:14.564 INFO 4937 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2020-12-22 15:23:14.581 INFO 4937 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
Process finished with exit code 0

Failed to validate data received from Authorization service - could not validate state

I downloaded ms-identity-java-webapp archive and updated the application.properties file with the Azure AD details.
When I started the Spring Boot application, I got a login page. After clicking login button, I got a microsoft login page and after logging in with the user account, I got the following log lines with an error page:
2020-09-23 16:53:06.982 INFO 708 --- [ main] c.m.a.m.MsalWebSampleApplication : Starting MsalWebSampleApplication with PID 708 (C:\Users\testuser\Downloads\ms-identity-java-webapp-master\msal-java-webapp-sample\target\classes started by testuser in C:\Users\testuser\Downloads\ms-identity-java-webapp-master\msal-java-webapp-sample)
2020-09-23 16:53:06.985 INFO 708 --- [ main] c.m.a.m.MsalWebSampleApplication : No active profile set, falling back to default profiles: default
2020-09-23 16:53:08.466 INFO 708 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-09-23 16:53:08.497 INFO 708 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-09-23 16:53:08.497 INFO 708 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.17]
2020-09-23 16:53:08.646 INFO 708 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-09-23 16:53:08.647 INFO 708 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1613 ms
2020-09-23 16:53:08.967 INFO 708 --- [ main] .s.s.UserDetailsServiceAutoConfiguration :
Using generated security password: 970ff480-0c7d-4cd0-b657-000c23a68ab4
2020-09-23 16:53:09.148 INFO 708 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#6813a331, org.springframework.security.web.context.SecurityContextPersistenceFilter#27494e46, org.springframework.security.web.header.HeaderWriterFilter#68105edc, org.springframework.security.web.csrf.CsrfFilter#6e4ea0bd, org.springframework.security.web.authentication.logout.LogoutFilter#3e598df9, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#1e411d81, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#75504cef, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#1bd81830, org.springframework.security.web.session.SessionManagementFilter#470a9030, org.springframework.security.web.access.ExceptionTranslationFilter#28782602]
2020-09-23 16:53:09.373 INFO 708 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-09-23 16:53:09.561 INFO 708 --- [ main] o.s.b.a.w.s.WelcomePageHandlerMapping : Adding welcome page template: index
2020-09-23 16:53:09.710 INFO 708 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2020-09-23 16:53:09.715 INFO 708 --- [ main] c.m.a.m.MsalWebSampleApplication : Started MsalWebSampleApplication in 3.211 seconds (JVM running for 4.717)
2020-09-23 16:53:29.556 INFO 708 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-09-23 16:53:29.556 INFO 708 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2020-09-23 16:53:29.562 INFO 708 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 6 ms
Failed to validate data received from Authorization service - could not validate state
Has anyone faced this issue? How can I resolve this?
This issue was already addressed on GitHub and was already fixed. Please go through the solution given here .

How to check for another running project on Eclipse?

I am using eclipse IDE to run my spring boot project(the backend part) which uses the port 8080 on localhost. When i try to run my program it shuts down the program saying port 8080 was already in use. There isn't any other application that is using the port 8080 and there is no other console window because of which i cannot shut down the currently running application that is using port 8080. PFB the logs from the console window:
:: Spring Boot :: (v2.3.3.RELEASE)
2020-09-24 19:31:44.942 INFO 4092 --- [ main] c.library_management.lms.LmsApplication : Starting LmsApplication on DESKTOP-GM2UUP2 with PID 4092 (D:\eclipse-workspace\lms\target\classes started by Electrical Engineer in D:\eclipse-workspace\lms)
2020-09-24 19:31:44.948 INFO 4092 --- [ main] c.library_management.lms.LmsApplication : No active profile set, falling back to default profiles: default
2020-09-24 19:31:50.633 INFO 4092 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFERRED mode.
2020-09-24 19:31:51.947 INFO 4092 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 1092ms. Found 3 JPA repository interfaces.
2020-09-24 19:31:59.953 INFO 4092 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-09-24 19:32:00.358 INFO 4092 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-09-24 19:32:00.360 INFO 4092 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.37]
2020-09-24 19:32:01.666 INFO 4092 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-09-24 19:32:01.667 INFO 4092 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 16526 ms
2020-09-24 19:32:05.077 INFO 4092 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-09-24 19:32:06.080 INFO 4092 --- [ task-1] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-09-24 19:32:06.793 WARN 4092 --- [ 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-09-24 19:32:08.214 INFO 4092 --- [ task-1] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.20.Final
2020-09-24 19:32:16.114 INFO 4092 --- [ task-1] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-09-24 19:32:16.817 INFO 4092 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#5477a1ca, org.springframework.security.web.context.SecurityContextPersistenceFilter#6794ac0b, org.springframework.security.web.header.HeaderWriterFilter#77d680e6, org.springframework.security.web.authentication.logout.LogoutFilter#33a3c44a, org.springframework.security.web.authentication.www.BasicAuthenticationFilter#222afc67, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#5cb5bb88, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#3a01773b, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#3ae9d1e2, org.springframework.security.web.session.SessionManagementFilter#5c1f6d57, org.springframework.security.web.access.ExceptionTranslationFilter#6014a9ba, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#65f2f9b0]
2020-09-24 19:32:21.739 INFO 4092 --- [ task-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-09-24 19:32:26.793 WARN 4092 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.PortInUseException: Port 8080 is already in use
2020-09-24 19:32:26.862 INFO 4092 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2020-09-24 19:32:31.239 INFO 4092 --- [ task-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-09-24 19:32:31.877 INFO 4092 --- [ task-1] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
2020-09-24 19:32:41.109 INFO 4092 --- [ task-1] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-09-24 19:32:41.172 INFO 4092 --- [ task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
Exception in thread "task-2" 2020-09-24 19:32:41.202 INFO 4092 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2020-09-24 19:32:41.204 INFO 4092 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
java.lang.IllegalStateException: EntityManagerFactory is closed
at org.hibernate.internal.SessionFactoryImpl.validateNotClosed(SessionFactoryImpl.java:509)
at org.hibernate.internal.SessionFactoryImpl.getProperties(SessionFactoryImpl.java:503)
at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.findDataSource(DataSourceInitializedPublisher.java:105)
at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.publishEventIfRequired(DataSourceInitializedPublisher.java:97)
at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.access$100(DataSourceInitializedPublisher.java:50)
at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher$DataSourceSchemaCreatedPublisher.lambda$postProcessEntityManagerFactory$0(DataSourceInitializedPublisher.java:200)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
2020-09-24 19:32:41.413 INFO 4092 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2020-09-24 19:32:41.418 INFO 4092 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-09-24 19:32:41.629 INFO 4092 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-09-24 19:32:41.652 ERROR 4092 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Web server failed to start. Port 8080 was already in use.
Action:
Identify and stop the process that's listening on port 8080 or configure this application to listen on another port.
This can be because you might gave run the project first (so it occupied the port) and now you are trying to run it again without closing the last one.Use this Option
The error message is not ambiguous, and that's not something that will occur "erroneously" (saying something is using the port when it's not actually in use). The port doesn't have to be used by something you started from Eclipse. There is no question that something is already listening on that port. You just have to figure out what it is. Alternatively, you could set up your application to run on a different port.

Cant reach Endpoint in Controller, despite it beeing intialised

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

Categories