I'm trying to run a Spring Boot application with HTTPS enabled on the Digital Ocean droplet. The application ran previously with no issues until a recent restart from the server.
I keep getting "Failed to start bean 'webServerStartStop'... Unable to start embedded Tomcat server" error.
How can I start to debug this? I tried to capture the output log from the server in a .txt file, and this is the output.
Things I have tried:
Rolling back to a previous app version
Updating MySQL version
Updating server
I'm running:
Java 11 - jar app
MySQL v8.0.25 Community Server
2021-07-09 04:04:37.224 INFO 9278 --- [ task-1] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] 2021-07-09 04:04:37.238 INFO 9278 --- [ task-1] j.LocalContainerEntityManagerFactoryBean
: Initialized JPA EntityManagerFactory for persistence unit 'default' 2021-07-09 04:04:40.570 INFO 9278 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: OrRequestMatcher [requestMatchers=[Ant [pattern='/oauth/token'], Ant [pattern='/oauth/token_key'],
Ant [pattern='/oauth/check_token']]], [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#4248b963, org.springframework.security.web.context.SecurityContextPersistenceFilter#1dc76fa1, org.springframework.security.web.header.HeaderWriterFilter#2f508f3c,
org.springframework.security.web.authentication.logout.LogoutFilter#ad9e63e, org.springframework.security.web.authentication.www.BasicAuthenticationFilter#3abfe845, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#33d53216, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#7808f638,
org.springframework.security.web.authentication.AnonymousAuthenticationFilter#7f08caf, org.springframework.security.web.session.SessionManagementFilter#2459319c, org.springframework.security.web.access.ExceptionTranslationFilter#71f0b72e, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#2650f79]
2021-07-09 04:04:40.607 INFO 9278 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfiguration$NotOAuthRequestMatcher#7be3a9ce, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#37d871c2,
org.springframework.security.web.context.SecurityContextPersistenceFilter#2c0b4c83, org.springframework.security.web.header.HeaderWriterFilter#4893b344, org.springframework.web.filter.CorsFilter#3baf6936, org.springframework.security.web.authentication.logout.LogoutFilter#3bfc6a5e,
org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter#62db0521, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#78525ef9, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#2d0ecb24,
org.springframework.security.web.authentication.AnonymousAuthenticationFilter#285f38f6, org.springframework.security.web.session.SessionManagementFilter#53a665ad, org.springframework.security.web.access.ExceptionTranslationFilter#249e0271, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#4acb2510]
2021-07-09 04:04:40.610 INFO 9278 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#27b2faa6, org.springframework.security.web.context.SecurityContextPersistenceFilter#57c47a9e,
org.springframework.security.web.header.HeaderWriterFilter#4eed2acf, org.springframework.security.web.authentication.logout.LogoutFilter#61d84e08, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#642505c7, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#4339e0de,
org.springframework.security.web.authentication.AnonymousAuthenticationFilter#6428591a, org.springframework.security.web.session.SessionManagementFilter#36fc05ff, org.springframework.security.web.access.ExceptionTranslationFilter#476e8796, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#715d6168]
2021-07-09 04:04:40.779 WARN 9278 --- [ 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.WebServerException: Unable to start embedded Tomcat server 2021-07-09 04:04:40.784 INFO 9278 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence
unit 'default' 2021-07-09 04:04:40.785 INFO 9278 --- [ main] .SchemaDropperImpl$DelayedDropActionImpl : HHH000477: Starting delayed evictData of schema as part of SessionFactory shut-down' 2021-07-09 04:04:40.786 DEBUG 9278 --- [ main] org.hibernate.SQL
: alter table contacts drop foreign key FKna8bddygr3l3kq1imghgcskt8 2021-07-09 04:04:40.808 DEBUG 9278 --- [ main] org.hibernate.SQL : alter table leads drop foreign key FK50ynw1akb9fok4ronueu0efpk 2021-07-09 04:04:40.934 DEBUG 9278 --- [ main] org.hibernate.SQL
: alter table leads drop foreign key FK10u8b7klywjncgkn7xffx7ncu 2021-07-09 04:04:41.033 DEBUG 9278 --- [ main] org.hibernate.SQL : alter table leads_notes drop foreign key FKhpoad9uf9y5lh6nv7iqb06uk2 2021-07-09 04:04:41.065 DEBUG 9278 --- [ main] org.hibernate.SQL
: alter table leads_notes drop foreign key FK6tw7yuipyu91x1d4csegdumpt 2021-07-09 04:04:41.093 DEBUG 9278 --- [ main] org.hibernate.SQL : alter table submissions drop foreign key FKpy8k2vjp2ax1glqn4tc77f362 2021-07-09 04:04:41.169 DEBUG 9278 --- [ main]
org.hibernate.SQL : alter table submissions drop foreign key FKhwyuy355rlq3e0d1lw5nxywum 2021-07-09 04:04:41.196 DEBUG 9278 --- [ main] org.hibernate.SQL : alter table submissions drop foreign key FKhfixvturyi8nqcvr8qbujkmmd 2021-07-09 04:04:41.227 DEBUG
9278 --- [ main] org.hibernate.SQL : alter table submissions drop foreign key FKaddc6b566b2j07ndp34akltik 2021-07-09 04:04:41.252 DEBUG 9278 --- [ main] org.hibernate.SQL : alter table users drop foreign key FKin8gn4o1hpiwe6qe4ey7ykwq7 2021-07-09 04:04:41.300
DEBUG 9278 --- [ main] org.hibernate.SQL : alter table users_roles drop foreign key FKa62j07k5mhgifpp955h37ponj 2021-07-09 04:04:41.331 DEBUG 9278 --- [ main] org.hibernate.SQL : alter table users_roles drop foreign key FK2o0jvgh89lemvvo17cbqvdxaa 2021-07-09
04:04:41.353 DEBUG 9278 --- [ main] org.hibernate.SQL : drop table if exists categories 2021-07-09 04:04:41.361 DEBUG 9278 --- [ main] org.hibernate.SQL : drop table if exists companies 2021-07-09 04:04:41.377 DEBUG 9278 --- [ main] org.hibernate.SQL
: drop table if exists contacts 2021-07-09 04:04:41.397 DEBUG 9278 --- [ main] org.hibernate.SQL : drop table if exists leads 2021-07-09 04:04:41.446 DEBUG 9278 --- [ main] org.hibernate.SQL : drop table if exists leads_notes 2021-07-09 04:04:41.465 DEBUG
9278 --- [ main] org.hibernate.SQL : drop table if exists leads_status 2021-07-09 04:04:41.474 DEBUG 9278 --- [ main] org.hibernate.SQL : drop table if exists products 2021-07-09 04:04:41.482 DEBUG 9278 --- [ main] org.hibernate.SQL : drop table if exists
roles 2021-07-09 04:04:41.493 DEBUG 9278 --- [ main] org.hibernate.SQL : drop table if exists submissions 2021-07-09 04:04:41.503 DEBUG 9278 --- [ main] org.hibernate.SQL : drop table if exists submissions_status 2021-07-09 04:04:41.517 DEBUG 9278 ---
[ main] org.hibernate.SQL : drop table if exists users 2021-07-09 04:04:41.537 DEBUG 9278 --- [ main] org.hibernate.SQL : drop table if exists users_roles 2021-07-09 04:04:41.560 INFO 9278 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting
down ExecutorService 'applicationTaskExecutor' 2021-07-09 04:04:41.564 INFO 9278 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... 2021-07-09 04:04:41.585 INFO 9278 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1
- Shutdown completed. 2021-07-09 04:04:41.599 INFO 9278 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2021-07-09 04:04:41.636 INFO 9278 --- [ main] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext.
To display the conditions report re-run your application with 'debug' enabled. 2021-07-09 04:04:41.652 ERROR 9278 --- [ main] o.s.boot.SpringApplication : Application run failed org.springframework.context.ApplicationContextException: Failed to start
bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:185)
~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE] at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:53) ~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE] at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:360)
~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE] at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:158) ~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE] at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:122)
~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:894) ~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553)
~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758)
~[spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) ~[spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
~[spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237)
~[spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE] at com.maxwelton.investorportal.InvestorPortalBackendApplication.main(InvestorPortalBackendApplication.java:10)
~[classes!/:0.0.1-SNAPSHOT] 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:566) ~[na:na] at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[investor-portal-backend-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:109)
~[investor-portal-backend-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[investor-portal-backend-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
~[investor-portal-backend-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:229)
~[spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE] at org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:43) ~[spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE] at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:182)
~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE] ... 22 common frames omitted Caused by: java.lang.IllegalArgumentException: standardService.connector.startFailed at org.apache.catalina.core.StandardService.addConnector(StandardService.java:231) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:282) ~[spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE] at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:213)
~[spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE] ... 24 common frames omitted Caused by: org.apache.catalina.LifecycleException: Protocol handler start failed at org.apache.catalina.connector.Connector.startInternal(Connector.java:1058) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35] at org.apache.catalina.core.StandardService.addConnector(StandardService.java:227) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35] ... 26 common
frames omitted Caused by: java.lang.IllegalArgumentException: None of the [protocols] specified are supported by the SSL engine : [[TSLv1.2]] at org.apache.tomcat.util.net.SSLUtilBase.getEnabled(SSLUtilBase.java:151) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
at org.apache.tomcat.util.net.SSLUtilBase.
<init>(SSLUtilBase.java:109) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35] at org.apache.tomcat.util.net.SSLUtilBase.
<init>(SSLUtilBase.java:83) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35] at org.apache.tomcat.util.net.openssl.OpenSSLUtil.
<init>(OpenSSLUtil.java:42) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35] at org.apache.tomcat.util.net.openssl.OpenSSLImplementation.getSSLUtil(OpenSSLImplementation.java:36) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35] at org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(AbstractJsseEndpoint.java:88)
~[tomcat-embed-core-9.0.35.jar!/:9.0.35] at org.apache.tomcat.util.net.AbstractJsseEndpoint.initialiseSsl(AbstractJsseEndpoint.java:71) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35] at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:216)
~[tomcat-embed-core-9.0.35.jar!/:9.0.35] at org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1141) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35] at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1227)
~[tomcat-embed-core-9.0.35.jar!/:9.0.35] at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:592) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35] at org.apache.catalina.connector.Connector.startInternal(Connector.java:1055) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
... 28 common frames omitted
My DB properties are
spring.datasource.url=jdbc:mysql://localhost/db_investor_portal?useLegacyDatetimeCode=false&serverTimezone=UTC&useSSL=true
spring.datasource.username=**********
spring.datasource.password=**********
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect
spring.jpa.hibernate.ddl-auto=create-drop
spring.jackson.serialization.fail-on-empty-beans=false
logging.level.org.hibernate.SQL=debug
spring.servlet.multipart.max-file-size=10MB
spring.servlet.multipart.max-request-size=10MB
#SpringBoot SSL configuration for Digital Ocean
#server.ssl.enabled=true
#server.port=8443
#server.ssl.key-store=/etc/letsencrypt/live/*****
#server.ssl.key-store-password=***********
#server.ssl.key-store-type=PKCS12
#server.ssl.protocol=TLS
#server.ssl.enabled-protocols=TSLv1.2
#server.ssl.ciphers=TSL_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256, TLS_AES_128_GCM_SHA256
And my 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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.maxwelton.investorportal</groupId>
<artifactId>investor-portal-backend</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>investor-portal-backend</name>
<packaging>jar</packaging>
<description>Backend for MW Investor Portal</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-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
<version>8.0.24</version><!--$NO-MVN-MAN-VER$-->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.security.oauth/spring-security-oauth2 -->
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.3.5.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-jwt -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-jwt</artifactId>
<version>1.0.10.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.glassfish.jaxb/jaxb-runtime -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<mainClass>${start-class}</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.maxwelton.investorportal.InvestorPortalBackendApplication</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
The error says: None of the [protocols] specified are supported by the SSL engine : [[TSLv1.2]]
You have a typo in protocol name TSLv1.2 -> TLSv1.2
Also, there is a typo in cipher name, it must be TLS_AES_256_GCM_SHA384
I am facing issue while running my newly created spring boot application using spring initializer.
The embedded tomcat is failing to start with below error
org.springframework.context.ApplicationContextException: Failed to
start bean 'webServerStartStop'; nested exception is
org.springframework.boot.web.server.WebServerException: Unable to
start embedded Tomcat server
Below is the full exception stack trace message while running the application
SnapShooter listening on port 57894
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.4.4)
2021-04-25 11:48:44.048 INFO 2372 --- [ main] e.T.TransactionManagementBootApplication : Starting TransactionManagementBootApplication using Java 1.8.0_212 on DESKTOP-8UK0JH5 with PID 2372 (D:\core-java-practice-programs\Gradle_Practice\TransactionManagementBoot\target\classes started by dell in D:\core-java-practice-programs\Gradle_Practice)
2021-04-25 11:48:44.051 INFO 2372 --- [ main] e.T.TransactionManagementBootApplication : No active profile set, falling back to default profiles: default
2021-04-25 11:48:44.866 INFO 2372 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-04-25 11:48:44.880 INFO 2372 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 5 ms. Found 0 JPA repository interfaces.
2021-04-25 11:48:45.827 INFO 2372 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8085 (http)
2021-04-25 11:48:45.837 INFO 2372 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-04-25 11:48:45.837 INFO 2372 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.44]
2021-04-25 11:48:45.980 INFO 2372 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-04-25 11:48:45.980 INFO 2372 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1865 ms
2021-04-25 11:48:46.028 INFO 2372 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-04-25 11:48:46.195 INFO 2372 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-04-25 11:48:46.202 INFO 2372 --- [ main] o.s.b.a.h2.H2ConsoleAutoConfiguration : H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:ashok'
2021-04-25 11:48:46.448 INFO 2372 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-04-25 11:48:46.502 INFO 2372 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.29.Final
2021-04-25 11:48:46.616 INFO 2372 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-04-25 11:48:46.722 INFO 2372 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2021-04-25 11:48:47.222 INFO 2372 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-04-25 11:48:47.231 INFO 2372 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-04-25 11:48:47.279 WARN 2372 --- [ 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-04-25 11:48:47.414 INFO 2372 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2021-04-25 11:48:47.660 INFO 2372 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Marking servlet [jsp] as unavailable
2021-04-25 11:48:47.662 WARN 2372 --- [ 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.WebServerException: Unable to start embedded Tomcat server
2021-04-25 11:48:47.664 INFO 2372 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2021-04-25 11:48:47.664 INFO 2372 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2021-04-25 11:48:47.664 INFO 2372 --- [ main] .SchemaDropperImpl$DelayedDropActionImpl : HHH000477: Starting delayed evictData of schema as part of SessionFactory shut-down'
2021-04-25 11:48:47.670 INFO 2372 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2021-04-25 11:48:47.671 INFO 2372 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2021-04-25 11:48:48.013 INFO 2372 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2021-04-25 11:48:48.041 INFO 2372 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-04-25 11:48:48.056 ERROR 2372 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181) ~[spring-context-5.3.5.jar:5.3.5]
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54) ~[spring-context-5.3.5.jar:5.3.5]
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356) ~[spring-context-5.3.5.jar:5.3.5]
at java.lang.Iterable.forEach(Iterable.java:75) ~[na:1.8.0_212]
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155) ~[spring-context-5.3.5.jar:5.3.5]
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123) ~[spring-context-5.3.5.jar:5.3.5]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935) ~[spring-context-5.3.5.jar:5.3.5]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) ~[spring-context-5.3.5.jar:5.3.5]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) ~[spring-boot-2.4.4.jar:2.4.4]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:769) [spring-boot-2.4.4.jar:2.4.4]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-2.4.4.jar:2.4.4]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426) [spring-boot-2.4.4.jar:2.4.4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:326) [spring-boot-2.4.4.jar:2.4.4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1313) [spring-boot-2.4.4.jar:2.4.4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) [spring-boot-2.4.4.jar:2.4.4]
at com.example.TransactionManagementBoot.TransactionManagementBootApplication.main(TransactionManagementBootApplication.java:10) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_212]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_212]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_212]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_212]
at com.intellij.uiDesigner.snapShooter.SnapShooter.main(SnapShooter.java:58) [uiDesigner.jar:na]
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:229) ~[spring-boot-2.4.4.jar:2.4.4]
at org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:43) ~[spring-boot-2.4.4.jar:2.4.4]
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178) ~[spring-context-5.3.5.jar:5.3.5]
... 20 common frames omitted
Caused by: org.springframework.boot.web.server.WebServerException: Servlet [jsp] in web application [] threw load() exception
at org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedContext.load(TomcatEmbeddedContext.java:87) ~[spring-boot-2.4.4.jar:2.4.4]
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) ~[na:1.8.0_212]
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382) ~[na:1.8.0_212]
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580) ~[na:1.8.0_212]
at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:270) ~[na:1.8.0_212]
at java.util.TreeMap$ValueSpliterator.forEachRemaining(TreeMap.java:2897) ~[na:1.8.0_212]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) ~[na:1.8.0_212]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) ~[na:1.8.0_212]
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) ~[na:1.8.0_212]
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) ~[na:1.8.0_212]
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:1.8.0_212]
at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) ~[na:1.8.0_212]
at org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedContext.lambda$deferredLoadOnStartup$0(TomcatEmbeddedContext.java:65) ~[spring-boot-2.4.4.jar:2.4.4]
at org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedContext.doWithThreadContextClassLoader(TomcatEmbeddedContext.java:106) ~[spring-boot-2.4.4.jar:2.4.4]
at org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedContext.deferredLoadOnStartup(TomcatEmbeddedContext.java:64) ~[spring-boot-2.4.4.jar:2.4.4]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.performDeferredLoadOnStartup(TomcatWebServer.java:305) ~[spring-boot-2.4.4.jar:2.4.4]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:216) ~[spring-boot-2.4.4.jar:2.4.4]
... 22 common frames omitted
Caused by: javax.servlet.ServletException: Class [org.apache.jasper.servlet.JspServlet] is not a Servlet
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1047) ~[tomcat-embed-core-9.0.44.jar:9.0.44]
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:983) ~[tomcat-embed-core-9.0.44.jar:9.0.44]
at org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedContext.load(TomcatEmbeddedContext.java:82) ~[spring-boot-2.4.4.jar:2.4.4]
... 38 common frames omitted
Caused by: java.lang.ClassCastException: org.apache.jasper.servlet.JspServlet cannot be cast to javax.servlet.Servlet
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1042) ~[tomcat-embed-core-9.0.44.jar:9.0.44]
... 40 common frames omitted
Process finished with exit code 1
My Pom.xml file is as below
<?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.4.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>TransactionManagementBoot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>TransactionManagementBoot</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<scope>compile</scope>
</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.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jasper</artifactId>
<version>10.0.4</version>
</dependency>
<dependency>
<groupId>jakarta.servlet.jsp</groupId>
<artifactId>jakarta.servlet.jsp-api</artifactId>
<version>3.0.0-M1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
My Run config is as below
Run Config Snapshot
Any help will be highly appreciated
If you want to use embedded tomcat in spring boot, you must change your dependency libriary tomcat-jasper to tomcat-embed-jasper.
There is spring-boot-starter-tomcat in spring-boot-starter-web. you can see here.
There is tomcat-embed-core in spring-boot-starter-tomcat to use embedded tomcat. you can see here.
embed-jaspser which includes dependency with tomcat-embed-core. you can see here.
The tomcat-jasper you used is unnecessary because it doesn't include with dependency tomcat-embed-core. you can see here.
The version of JSP that comes with Tomcat 10 is not compatible with the embedded Tomcat 9: Tomcat 9 is a Servlet 4.0 servlet container, while Tomcat 10 is a Servlet 5.0 servlet container (cf. this question).
Therefore you should use a version of Jasper compatible with your version of Tomcat. Since spring-boot-starter-parent manages the versions of Tomcat dependencies, just delete the <version> property:
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
and remove the jakarta.servlet.jsp-api dependency.
Edit: Remark also that the scope of tomcat-embed-jasper should be provided so Spring Boot will not package it into WEB-INF/lib (it will put it into WEB-INF/lib-provided instead) and you will not encounter version conflicts if you deploy the project to an external Tomcat.
You can find the list of artifacts for which Spring Boot manages the versions in the spring-boot-dependencies POM.
I had the same problem. I dont know why but when I put spring-boot-starter-web dependency first in the dependency list in the pom file it got resolved on its own! Please confirm if this works for anyone else too.
I've posted a relatively similar question in the past here. I am attempting to configure my environment to work with VirtualBox so I can use Linux related tools to manage the servers. Currently, I am attempting to connect my Spring Boot web application to my Ubuntu MySQL server on my VirtualBox machine.
Problem
When attempting to connect to my MySQL server with my Spring Boot application, I received this error message:
2020-06-06 08:16:02.390 INFO 2936 --- [ restartedMain] c.c.mvcblog.SpringMvcBlogApplication : Starting SpringMvcBlogApplication on DESKTOP-AS2P0GJ with PID 2936 (C:\Users\rocke\IdeaProjects\mvc-blog\target\classes started by rocke in C:\Users\rocke\IdeaProjects\mvc-blog)
2020-06-06 08:16:02.396 INFO 2936 --- [ restartedMain] c.c.mvcblog.SpringMvcBlogApplication : No active profile set, falling back to default profiles: default
2020-06-06 08:16:02.480 INFO 2936 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2020-06-06 08:16:02.480 INFO 2936 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2020-06-06 08:16:04.076 INFO 2936 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFERRED mode.
2020-06-06 08:16:04.215 INFO 2936 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 127ms. Found 2 JPA repository interfaces.
2020-06-06 08:16:05.913 INFO 2936 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-06-06 08:16:05.940 INFO 2936 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-06-06 08:16:05.940 INFO 2936 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.35]
2020-06-06 08:16:06.141 INFO 2936 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-06-06 08:16:06.141 INFO 2936 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3660 ms
2020-06-06 08:16:06.474 INFO 2936 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-06-06 08:16:06.572 INFO 2936 --- [ task-1] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-06-06 08:16:06.672 WARN 2936 --- [ 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-06-06 08:16:06.788 INFO 2936 --- [ task-1] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.15.Final
2020-06-06 08:16:07.055 INFO 2936 --- [ task-1] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-06-06 08:16:07.205 INFO 2936 --- [ task-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-06-06 08:16:10.357 ERROR 2936 --- [ task-1] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization.
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174) ~[mysql-connector-java-8.0.20.jar:8.0.20]
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64) ~[mysql-connector-java-8.0.20.jar:8.0.20]
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836) ~[mysql-connector-java-8.0.20.jar:8.0.20]
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456) ~[mysql-connector-java-8.0.20.jar:8.0.20]
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246) ~[mysql-connector-java-8.0.20.jar:8.0.20]
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197) ~[mysql-connector-java-8.0.20.jar:8.0.20]
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) ~[HikariCP-3.4.5.jar:na]
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:358) ~[HikariCP-3.4.5.jar:na]
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206) ~[HikariCP-3.4.5.jar:na]
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:477) ~[HikariCP-3.4.5.jar:na]
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:560) ~[HikariCP-3.4.5.jar:na]
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115) ~[HikariCP-3.4.5.jar:na]
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) ~[HikariCP-3.4.5.jar:na]
at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) ~[hibernate-core-5.4.15.Final.jar:5.4.15.Final]
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:180) ~[hibernate-core-5.4.15.Final.jar:5.4.15.Final]
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:68) ~[hibernate-core-5.4.15.Final.jar:5.4.15.Final]
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) ~[hibernate-core-5.4.15.Final.jar:5.4.15.Final]
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:101) ~[hibernate-core-5.4.15.Final.jar:5.4.15.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263) ~[hibernate-core-5.4.15.Final.jar:5.4.15.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237) ~[hibernate-core-5.4.15.Final.jar:5.4.15.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) ~[hibernate-core-5.4.15.Final.jar:5.4.15.Final]
at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:152) ~[hibernate-core-5.4.15.Final.jar:5.4.15.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286) ~[hibernate-core-5.4.15.Final.jar:5.4.15.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243) ~[hibernate-core-5.4.15.Final.jar:5.4.15.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) ~[hibernate-core-5.4.15.Final.jar:5.4.15.Final]
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:176) ~[hibernate-core-5.4.15.Final.jar:5.4.15.Final]
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:118) ~[hibernate-core-5.4.15.Final.jar:5.4.15.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1214) ~[hibernate-core-5.4.15.Final.jar:5.4.15.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1245) ~[hibernate-core-5.4.15.Final.jar:5.4.15.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58) ~[spring-orm-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:391) ~[spring-orm-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure
A handful of resources I found online related to this topic were dealing with invalid login attempts, invalid MySQL queries, or invalid dialects.
Debugging Information
I am able to ping the virtual machine when actively running. I ended up installing MySQL directly onto my local machine (Windows 10) and attempted to connect directly that way. After squashing a few bugs related to me using the wrong dialect, I was able to connect directly to my MySQL database on my local machine. However, switching back at that point to my Ubuntu hosted MySQL server still resulted in the same error message. I have also verified that the MySQL service is running. Lastly, I've also tried adding the 3306 port for MySQL.
Code
You can find my current repository here. I'll show the most important pieces of my project here.
application.properties
spring.datasource.driver-class-name = com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://192.168.0.101:3306/blog_db
spring.datasource.username=root
spring.datasource.password=mIThl
# Configure Hibernate DDL mode: create / update
spring.jpa.properties.hibernate.hbm2ddl.auto = create
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
Maven Pom Dependencies:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>2.3.0.RELEASE</version>
</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>
<!-- https://mvnrepository.com/artifact/javax.validation/validation-api -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
Additionally, my Spring Boot Parent version is 2.3.0.RELEASE.
I greatly appreciate any help given! I'm eager to improve my development process by incorporating VirtualBox VM's and am hoping to be able to find a resolution for this issue. Thank you!
I've created a Spring Boot application using version 2.2.0.BUILD-SNAPSHOT with Java 11 (POM below):
<?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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.0.BUILD-SNAPSHOT</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.mycompany</groupId>
<artifactId>Eureka-Service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Eureka-Service</name>
<description>Spring Boot Eureka Service</description>
<properties>
<java.version>11</java.version>
<spring-cloud.version>Greenwich.BUILD-SNAPSHOT</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</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>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</pluginRepository>
</pluginRepositories>
</project>
When the app starts up, it throws this exception:
2018-12-30 14:09:43.584 INFO 1305 --- [ main]
c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec
XStreamXml
2018-12-30 14:09:43.584 INFO 1305 --- [ main]
c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec
XStreamXml
2018-12-30 14:09:43.710 ERROR 1305 --- [ main] c.s.j.s.i.w.WadlApplicationContextImpl : Implementation of JAXB-API has not been found on module path or classpath.
javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:177) ~[jaxb-api-2.3.1.jar:2.3.0]
at javax.xml.bind.ContextFinder.find(ContextFinder.java:364) ~[jaxb-api-2.3.1.jar:2.3.0]
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:508) ~[jaxb-api-2.3.1.jar:2.3.0]
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:465) ~[jaxb-api-2.3.1.jar:2.3.0]
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:366) ~[jaxb-api-2.3.1.jar:2.3.0]
at com.sun.jersey.server.impl.wadl.WadlApplicationContextImpl.<init>(WadlApplicationContextImpl.java:107) ~[jersey-server-1.19.1.jar:1.19.1]
at com.sun.jersey.server.impl.wadl.WadlFactory.init(WadlFactory.java:100) ~[jersey-server-1.19.1.jar:1.19.1]
at com.sun.jersey.server.impl.application.RootResourceUriRules.initWadl(RootResourceUriRules.java:169) ~[jersey-server-1.19.1.jar:1.19.1]
at com.sun.jersey.server.impl.application.RootResourceUriRules.<init>(RootResourceUriRules.java:106) ~[jersey-server-1.19.1.jar:1.19.1]
at com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1359) ~[jersey-server-1.19.1.jar:1.19.1]
at com.sun.jersey.server.impl.application.WebApplicationImpl.access$700(WebApplicationImpl.java:180) ~[jersey-server-1.19.1.jar:1.19.1]
at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:799) ~[jersey-server-1.19.1.jar:1.19.1]
at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:795) ~[jersey-server-1.19.1.jar:1.19.1]
at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193) ~[jersey-core-1.19.1.jar:1.19.1]
at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:795) ~[jersey-server-1.19.1.jar:1.19.1]
at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:790) ~[jersey-server-1.19.1.jar:1.19.1]
at com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:509) ~[jersey-servlet-1.19.1.jar:1.19.1]
at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:339) ~[jersey-servlet-1.19.1.jar:1.19.1]
at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605) ~[jersey-servlet-1.19.1.jar:1.19.1]
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:207) ~[jersey-servlet-1.19.1.jar:1.19.1]
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:394) ~[jersey-servlet-1.19.1.jar:1.19.1]
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:744) ~[jersey-servlet-1.19.1.jar:1.19.1]
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:270) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:106) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4511) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5157) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1382) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1372) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) ~[na:na]
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:907) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:831) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1382) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1372) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) ~[na:na]
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:907) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:423) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:933) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:398) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:106) ~[spring-boot-2.2.0.BUILD-SNAPSHOT.jar:2.2.0.BUILD-SNAPSHOT]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:86) ~[spring-boot-2.2.0.BUILD-SNAPSHOT.jar:2.2.0.BUILD-SNAPSHOT]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:414) ~[spring-boot-2.2.0.BUILD-SNAPSHOT.jar:2.2.0.BUILD-SNAPSHOT]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:174) ~[spring-boot-2.2.0.BUILD-SNAPSHOT.jar:2.2.0.BUILD-SNAPSHOT]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:181) ~[spring-boot-2.2.0.BUILD-SNAPSHOT.jar:2.2.0.BUILD-SNAPSHOT]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:154) ~[spring-boot-2.2.0.BUILD-SNAPSHOT.jar:2.2.0.BUILD-SNAPSHOT]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:540) ~[spring-context-5.1.4.BUILD-SNAPSHOT.jar:5.1.4.BUILD-SNAPSHOT]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.2.0.BUILD-SNAPSHOT.jar:2.2.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) ~[spring-boot-2.2.0.BUILD-SNAPSHOT.jar:2.2.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.2.0.BUILD-SNAPSHOT.jar:2.2.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) ~[spring-boot-2.2.0.BUILD-SNAPSHOT.jar:2.2.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) ~[spring-boot-2.2.0.BUILD-SNAPSHOT.jar:2.2.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) ~[spring-boot-2.2.0.BUILD-SNAPSHOT.jar:2.2.0.BUILD-SNAPSHOT]
at com.orbis.EurekaServiceApplication.main(EurekaServiceApplication.java:13) ~[classes/:na]
Caused by: java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory
at org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedWebappClassLoader.loadClass(TomcatEmbeddedWebappClassLoader.java:70) ~[spring-boot-2.2.0.BUILD-SNAPSHOT.jar:2.2.0.BUILD-SNAPSHOT]
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1173) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
at javax.xml.bind.ServiceLoaderUtil.nullSafeLoadClass(ServiceLoaderUtil.java:122) ~[jaxb-api-2.3.1.jar:2.3.0]
at javax.xml.bind.ServiceLoaderUtil.safeLoadClass(ServiceLoaderUtil.java:155) ~[jaxb-api-2.3.1.jar:2.3.0]
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:174) ~[jaxb-api-2.3.1.jar:2.3.0]
... 61 common frames omitted
2018-12-30 14:09:43.790 WARN 1305 --- [ main] o.s.c.n.a.ArchaiusAutoConfiguration : No spring.application.name found, defaulting to 'application'
2018-12-30 14:09:43.790 WARN 1305 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2018-12-30 14:09:43.791 INFO 1305 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2018-12-30 14:09:43.922 INFO 1305 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2018-12-30 14:09:44.330 INFO 1305 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2018-12-30 14:09:44.368 INFO 1305 --- [ main] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2018-12-30 14:09:44.368 INFO 1305 --- [ main] com.netflix.discovery.DiscoveryClient : Client configured to neither register nor query for data.
2018-12-30 14:09:44.378 INFO 1305 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1546178984375 with initial instances count: 0
2018-12-30 14:09:44.405 INFO 1305 --- [ main] c.n.eureka.DefaultEurekaServerContext : Initializing ...
2018-12-30 14:09:44.406 INFO 1305 --- [ main] c.n.eureka.cluster.PeerEurekaNodes : Adding new peer nodes [http://localhost:8761/eureka/]
2018-12-30 14:09:44.583 INFO 1305 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2018-12-30 14:09:44.584 INFO 1305 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2018-12-30 14:09:44.584 INFO 1305 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2018-12-30 14:09:44.584 INFO 1305 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2018-12-30 14:09:44.668 INFO 1305 --- [ main] c.n.eureka.cluster.PeerEurekaNodes : Replica node URL: http://localhost:8761/eureka/
2018-12-30 14:09:44.675 INFO 1305 --- [ main] c.n.e.registry.AbstractInstanceRegistry : Finished initializing remote region registries. All known remote regions: []
2018-12-30 14:09:44.675 INFO 1305 --- [ main] c.n.eureka.DefaultEurekaServerContext : Initialized
2018-12-30 14:09:44.682 INFO 1305 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 2 endpoint(s) beneath base path '/actuator'
2018-12-30 14:09:44.741 INFO 1305 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Registering application UNKNOWN with eureka with status UP
2018-12-30 14:09:44.744 INFO 1305 --- [ Thread-12] o.s.c.n.e.server.EurekaServerBootstrap : Setting the eureka configuration..
2018-12-30 14:09:44.745 INFO 1305 --- [ Thread-12] o.s.c.n.e.server.EurekaServerBootstrap : Eureka data center value eureka.datacenter is not set, defaulting to default
2018-12-30 14:09:44.745 INFO 1305 --- [ Thread-12] o.s.c.n.e.server.EurekaServerBootstrap : Eureka environment value eureka.environment is not set, defaulting to test
2018-12-30 14:09:44.754 INFO 1305 --- [ Thread-12] o.s.c.n.e.server.EurekaServerBootstrap : isAws returned false
2018-12-30 14:09:44.755 INFO 1305 --- [ Thread-12] o.s.c.n.e.server.EurekaServerBootstrap : Initialized server context
2018-12-30 14:09:44.755 INFO 1305 --- [ Thread-12] c.n.e.r.PeerAwareInstanceRegistryImpl : Got 1 instances from neighboring DS node
2018-12-30 14:09:44.755 INFO 1305 --- [ Thread-12] c.n.e.r.PeerAwareInstanceRegistryImpl : Renew threshold is: 1
2018-12-30 14:09:44.755 INFO 1305 --- [ Thread-12] c.n.e.r.PeerAwareInstanceRegistryImpl : Changing status to UP
2018-12-30 14:09:44.761 INFO 1305 --- [ Thread-12] e.s.EurekaServerInitializerConfiguration : Started Eureka Server
2018-12-30 14:09:44.775 INFO 1305 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8761 (http) with context path ''
2018-12-30 14:09:44.775 INFO 1305 --- [ main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 8761
2018-12-30 14:09:44.777 INFO 1305 --- [ main] com.orbis.EurekaServiceApplication : Started EurekaServiceApplication in 4.097 seconds (JVM running for 5.186)
2018-12-30 14:10:44.762 INFO 1305 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 0msaa
However, when i remove the following dependency:
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
the application fails to start up:
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:125) ~[spring-boot-2.2.0.BUILD-SNAPSHOT.jar:2.2.0.BUILD-SNAPSHOT]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:86) ~[spring-boot-2.2.0.BUILD-SNAPSHOT.jar:2.2.0.BUILD-SNAPSHOT]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:414) ~[spring-boot-2.2.0.BUILD-SNAPSHOT.jar:2.2.0.BUILD-SNAPSHOT]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:174) ~[spring-boot-2.2.0.BUILD-SNAPSHOT.jar:2.2.0.BUILD-SNAPSHOT]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:181) ~[spring-boot-2.2.0.BUILD-SNAPSHOT.jar:2.2.0.BUILD-SNAPSHOT]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:154) ~[spring-boot-2.2.0.BUILD-SNAPSHOT.jar:2.2.0.BUILD-SNAPSHOT]
... 8 common frames omitted
Caused by: java.lang.IllegalStateException: StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[] failed to start
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.rethrowDeferredStartupExceptions(TomcatWebServer.java:171) ~[spring-boot-2.2.0.BUILD-SNAPSHOT.jar:2.2.0.BUILD-SNAPSHOT]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:109) ~[spring-boot-2.2.0.BUILD-SNAPSHOT.jar:2.2.0.BUILD-SNAPSHOT]
... 13 common frames omitted
Starting from Java 9 the JAXB implementation has been removed. So what you have added is only the API and you need to add the implementation also. There might be several alternatives.
As a fix you could add - for example, as there are other implementations also I guess - this dependency:
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.moxy</artifactId>
<version>2.7.3</version>
</dependency>
Here is an excellent explanation about this.
Why it has been removed (excerpt from above link):
Java’s standard library isn’t exactly small and lightweight. In the course of the past 20+ years, many features have been added to it, mostly because at the time it was thought that it would be a good idea if Java supported a particular technology out-of-the-box.
One of these was support for XML-based web services. When Java SE 6 was released in December 2006, XML-based web services were popular, so the developers of the Java language thought it would be a good idea if Java would have support for calling web services as a standard feature. It was decided to add the necessary APIs, that were originally developed as part of Java EE, to Java SE. Among these were JAX-WS (Java API for XML-Based Web Services) and JAXB.
With today’s trend towards microservices, it’s important that the Java runtime environment is small and lightweight, so having a large runtime library with built-in support for every possible technology isn’t as advantageous anymore.
Therefore, a proposal was made in JEP-320 to remove the Java EE and CORBA modules from the JDK.
Note about MOXy: you might also need to add jaxp.properties that contains line:
javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory
to get rid of problem:
javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.-
Added yet pretty printed version of comment from Orby that contains dependencies for Sun's implementation:
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0</version>
</dependency>
I have seen many similar problems on here but none of them seem to be the solution for me. My package structure seems to be correct and even if it wasn't, explicitly declaring the package or #RestController class in the application class still results in a 404. One thing I have noticed different about my problem than most others I have seen is that I am getting an HTML 404 response while most others I've seen are getting JSON 404 responses. I am not deploying this application, just running with mvn spring-boot:run.
Here is my code:
package com.billbuddy;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class BillbuddyApplication {
public static void main(String[] args) {
SpringApplication.run(BillbuddyApplication.class, args);
}
}
Adding the annotation #ComponentScan(#ComponentScan(basePackageClasses = UserController.class) still results in the 404
Here is my rest controller class
package com.billbuddy.controllers;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
#RestController
#RequestMapping("/user")
public class UserController {
#RequestMapping("/login")
public String login() {
return "Hello, World";
}
}
As you can see my Rest controller is in a nested class of the Spring application class. The folder structure is the same
- src/main/java
- com/billbuddy
- BillbuddyApplication.java
- controllers
- UserController.java
Here is my 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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.testprojects</groupId>
<artifactId>billbuddy</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>billbuddy</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-couchbase</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</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>
Here is what my output looks like when running the command (external IP of my CouchBase host [connection initialized but not yet used by my spring-boot application] has been censored and appears as XXX.XXX.XXX.XXX).
2018-12-22 06:11:42.603 INFO 56870 --- [ main] com.billbuddy.BillbuddyApplication : Starting BillbuddyApplication on charlies-mbp.lan with PID 56870 (/Users/user1/Projects/Github/angular-example/Server/target/classes started by user1 in /Users/user1/Projects/Github/angular-example/Server)
2018-12-22 06:11:42.608 INFO 56870 --- [ main] com.billbuddy.BillbuddyApplication : No active profile set, falling back to default profiles: default
2018-12-22 06:11:43.737 INFO 56870 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2018-12-22 06:11:43.921 INFO 56870 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 172ms. Found 1 repository interfaces.
2018-12-22 06:11:44.702 INFO 56870 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2018-12-22 06:11:44.736 INFO 56870 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-12-22 06:11:44.736 INFO 56870 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/9.0.13
2018-12-22 06:11:44.749 INFO 56870 --- [ 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: [/Users/user1/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
2018-12-22 06:11:44.840 INFO 56870 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-12-22 06:11:44.840 INFO 56870 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2130 ms
2018-12-22 06:11:45.345 INFO 56870 --- [ main] com.couchbase.client.core.CouchbaseCore : CouchbaseEnvironment: {sslEnabled=false, sslKeystoreFile='null', sslTruststoreFile='null', sslKeystorePassword=false, sslTruststorePassword=false, sslKeystore=null, sslTruststore=null, bootstrapHttpEnabled=true, bootstrapCarrierEnabled=true, bootstrapHttpDirectPort=8091, bootstrapHttpSslPort=18091, bootstrapCarrierDirectPort=11210, bootstrapCarrierSslPort=11207, ioPoolSize=4, computationPoolSize=4, responseBufferSize=16384, requestBufferSize=16384, kvServiceEndpoints=1, viewServiceEndpoints=12, queryServiceEndpoints=12, searchServiceEndpoints=12, configPollInterval=2500, configPollFloorInterval=50, networkResolution=NetworkResolution{name='auto'}, ioPool=NioEventLoopGroup, kvIoPool=null, viewIoPool=null, searchIoPool=null, queryIoPool=null, analyticsIoPool=null, coreScheduler=CoreScheduler, memcachedHashingStrategy=DefaultMemcachedHashingStrategy, eventBus=DefaultEventBus, packageNameAndVersion=couchbase-java-client/2.7.1 (git: 2.7.1, core: 1.7.1), retryStrategy=BestEffort, maxRequestLifetime=75000, retryDelay=ExponentialDelay{growBy 1.0 MICROSECONDS, powers of 2; lower=100, upper=100000}, reconnectDelay=ExponentialDelay{growBy 1.0 MILLISECONDS, powers of 2; lower=32, upper=4096}, observeIntervalDelay=ExponentialDelay{growBy 1.0 MICROSECONDS, powers of 2; lower=10, upper=100000}, keepAliveInterval=30000, continuousKeepAliveEnabled=true, keepAliveErrorThreshold=4, keepAliveTimeout=2500, autoreleaseAfter=2000, bufferPoolingEnabled=true, tcpNodelayEnabled=true, mutationTokensEnabled=false, socketConnectTimeout=1000, callbacksOnIoPool=false, disconnectTimeout=25000, requestBufferWaitStrategy=com.couchbase.client.core.env.DefaultCoreEnvironment$4#5d52e3ef, certAuthEnabled=false, coreSendHook=null, forceSaslPlain=false, compressionMinRatio=0.83, compressionMinSize=32, compressionEnabled=true, operationTracingEnabled=true, operationTracingServerDurationEnabled=true, tracer=ThresholdLogTracer, orphanResponseReportingEnabled=true, orphanResponseReporter=DefaultOrphanResponseReporter, keyValueServiceConfig=KeyValueServiceConfig{minEndpoints=1, maxEndpoints=1, pipelined=true, idleTime=0}, queryServiceConfig=QueryServiceConfig{minEndpoints=1, maxEndpoints=1, pipelined=false, idleTime=300}, searchServiceConfig=SearchServiceConfig{minEndpoints=0, maxEndpoints=12, pipelined=false, idleTime=300}, viewServiceConfig=ViewServiceConfig{minEndpoints=1, maxEndpoints=1, pipelined=false, idleTime=300}, analyticsServiceConfig=AnalyticsServiceConfig{minEndpoints=0, maxEndpoints=12, pipelined=false, idleTime=300}, queryTimeout=7500, viewTimeout=7500, searchTimeout=75000, analyticsTimeout=75000, kvTimeout=2500, connectTimeout=5000, dnsSrvEnabled=false, propagateParentSpan=true}
2018-12-22 06:11:46.672 INFO 56870 --- [ cb-io-1-1] com.couchbase.client.core.node.Node : Connected to Node XXX.XXX.XXX.XXX/XXX.XXX.XXX.XXX
2018-12-22 06:11:46.796 INFO 56870 --- [-computations-4] c.c.c.core.config.ConfigurationProvider : Selected network configuration: default
2018-12-22 06:11:46.810 INFO 56870 --- [-computations-4] c.c.c.core.config.ConfigurationProvider : Opened bucket BillBuddy
2018-12-22 06:11:47.394 INFO 56870 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2018-12-22 06:11:47.398 INFO 56870 --- [ main] com.billbuddy.BillbuddyApplication : Started BillbuddyApplication in 5.436 seconds (JVM running for 6.733)
2018-12-22 06:12:25.329 WARN 56870 --- [ cb-orphan-1] c.c.c.c.t.DefaultOrphanResponseReporter : Orphan responses observed: [{"top":[{"r":"XXX.XXX.XXX.XXX:8092","s":"view","c":"09F46A832158B8F9/0000000037386FDF","l":"192.168.86.142:62096"}],"service":"view","count":1}]
I am testing the #RestController by browsing to http://localhost:8080/user/login in chrome and see the following screen:
https://imgur.com/a/42U3eZR
Running
curl http://localhost:8080/user/login
Returns
<!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1></body></html>
I'm sure it's going to be something stupid I'm doing, but I've tried dozens of other answers I've seen both on stack overflow and other websites to no avail. Please help me.
Made a quick test with a project on my pc... you should have in your pom this dependency:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
let me know if it works.