Spring Batch application sqlcode -4499 sqlstate 08001 - java

Requirement:
Read from the file containing 100K records.
For each records, retrieve data from IBM DB2 database table and then retrieve data from NuoDB database table.
At last, insert the updated records in the NuoDB database table.
Design approached:
Chunk-oriented processing where 1000 records will be read from the file and processed and written into the database.
Issue:
After approx 75K records and running for almost 5 hours, the batch application failed with the below error:
Hibernate: select ... the SELECT query for DB2
Hibernate: select ... the SELECT query for NuoDB
2020-06-08 22:00:00.187 INFO [ ,,,] 32215 --- [ Thread-9] ConfigServletWebServerApplicationContext : Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#2a7f1f10: startup date [Mon Jun 08 17:22:51 BST 2020]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#3972a855
2020-06-08 22:00:00.192 INFO [ ,,,] 32215 --- [ Thread-9] o.s.c.support.DefaultLifecycleProcessor : Stopping beans in phase 0
2020-06-08 22:00:00.193 INFO [ ,,,] 32215 --- [ Thread-9] o.s.i.endpoint.EventDrivenConsumer : Removing {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
2020-06-08 22:00:00.193 INFO [ ,,,] 32215 --- [ Thread-9] o.s.i.channel.PublishSubscribeChannel : Channel ' -1.errorChannel' has 0 subscriber(s).
2020-06-08 22:00:00.193 INFO [ ,,,] 32215 --- [ Thread-9] o.s.i.endpoint.EventDrivenConsumer : stopped _org.springframework.integration.errorLogger
2020-06-08 22:00:00.195 INFO [ ,,,] 32215 --- [ Thread-9] o.s.s.c.ThreadPoolTaskScheduler : Shutting down ExecutorService 'taskScheduler'
2020-06-08 22:00:00.196 INFO [ ,,,] 32215 --- [ Thread-9] o.s.jmx.export.MBeanExporter : Unregistering JMX-exposed beans on shutdown
2020-06-08 22:00:00.203 INFO [ ,,,] 32215 --- [ Thread-9] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2020-06-08 22:00:00.203 INFO [ ,,,] 32215 --- [ Thread-9] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2020-06-08 22:00:00.203 INFO [ ,,,] 32215 --- [ Thread-9] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2020-06-08 22:00:00.203 INFO [ ,,,] 32215 --- [ Thread-9] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2020-06-08 22:00:00.203 INFO [ ,,,] 32215 --- [ Thread-9] com.zaxxer.hikari.HikariDataSource : HikariPool-3 - Shutdown initiated...
2020-06-08 22:00:00.210 INFO [ ,,,] 32215 --- [ Thread-9] com.zaxxer.hikari.HikariDataSource : HikariPool-3 - Shutdown completed.
2020-06-08 22:00:00.210 INFO [ ,,,] 32215 --- [ Thread-9] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Shutdown initiated...
2020-06-08 22:00:00.211 INFO [ ,,,] 32215 --- [ Thread-9] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Shutdown completed.
2020-06-08 22:00:00.212 INFO [ ,,,] 32215 --- [ Thread-9] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2020-06-08 22:00:00.214 INFO [ ,,,] 32215 --- [ Thread-9] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
What can be the actual cause of this issue?
Is this like a database cant be triggered SELECT query for 100K times regularly for 4-6 hours.
I re-run the application with log-level in DEBUG mode and here is the error I got:
com.ibm.db2.jcc.am.DisconnectNonTransientConnectionException: [jcc][t4][2030][11211][4.19.72] A communication error occurred during operations on the connection's underlying socket, socket input stream,
or socket output stream. Error location: Command timeout check. Message: Command timed out. ERRORCODE=-4499, SQLSTATE=08001

It seems like your database connection has been lost. You need to restart your job instance. If correctly configured, your job should restart from where it left off after the failure.

Related

how H2 in intellij without installed H2

i'm army
army computer can install intellij, but can not install H2.
test need h2 or other database program.
i wish know h2 use with 'localhost:8080/h2-console'
thank you for read.
2023-01-05T23:47:23.106+09:00 INFO 6156 --- \[ restartedMain\] anyway.sunwon.SunwonApplication : Starting SunwonApplication using Java 19.0.1 with PID 6156 (C:\\Users\\CKIRUser\\Desktop\\sunwon\\out\\production\\classes started by CKIRUser in C:\\Users\\CKIRUser\\Desktop\\sunwon)
2023-01-05T23:47:23.111+09:00 INFO 6156 --- \[ restartedMain\] anyway.sunwon.SunwonApplication : No active profile set, falling back to 1 default profile: "default"
2023-01-05T23:47:23.187+09:00 INFO 6156 --- \[ restartedMain\] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2023-01-05T23:47:23.187+09:00 INFO 6156 --- \[ restartedMain\] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2023-01-05T23:47:25.137+09:00 INFO 6156 --- \[ restartedMain\] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2023-01-05T23:47:25.225+09:00 INFO 6156 --- \[ restartedMain\] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 75 ms. Found 1 JPA repository interfaces.
2023-01-05T23:47:26.289+09:00 INFO 6156 --- \[ restartedMain\] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2023-01-05T23:47:26.306+09:00 INFO 6156 --- \[ restartedMain\] o.apache.catalina.core.StandardService : Starting service \[Tomcat\]
2023-01-05T23:47:26.306+09:00 INFO 6156 --- \[ restartedMain\] o.apache.catalina.core.StandardEngine : Starting Servlet engine: \[Apache Tomcat/10.1.4\]
2023-01-05T23:47:26.404+09:00 INFO 6156 --- \[ restartedMain\] o.a.c.c.C.\[Tomcat\].\[localhost\].\[/\] : Initializing Spring embedded WebApplicationContext
2023-01-05T23:47:26.406+09:00 INFO 6156 --- \[ restartedMain\] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3217 ms
2023-01-05T23:47:26.509+09:00 INFO 6156 --- \[ restartedMain\] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2023-01-05T23:47:27.118+09:00 INFO 6156 --- \[ restartedMain\] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Added connection conn0: url=jdbc:h2:mem:testdb user=SA
2023-01-05T23:47:27.120+09:00 INFO 6156 --- \[ restartedMain\] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2023-01-05T23:47:27.129+09:00 INFO 6156 --- \[ restartedMain\] o.s.b.a.h2.H2ConsoleAutoConfiguration : H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:testdb'
2023-01-05T23:47:27.392+09:00 INFO 6156 --- \[ restartedMain\] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo \[name: default\]
2023-01-05T23:47:27.459+09:00 INFO 6156 --- \[ restartedMain\] org.hibernate.Version : HHH000412: Hibernate ORM core version 6.1.6.Final
2023-01-05T23:47:27.638+09:00 WARN 6156 --- \[ restartedMain\] org.hibernate.orm.deprecation : HHH90000021: Encountered deprecated setting \[javax.persistence.sharedCache.mode\], use \[jakarta.persistence.sharedCache.mode\] instead
2023-01-05T23:47:27.895+09:00 INFO 6156 --- \[ restartedMain\] SQL dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2023-01-05T23:47:28.487+09:00 INFO 6156 --- \[ restartedMain\] o.h.m.i.EntityInstantiatorPojoStandard : HHH000182: No default (no-argument) constructor for class: anyway.sunwon.domain.Book (class must be instantiated by Interceptor)
2023-01-05T23:47:28.746+09:00 INFO 6156 --- \[ restartedMain\] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: \[org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform\]
2023-01-05T23:47:28.760+09:00 INFO 6156 --- \[ restartedMain\] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2023-01-05T23:47:29.060+09:00 WARN 6156 --- \[ restartedMain\] ocalVariableTableParameterNameDiscoverer : Using deprecated '-debug' fallback for parameter name resolution. Compile the affected code with '-parameters' instead or avoid its introspection: anyway.sunwon.repository.AdminUserRepository
2023-01-05T23:47:29.178+09:00 WARN 6156 --- \[ 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
2023-01-05T23:47:29.491+09:00 INFO 6156 --- \[ restartedMain\] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with \[org.springframework.security.web.session.DisableEncodeUrlFilter#7eec5f21, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#79825521, org.springframework.security.web.context.SecurityContextHolderFilter#440b0657, org.springframework.security.web.header.HeaderWriterFilter#67a9dd22, org.springframework.security.web.csrf.CsrfFilter#619d188, org.springframework.security.web.authentication.logout.LogoutFilter#5d875af3, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#1fcb3a64, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#166bfb26, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#3beb7681, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#4632b036, org.springframework.security.web.access.ExceptionTranslationFilter#76fd6789, org.springframework.security.web.access.intercept.AuthorizationFilter#21e50fa\]
2023-01-05T23:47:29.689+09:00 INFO 6156 --- \[ restartedMain\] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2023-01-05T23:47:29.746+09:00 INFO 6156 --- \[ restartedMain\] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2023-01-05T23:47:29.760+09:00 INFO 6156 --- \[ restartedMain\] anyway.sunwon.SunwonApplication : Started SunwonApplication in 7.529 seconds (process running for 8.562)
HikariProxyConnection#1662029991 wrapping conn0: url=jdbc:h2:mem:testdb user=SA
jdbc:h2:mem:testdb
SA
2023-01-05T23:47:29.792+09:00 INFO 6156 --- \[ restartedMain\] .s.b.a.l.ConditionEvaluationReportLogger :
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2023-01-05T23:47:29.814+09:00 ERROR 6156 --- \[ restartedMain\] o.s.boot.SpringApplication : Application run failed
java.lang.IllegalStateException: Failed to execute ApplicationRunner
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:761) \~\[spring-boot-3.0.1.jar:3.0.1\]
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:748) \~\[spring-boot-3.0.1.jar:3.0.1\]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) \~\[spring-boot-3.0.1.jar:3.0.1\]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) \~\[spring-boot-3.0.1.jar:3.0.1\]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291) \~\[spring-boot-3.0.1.jar:3.0.1\]
at anyway.sunwon.SunwonApplication.main(SunwonApplication.java:10) \~\[classes/:na\]
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) \~\[na:na\]
at java.base/java.lang.reflect.Method.invoke(Method.java:578) \~\[na:na\]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) \~\[spring-boot-devtools-3.0.1.jar:3.0.1\]
Caused by: org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar \[INSERT INTO USER VALUES(1, 'testuser')\]
at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:101) \~\[spring-jdbc-6.0.3.jar:6.0.3\]
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70) \~\[spring-jdbc-6.0.3.jar:6.0.3\]
at org.springframework.jdbc.core.JdbcTemplate.translateException(JdbcTemplate.java:1538) \~\[spring-jdbc-6.0.3.jar:6.0.3\]
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:393) \~\[spring-jdbc-6.0.3.jar:6.0.3\]
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:431) \~\[spring-jdbc-6.0.3.jar:6.0.3\]
at anyway.sunwon.H2Runner.run(H2Runner.java:37) \~\[classes/:na\]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:758) \~\[spring-boot-3.0.1.jar:3.0.1\]
... 8 common frames omitted
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "INSERT INTO \[\*\]USER VALUES(1, 'testuser')"; expected "identifier"; SQL statement:
INSERT INTO USER VALUES(1, 'testuser') \[42001-214\]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:502) \~\[h2-2.1.214.jar:2.1.214\]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:477) \~\[h2-2.1.214.jar:2.1.214\]
at org.h2.message.DbException.getSyntaxError(DbException.java:261) \~\[h2-2.1.214.jar:2.1.214\]
at org.h2.command.Parser.readIdentifier(Parser.java:5656) \~\[h2-2.1.214.jar:2.1.214\]
at org.h2.command.Parser.readIdentifierWithSchema(Parser.java:5616) \~\[h2-2.1.214.jar:2.1.214\]
at org.h2.command.Parser.readTableOrView(Parser.java:8328) \~\[h2-2.1.214.jar:2.1.214\]
at org.h2.command.Parser.parseInsert(Parser.java:1632) \~\[h2-2.1.214.jar:2.1.214\]
at org.h2.command.Parser.parsePrepared(Parser.java:814) \~\[h2-2.1.214.jar:2.1.214\]
at org.h2.command.Parser.parse(Parser.java:689) \~\[h2-2.1.214.jar:2.1.214\]
at org.h2.command.Parser.parse(Parser.java:661) \~\[h2-2.1.214.jar:2.1.214\]
at org.h2.command.Parser.prepareCommand(Parser.java:569) \~\[h2-2.1.214.jar:2.1.214\]
at org.h2.engine.SessionLocal.prepareLocal(SessionLocal.java:631) \~\[h2-2.1.214.jar:2.1.214\]
at org.h2.engine.SessionLocal.prepareCommand(SessionLocal.java:554) \~\[h2-2.1.214.jar:2.1.214\]
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1116) \~\[h2-2.1.214.jar:2.1.214\]
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:237) \~\[h2-2.1.214.jar:2.1.214\]
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:223) \~\[h2-2.1.214.jar:2.1.214\]
at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:94) \~\[HikariCP-5.0.1.jar:na\]
at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java) \~\[HikariCP-5.0.1.jar:na\]
at org.springframework.jdbc.core.JdbcTemplate$1ExecuteStatementCallback.doInStatement(JdbcTemplate.java:422) \~\[spring-jdbc-6.0.3.jar:6.0.3\]
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:381) \~\[spring-jdbc-6.0.3.jar:6.0.3\]
... 11 common frames omitted
2023-01-05T23:47:29.853+09:00 INFO 6156 --- \[ restartedMain\] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2023-01-05T23:47:30.061+09:00 WARN 6156 --- \[ restartedMain\] o.s.b.f.support.DisposableBeanAdapter : Invocation of destroy method failed on bean with name 'inMemoryDatabaseShutdownExecutor': org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) \[90121-214\]
2023-01-05T23:47:30.062+09:00 INFO 6156 --- \[ restartedMain\] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2023-01-05T23:47:30.066+09:00 INFO 6156 --- \[ restartedMain\] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
Process finished with exit code 0
Kindly paste your Java program as well.
stmt.executeUpdate("INSERT INTO CUSTOMER (ID,NAME,AGE,ADDRESS,SALARY) VALUES (1, 'Ramesh', 32, 'Ahmedabad', 2000.00 );");
Pasting the working SQL query in my current system, Thanks.

