1

I want deploy a spring boot web application on tomcat external but error, I can't fix it. Please help me, thank you very much.

application.properties

server.port=8080
spring.datasource.url=jdbc:mysql://localhost:3306/springboot?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect
#spring.jpa.properties.hibernate.id.new_generator_mappings = false
spring.jpa.properties.hibernate.format_sql = true

Log

java.lang.Object.wait(Native Method)
 java.lang.ref.ReferenceQueue.remove(Unknown Source)
 com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:70)
 java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
 java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
 java.lang.Thread.run(Unknown Source)
14-Jan-2019 16:25:53.860 INFO [http-nio-8080-exec-2] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive C:\Server\Tomcat-8.5\webapps\springboot-0.0.1-SNAPSHOT.war has finished in 12,765 ms
14-Jan-2019 16:25:54.713 INFO [Abandoned connection cleanup thread] org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading Illegal access: this web application instance has been stopped already. Could not load []. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
 java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load []. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
        at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1305)
        at org.apache.catalina.loader.WebappClassLoaderBase.getResource(WebappClassLoaderBase.java:986)
        at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.checkContextClassLoaders(AbandonedConnectionCleanupThread.java:96)
        at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:69)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
bathudaide
  • 737
  • 1
  • 4
  • 12

2 Answers2

3

Change your config to provided of mysql driver, if you compile the driver with the war, when you deploy on tomcat, many thread can't be removed.

I had the same problem with a gradle project, my config was:

runtime 'mysql:mysql-connector-java:8.0.13'

and i change that for

provided 'mysql:mysql-connector-java:8.0.13'

that solved my problem

1

The solution of https://stackoverflow.com/a/55730497/3906760 requires that the MySQL Connector/J is used as a shared lib on Tomcat (cf. https://stackoverflow.com/a/19190060/3906760).

If you don't want to or can't do that, you should stop the thread manually using a context listener, cf. https://stackoverflow.com/a/19189613/3906760.

Some information about other approaches are listed here (search for AbandonedConnectionCleanupThread): https://dev.mysql.com/doc/relnotes/connector-j/5.1/en/news-5-1-41.html

MrTux
  • 32,350
  • 30
  • 109
  • 146