Spring boot Graphql Not worked

the application stands up but the graphql end point is not produced. I generated this project on start.spring.io but originally settings is the graphql end point not produced
application.yml
datasource:
url: jdbc:postgresql://localhost:10000/postgres
username: admin
password: 12345
graphql:
graphiql:
enabled: true
log
2022-07-07 09:44:40.006 INFO 10960 --- [ restartedMain] c.i.e.EmployeeManagmentApplication : No active profile set, falling back to 1 default profile: "default"
2022-07-07 09:44:40.173 INFO 10960 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2022-07-07 09:44:40.173 INFO 10960 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2022-07-07 09:44:41.787 INFO 10960 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode
2022-07-07 09:44:41.788 INFO 10960 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-07-07 09:44:41.823 INFO 10960 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 13 ms. Found 0 JPA repository interfaces.
2022-07-07 09:44:41.866 INFO 10960 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode
2022-07-07 09:44:41.869 INFO 10960 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode.
2022-07-07 09:44:41.891 INFO 10960 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 2 ms. Found 0 Redis repository interfaces.
2022-07-07 09:44:43.152 INFO 10960 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2022-07-07 09:44:43.168 INFO 10960 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-07-07 09:44:43.168 INFO 10960 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.64]
2022-07-07 09:44:43.326 INFO 10960 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-07-07 09:44:43.326 INFO 10960 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3149 ms
2022-07-07 09:44:43.500 INFO 10960 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2022-07-07 09:44:43.722 INFO 10960 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2022-07-07 09:44:43.794 INFO 10960 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2022-07-07 09:44:43.927 INFO 10960 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.9.Final
2022-07-07 09:44:44.284 INFO 10960 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2022-07-07 09:44:44.547 INFO 10960 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL10Dialect
2022-07-07 09:44:44.780 INFO 10960 --- [ restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2022-07-07 09:44:44.793 INFO 10960 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2022-07-07 09:44:44.903 WARN 10960 --- [ 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
2022-07-07 09:44:46.688 INFO 10960 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2022-07-07 09:44:46.779 INFO 10960 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2022-07-07 09:44:46.805 INFO 10960 --- [ restartedMain] c.i.e.EmployeeManagmentApplication : Started EmployeeManagmentApplication in 7.652 seconds (JVM running for 10.128)```
pom.xml

extShutdownHook Spring boot JAR file AWS EC2 deployment error

I am now making Spring boot based Web project.
When using AWS EC2 ubuntu for deployment, unsolved error came out and I want to share.
Project stack: Spring boot + AWS (EC2, S3, RDS(MariaDB))
Deployment is run by ubuntu with Spring boot JAR file.
java -jar *.jar
The problem is whenever I start application by JAR file, the server immediately stops with this log. I thought it is because of WebSocketConfig.java for Chat messaging function, but even I added Threadpoooltaskschedule and STOMP setAllowedOrigins, symtoms still exists.
Exhausted with solving by own, I need some help from you guys.
WebSocketConfig.java
private static final Logger LOGGER = LoggerFactory.getLogger(WebsocketBrokerConfig.class);
#Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
//for subscribe prefix
registry.enableSimpleBroker("/user");
//for publish prefix
registry.setApplicationDestinationPrefixes("/app");
//user destination provides ability to have unique user queue
//registry.setUserDestinationPrefix("/user");
}
#Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/broadcast")
.setAllowedOrigins("http://ec2....amazonaws.com")
.withSockJS()
.setHeartbeatTime(60_000);
}
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.4.3)
2021-03-03 00:44:34.278 INFO 5898 --- [ main] com.example.salle.SalleApplication : Starting SalleApplication v0.0.1-SNAPSHOT using Java 1.8.0_282 on ip-172-31-46-33 with PID 5898 (/home/ubuntu/salle/salle/target/test-0.0.1-SNAPSHOT.jar started by ubuntu in /home/ubuntu/salle/salle)
2021-03-03 00:44:34.283 INFO 5898 --- [ main] com.example.salle.SalleApplication : No active profile set, falling back to default profiles: default
2021-03-03 00:44:36.435 INFO 5898 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-03-03 00:44:36.489 INFO 5898 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 31 ms. Found 0 JPA repository interfaces.
2021-03-03 00:44:38.298 INFO 5898 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2021-03-03 00:44:38.330 INFO 5898 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-03-03 00:44:38.330 INFO 5898 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.43]
2021-03-03 00:44:39.363 INFO 5898 --- [ main] org.apache.jasper.servlet.TldScanner : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2021-03-03 00:44:39.969 INFO 5898 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-03-03 00:44:39.969 INFO 5898 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 5536 ms
2021-03-03 00:44:41.016 INFO 5898 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-03-03 00:44:41.247 INFO 5898 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-03-03 00:44:41.408 INFO 5898 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-03-03 00:44:41.600 INFO 5898 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.28.Final
2021-03-03 00:44:41.900 INFO 5898 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-03-03 00:44:42.217 INFO 5898 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MariaDB103Dialect
2021-03-03 00:44:43.125 INFO 5898 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
ct.MariaDB103Dialect
2021-03-03 00:44:43.155 INFO 5898 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-03-03 00:44:45.786 INFO 5898 --- [ main] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService
2021-03-03 00:44:45.860 INFO 5898 --- [ main] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService 'messageBrokerTaskScheduler'
2021-03-03 00:44:46.023 INFO 5898 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'clientInboundChannelExecutor'
2021-03-03 00:44:46.025 INFO 5898 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'clientOutboundChannelExecutor'
2021-03-03 00:44:46.035 INFO 5898 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'brokerChannelExecutor'
2021-03-03 00:44:46.140 WARN 5898 --- [ 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-03-03 00:44:47.221 INFO 5898 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2021-03-03 00:44:47.227 INFO 5898 --- [ main] o.s.m.s.b.SimpleBrokerMessageHandler : Starting...
2021-03-03 00:44:47.227 INFO 5898 --- [ main] o.s.m.s.b.SimpleBrokerMessageHandler : BrokerAvailabilityEvent[available=true, SimpleBrokerMessageHandler [DefaultSubscriptionRegistry[cache[0 destination(s)], registry[0 sessions]]]]
2021-03-03 00:44:47.233 INFO 5898 --- [ main] o.s.m.s.b.SimpleBrokerMessageHandler : Started.
2021-03-03 00:44:47.252 INFO 5898 --- [ main] com.example.salle.SalleApplication : Started SalleApplication in 14.288 seconds (JVM running for 15.469)
2021-03-03 00:45:00.256 INFO 5898 --- [extShutdownHook] o.s.m.s.b.SimpleBrokerMessageHandler : Stopping...
2021-03-03 00:45:00.258 INFO 5898 --- [extShutdownHook] o.s.m.s.b.SimpleBrokerMessageHandler : BrokerAvailabilityEvent[available=false, SimpleBrokerMessageHandler [DefaultSubscriptionRegistry[cache[0 destination(s)], registry[0 sessions]]]]
2021-03-03 00:45:00.258 INFO 5898 --- [extShutdownHook] o.s.m.s.b.SimpleBrokerMessageHandler : Stopped.
2021-03-03 00:45:00.284 INFO 5898 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'brokerChannelExecutor'
2021-03-03 00:45:00.284 INFO 5898 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'clientOutboundChannelExecutor'
2021-03-03 00:45:00.284 INFO 5898 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'clientInboundChannelExecutor'
2021-03-03 00:45:00.284 INFO 5898 --- [extShutdownHook] o.s.s.c.ThreadPoolTaskScheduler : Shutting down ExecutorService 'messageBrokerTaskScheduler'
2021-03-03 00:45:00.296 INFO 5898 --- [extShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2021-03-03 00:45:00.299 INFO 5898 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...```
The easiest way to put a Spring BOOT app on an EC2 instance is to use Elastic Beanstalk. Read this AWS doc for more details - https://aws.amazon.com/blogs/devops/deploying-a-spring-boot-application-on-aws-using-aws-elastic-beanstalk/

How can I create a webapp with Spring (Tomcat server) and Maven?

I get the console message below when running my application but every time I navigate to http://localhost:8080/? I get an error message saying:
"Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Tue Jan 12 22:04:40 EST 2021
There was an unexpected error (type=Not Found, status=404)"
Console Output:
2021-01-12 22:03:17.212 INFO 21710 --- [ main] com.crd.carrental.CarRentalApplication : No active profile set, falling back to default profiles: default
2021-01-12 22:03:18.343 INFO 21710 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2021-01-12 22:03:18.350 INFO 21710 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-01-12 22:03:18.350 INFO 21710 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.39]
2021-01-12 22:03:18.424 INFO 21710 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-01-12 22:03:18.424 INFO 21710 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1073 ms
2021-01-12 22:03:18.539 INFO 21710 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'clientInboundChannelExecutor'
2021-01-12 22:03:18.542 INFO 21710 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'clientOutboundChannelExecutor'
2021-01-12 22:03:18.548 INFO 21710 --- [ main] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService 'messageBrokerTaskScheduler'
2021-01-12 22:03:18.613 INFO 21710 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'brokerChannelExecutor'
2021-01-12 22:03:19.539 INFO 21710 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2021-01-12 22:03:19.541 INFO 21710 --- [ main] o.s.m.s.b.SimpleBrokerMessageHandler : Starting...
2021-01-12 22:03:19.541 INFO 21710 --- [ main] o.s.m.s.b.SimpleBrokerMessageHandler : BrokerAvailabilityEvent[available=true, SimpleBrokerMessageHandler [DefaultSubscriptionRegistry[cache[0 destination(s)], registry[0 sessions]]]]
2021-01-12 22:03:19.541 INFO 21710 --- [ main] o.s.m.s.b.SimpleBrokerMessageHandler : Started.
2021-01-12 22:03:19.551 INFO 21710 --- [ main] com.crd.carrental.CarRentalApplication : Started CarRentalApplication in 2.977 seconds (JVM running for 5.797)
2021-01-12 22:04:18.616 INFO 21710 --- [MessageBroker-1] o.s.w.s.c.WebSocketMessageBrokerStats : WebSocketSession[0 current WS(0)-HttpStream(0)-HttpPoll(0), 0 total, 0 closed abnormally (0 connect failure, 0 send limit, 0 transport error)], stompSubProtocol[processed CONNECT(0)-CONNECTED(0)-DISCONNECT(0)], stompBrokerRelay[null], inboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0], outboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0], sockJsScheduler[pool size = 1, active threads = 1, queued tasks = 0, completed tasks = 0]
2021-01-12 22:04:23.920 INFO 21710 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2021-01-12 22:04:23.920 INFO 21710 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2021-01-12 22:04:23.929 INFO 21710 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 9 ms```
Make sure you have defined a Controller for the requested url "/" as below:
#RequestMapping("/")
public String homePage() {
... <your code>
return "home";
}
And, your home page have to be stored in below path:
|--resources
|--templates
|--home.html
white label error comes when there no page for that URL, you are searching. so in your controller see whether there is a mapping for "/".
The White Error label is the expected behavior of an empty Spring application without any Controller Path. Unless you haven't configured any REST path or endpoint, this error will be shown.
If the error persist, make sure that your main application class extends the SpringBootServletInitializer and that you are writing the propery endpoint path.

Spring Boot 2.3 DataSource injection

I have issues with recent Springboot 2.3 release.
I have the following config class:
package name.defance.springbootdemo.security;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
#Configuration
public class SampleConfig {
#Autowired
public SampleConfig(DataSource dataSource) {
System.out.println("DATASOURCE: " + dataSource);
this.dataSource = dataSource;
}
final private DataSource dataSource;
}
With version 2.2.7 I have the following output:
<... truncated output ...>
2020-05-18 17:57:33.872 INFO 2081 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-05-18 17:57:33.873 INFO 2081 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.34]
2020-05-18 17:57:33.950 INFO 2081 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-05-18 17:57:33.950 INFO 2081 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2113 ms
2020-05-18 17:57:34.511 INFO 2081 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-05-18 17:57:34.555 INFO 2081 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.15.Final
2020-05-18 17:57:34.686 INFO 2081 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-05-18 17:57:34.801 INFO 2081 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-05-18 17:57:34.901 INFO 2081 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-05-18 17:57:34.922 INFO 2081 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL10Dialect
2020-05-18 17:57:35.405 INFO 2081 --- [ restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-05-18 17:57:35.411 INFO 2081 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-05-18 17:57:35.463 WARN 2081 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : Unable to start LiveReload server
DATASOURCE: HikariDataSource (HikariPool-1)
<... truncated output ...>
With version 2.3.0.RELEASE I have the following:
<... truncated output ...>
2020-05-18 17:52:02.183 INFO 352 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-05-18 17:52:02.184 INFO 352 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.35]
2020-05-18 17:52:02.249 INFO 352 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-05-18 17:52:02.249 INFO 352 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2453 ms
2020-05-18 17:52:02.669 INFO 352 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
DATASOURCE: HikariDataSource (null)
2020-05-18 17:52:02.720 INFO 352 --- [ task-1] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-05-18 17:52:02.755 INFO 352 --- [ task-1] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.15.Final
2020-05-18 17:52:02.862 INFO 352 --- [ task-1] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-05-18 17:52:02.957 INFO 352 --- [ task-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-05-18 17:52:03.066 INFO 352 --- [ task-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-05-18 17:52:03.081 INFO 352 --- [ task-1] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL10Dialect
2020-05-18 17:52:03.526 INFO 352 --- [ task-1] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-05-18 17:52:03.534 INFO 352 --- [ task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-05-18 17:52:03.736 WARN 352 --- [ task-2] o.s.b.d.a.OptionalLiveReloadServer : Unable to start LiveReload server
<... truncated output ...>
The only difference between those is (in pom.xml):
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
vs
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
So with the new release datasource bean is configured in a separate thread, and my configuration bean received not-yet configured DataSource bean (null).
I cannot find any reference to configuration flow changes in release notes. What is wrong here, and why my code stopped working?
UPDATE. I reproduced this issue once more with Spring initializer. Options selected: Java 14, actuator, jdbc, web, devtools, postgres db driver
Application properties contains all the correct connection data (verified on other old-spring project). Its only contents is:
spring.datasource.url=jdbc:postgresql://localhost:15432/insurance-demo
spring.datasource.username=postgres
spring.datasource.password=postgresPWD
server.port=8080
Update: Project repo https://github.com/defance/datasource-demo
It looks like 'spring-boot-starter-data-jpa' can be added to the dependency set to bring the hikari pool start back to the same point it was before.
Using your repository, I added this section to the pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
and the result:
2020-05-18 09:58:17.046 INFO 60543 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-05-18 09:58:17.094 INFO 60543 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
DATASOURCE: HikariDataSource (HikariPool-1)
Here is the doc section about data source configuration that I followed:
https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-sql

Categories

Resources