I am new to microservices where I have to use two services (which I have made in separate projects). And now I am trying to set up Eureka configuration in my application.yml file :
But it's throwing errors as can be seen in the screenshot above:
Nested mappings are not allowed in compact mapping
and
Multiple markers at this line:
- Nested mappings are not allowed in compact mapping
- Implicit keys need to be on a single line
Additionally, I tried with
I am sharing my EServerApplication.java code below:
package com.eserver;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
#SpringBootApplication
#EnableEurekaServer
public class EServerApplication {
public static void main(String[] args) {
SpringApplication.run(EServerApplication.class, args);
}
}
and below is my pom.xml file contents:
<?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.6.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.eserver</groupId>
<artifactId>e_server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>e_server</name>
<description>This is a microservice for eureka server</description>
<properties>
<java.version>11</java.version>
<spring-cloud.version>2021.0.0</spring-cloud.version>
</properties>
<dependencies>
<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>
</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>
</project>
But, when I do configure the same thing in application.properties file, it works well.
and below is the console output:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.6.3)
2022-01-27 14:52:11.965 INFO 14444 --- [ main] com.eserver.EServerApplication : Starting EServerApplication using Java 17.0.1 on SHAHFAISALKHAN with PID 14444 (C:\Users\shahf\Documents\workspace-spring-tool-suite-4-4.13.0.RELEASE\e_server\target\classes started by shahf in C:\Users\shahf\Documents\workspace-spring-tool-suite-4-4.13.0.RELEASE\e_server)
2022-01-27 14:52:11.970 INFO 14444 --- [ main] com.eserver.EServerApplication : No active profile set, falling back to default profiles: default
2022-01-27 14:52:13.550 INFO 14444 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=0f4543fa-8866-3a60-8d6e-f4ead7a36662
2022-01-27 14:52:13.981 INFO 14444 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8761 (http)
2022-01-27 14:52:13.993 INFO 14444 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-01-27 14:52:13.993 INFO 14444 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.56]
2022-01-27 14:52:14.275 INFO 14444 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-01-27 14:52:14.275 INFO 14444 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2203 ms
2022-01-27 14:52:15.013 INFO 14444 --- [ main] c.s.j.s.i.a.WebApplicationImpl : Initiating Jersey application, version 'Jersey: 1.19.4 05/24/2017 03:20 PM'
2022-01-27 14:52:15.089 INFO 14444 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2022-01-27 14:52:15.091 INFO 14444 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2022-01-27 14:52:15.299 INFO 14444 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2022-01-27 14:52:15.300 INFO 14444 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2022-01-27 14:52:19.162 INFO 14444 --- [ main] DiscoveryClientOptionalArgsConfiguration : Eureka HTTP Client uses Jersey
2022-01-27 14:52:19.326 WARN 14444 --- [ main] iguration$LoadBalancerCaffeineWarnLogger : Spring Cloud LoadBalancer is currently working with the default cache. You can switch to using Caffeine cache, by adding it and org.springframework.cache.caffeine.CaffeineCacheManager to the classpath.
2022-01-27 14:52:19.393 INFO 14444 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2022-01-27 14:52:19.494 INFO 14444 --- [ main] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2022-01-27 14:52:19.495 INFO 14444 --- [ main] com.netflix.discovery.DiscoveryClient : Client configured to neither register nor query for data.
2022-01-27 14:52:19.525 INFO 14444 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1643275339522 with initial instances count: 0
2022-01-27 14:52:19.657 INFO 14444 --- [ main] c.n.eureka.DefaultEurekaServerContext : Initializing ...
2022-01-27 14:52:19.665 INFO 14444 --- [ main] c.n.eureka.cluster.PeerEurekaNodes : Adding new peer nodes [http://localhost:8761/eureka/]
2022-01-27 14:52:20.036 INFO 14444 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2022-01-27 14:52:20.036 INFO 14444 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2022-01-27 14:52:20.036 INFO 14444 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2022-01-27 14:52:20.036 INFO 14444 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2022-01-27 14:52:20.177 INFO 14444 --- [on(3)-127.0.0.1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2022-01-27 14:52:20.178 INFO 14444 --- [on(3)-127.0.0.1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2022-01-27 14:52:20.333 INFO 14444 --- [ main] c.n.eureka.cluster.PeerEurekaNodes : Replica node URL: http://localhost:8761/eureka/
2022-01-27 14:52:20.377 INFO 14444 --- [ main] c.n.e.registry.AbstractInstanceRegistry : Finished initializing remote region registries. All known remote regions: []
2022-01-27 14:52:20.386 INFO 14444 --- [ main] c.n.eureka.DefaultEurekaServerContext : Initialized
2022-01-27 14:52:20.396 INFO 14444 --- [on(3)-127.0.0.1] o.s.b.a.e.web.EndpointLinksResolver : Exposing 1 endpoint(s) beneath base path '/actuator'
2022-01-27 14:52:20.408 INFO 14444 --- [on(3)-127.0.0.1] o.s.web.servlet.DispatcherServlet : Completed initialization in 230 ms
2022-01-27 14:52:20.547 INFO 14444 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Registering application UNKNOWN with eureka with status UP
2022-01-27 14:52:20.551 INFO 14444 --- [ Thread-9] o.s.c.n.e.server.EurekaServerBootstrap : Setting the eureka configuration..
2022-01-27 14:52:20.567 INFO 14444 --- [ Thread-9] o.s.c.n.e.server.EurekaServerBootstrap : isAws returned false
2022-01-27 14:52:20.568 INFO 14444 --- [ Thread-9] o.s.c.n.e.server.EurekaServerBootstrap : Initialized server context
2022-01-27 14:52:20.568 INFO 14444 --- [ Thread-9] c.n.e.r.PeerAwareInstanceRegistryImpl : Got 1 instances from neighboring DS node
2022-01-27 14:52:20.569 INFO 14444 --- [ Thread-9] c.n.e.r.PeerAwareInstanceRegistryImpl : Renew threshold is: 1
2022-01-27 14:52:20.570 INFO 14444 --- [ Thread-9] c.n.e.r.PeerAwareInstanceRegistryImpl : Changing status to UP
2022-01-27 14:52:20.606 INFO 14444 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8761 (http) with context path ''
2022-01-27 14:52:20.607 INFO 14444 --- [ main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 8761
2022-01-27 14:52:20.692 INFO 14444 --- [ Thread-9] e.s.EurekaServerInitializerConfiguration : Started Eureka Server
2022-01-27 14:52:21.438 INFO 14444 --- [ main] com.eserver.EServerApplication : Started EServerApplication in 11.215 seconds (JVM running for 12.441)
2022-01-27 14:53:20.580 INFO 14444 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 0ms
2022-01-27 14:54:20.579 INFO 14444 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 0ms
Please guide me how can I can I fix the application.yml error.
EDIT: [SOLVED]
I found that this yml configuration file is sensitive to white-space of each components and hence I corrected it in my program. Closing the thread now!
yaml files follow a different naming convention. The following properties should resolve your issue.
eureka:
client:
register-with-eureka: false
fetch-registry: false
server:
wait-time-in-ms-when-sync-empty: 0
I have created a Bootstrap project in which I have 3 repositories. When I compile the project I do not receive any errors but unfortunately I can not see my controllers in Swagger!!!
I have found out that line 4 says:
Finished Spring Data repository scanning in 4 ms. Found 0 JPA
repository interfaces.
I think this the reason that I can not see the controllers. Any idea to solve this? Thank you in advance.
2021-12-14 00:26:13.768 INFO 5472 --- [ main] WBSthesis.rotab.RotabApplication
: No active profile set, falling back to default profiles: default
2021-12-14 00:26:14.648 INFO 5472 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-12-14 00:26:14.661 INFO 5472 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : ***Finished Spring Data repository scanning in 4 ms. Found 0 JPA repository interfaces.***
2021-12-14 00:26:15.592 INFO 5472 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2021-12-14 00:26:15.609 INFO 5472 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-12-14 00:26:15.609 INFO 5472 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.54]
2021-12-14 00:26:15.718 INFO 5472 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-12-14 00:26:15.718 INFO 5472 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1885 ms
2021-12-14 00:26:15.975 INFO 5472 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-12-14 00:26:16.051 INFO 5472 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.32.Final
2021-12-14 00:26:16.226 INFO 5472 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-12-14 00:26:16.356 INFO 5472 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-12-14 00:26:16.562 INFO 5472 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-12-14 00:26:16.580 INFO 5472 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL55Dialect
2021-12-14 00:26:16.856 INFO 5472 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-12-14 00:26:16.866 INFO 5472 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-12-14 00:26:17.090 WARN 5472 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2021-12-14 00:26:17.225 INFO 5472 --- [ main] pertySourcedRequestMappingHandlerMapping : Mapped URL path [/v2/api-docs] onto method [springfox.documentation.swagger2.web.Swagger2Controller#getDocumentation(String, HttpServletRequest)]
2021-12-14 00:26:17.490 INFO 5472 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2021-12-14 00:26:17.491 INFO 5472 --- [ main] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
2021-12-14 00:26:17.511 INFO 5472 --- [ main] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
2021-12-14 00:26:17.544 INFO 5472 --- [ main] s.d.s.w.s.ApiListingReferenceScanner : Scanning for api listing references
2021-12-14 00:26:17.698 INFO 5472 --- [ main] WBSthesis.rotab.RotabApplication : Started RotabApplication in 4.468 seconds (JVM running for 4.958)
More info of your project would be helpful, but maybe your interfaces are not inside the right package. I was facing this once...
Here is an example.
Notice that all sub-packages are on the same level as the #SpringBootApplication.
I need to deploy SCDF 2.8.0 version in OKD. I also made changes to SCDF Code to add the Oracle Driver dependency. When I scale up the POD after adding all configurations of SCDF as given in the documentation I get the below error. I tried changing the port but It's of no use.
There are other Rest applications deployed in the same environment and they have no issues in exposing the service via the port 80 or 81. Kindly let me know your inputs.
____ ____ _ __
/ ___| _ __ _ __(_)_ __ __ _ / ___| | ___ _ _ __| |
\___ \| '_ \| '__| | '_ \ / _` | | | | |/ _ \| | | |/ _` |
___) | |_) | | | | | | | (_| | | |___| | (_) | |_| | (_| |
|____/| .__/|_| |_|_| |_|\__, | \____|_|\___/ \__,_|\__,_|
____ |_| _ __|___/ __________
| _ \ __ _| |_ __ _ | ___| | _____ __ \ \ \ \ \ \
| | | |/ _` | __/ _` | | |_ | |/ _ \ \ /\ / / \ \ \ \ \ \
| |_| | (_| | || (_| | | _| | | (_) \ V V / / / / / / /
|____/ \__,_|\__\__,_| |_| |_|\___/ \_/\_/ /_/_/_/_/_/
Spring Cloud Data Flow Server (v2.8.0)
2021-06-22 12:24:49.231 INFO 1 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-configmap.scdf-server.devfac-capella-batches'}]
2021-06-22 12:24:49.258 INFO 1 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-oracle-root-username'}, BootstrapPropertySource {name='bootstrapProperties-oracle-root-url'}, BootstrapPropertySource {name='bootstrapProperties-oracle-root-password'}, BootstrapPropertySource {name='bootstrapProperties-secrets.spring-cloud-dataflow-server.devfac-capella-batches'}]
2021-06-22 12:24:49.426 INFO 1 --- [ main] o.s.c.d.s.s.DataFlowServerApplication : The following profiles are active: dev,kubernetes
2021-06-22 12:24:53.337 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2021-06-22 12:24:53.338 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Map repositories in DEFAULT mode.
2021-06-22 12:24:53.924 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 555 ms. Found 1 Map repository interfaces.
2021-06-22 12:24:55.329 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2021-06-22 12:24:55.333 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-06-22 12:24:55.351 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 2 ms. Found 0 JPA repository interfaces.
2021-06-22 12:24:56.222 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2021-06-22 12:24:56.222 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-06-22 12:24:56.456 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 233 ms. Found 5 JPA repository interfaces.
2021-06-22 12:24:57.121 INFO 1 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=46e2ec48-3213-3e84-8b1a-af720b97c983
2021-06-22 12:24:59.309 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 81 (http)
2021-06-22 12:24:59.331 INFO 1 --- [ main] o.a.coyote.http11.Http11NioProtocol : Initializing ProtocolHandler ["http-nio-81"]
2021-06-22 12:24:59.332 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-06-22 12:24:59.332 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.45]
2021-06-22 12:24:59.608 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-06-22 12:25:01.547 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-06-22 12:25:02.648 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-06-22 12:25:03.020 INFO 1 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-06-22 12:25:03.637 INFO 1 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.30.Final
2021-06-22 12:25:04.536 INFO 1 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-06-22 12:25:05.046 INFO 1 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.Oracle12cDialect
2021-06-22 12:25:06.918 INFO 1 --- [ main] o.h.validator.internal.util.Version : HV000001: Hibernate Validator 6.1.7.Final
2021-06-22 12:25:08.958 INFO 1 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-06-22 12:25:09.011 INFO 1 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-06-22 12:25:09.933 INFO 1 --- [ main] d.c.r.ContainerRegistryAutoConfiguration : Final Registry Configurations: {registry-1.docker.io=ContainerRegistryConfiguration{registryHost='registry-1.docker.io', user='null', secret='****'', authorizationType=dockeroauth2, manifestMediaType='application/vnd.docker.distribution.manifest.v2+json', disableSslVerification='false', useHttpProxy='false', extra={registryAuthUri=https://auth.docker.io/token?service=registry.docker.io&scope=repository:{repository}:pull&offline_token=1&client_id=shell}}}
2021-06-22 12:25:12.908 WARN 1 --- [ main] .s.c.d.s.s.i.TaskConfigurationProperties : org.springframework.cloud.dataflow.server.service.impl.TaskConfigurationProperties.setComposedTaskRunnerUri is deprecated. Please use org.springframework.cloud.dataflow.server.service.impl.ComposedTaskRunnerConfigurationProperties.setUri
2021-06-22 12:25:13.826 INFO 1 --- [ main] o.s.b.c.r.s.JobRepositoryFactoryBean : No database type set, using meta data indicating: ORACLE
2021-06-22 12:25:14.041 INFO 1 --- [ main] o.s.c.d.s.b.SimpleJobServiceFactoryBean : No database type set, using meta data indicating: ORACLE
2021-06-22 12:25:14.730 WARN 1 --- [ 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-06-22 12:25:15.148 INFO 1 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2021-06-22 12:25:18.118 INFO 1 --- [ main] .s.c.DataFlowControllerAutoConfiguration : Skipper URI [http://localhost:7577/api]
2021-06-22 12:25:18.942 INFO 1 --- [ main] o.a.coyote.http11.Http11NioProtocol : Starting ProtocolHandler ["http-nio-81"]
2021-06-22 12:25:18.951 WARN 1 --- [ 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-06-22 12:25:19.030 INFO 1 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2021-06-22 12:25:19.041 INFO 1 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2021-06-22 12:25:19.045 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2021-06-22 12:25:19.144 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2021-06-22 12:25:19.147 INFO 1 --- [ main] o.a.coyote.http11.Http11NioProtocol : Pausing ProtocolHandler ["http-nio-81"]
2021-06-22 12:25:19.148 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2021-06-22 12:25:19.154 INFO 1 --- [ main] o.a.coyote.http11.Http11NioProtocol : Stopping ProtocolHandler ["http-nio-81"]
2021-06-22 12:25:19.155 INFO 1 --- [ main] o.a.coyote.http11.Http11NioProtocol : Destroying ProtocolHandler ["http-nio-81"]
2021-06-22 12:25:19.746 ERROR 1 --- [ 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)
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356)
at java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155)
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:782)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:774)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:339)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1340)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1329)
at org.springframework.cloud.dataflow.server.single.DataFlowServerApplication.main(DataFlowServerApplication.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
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)
at org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:43)
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178)
... 23 common frames omitted
Caused by: java.lang.IllegalArgumentException: standardService.connector.startFailed
at org.apache.catalina.core.StandardService.addConnector(StandardService.java:243)
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:282)
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:213)
... 25 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Protocol handler start failed
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1074)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.addConnector(StandardService.java:239)
... 27 common frames omitted
Caused by: java.net.SocketException: Permission denied
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:433)
at sun.nio.ch.Net.bind(Net.java:425)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at org.apache.tomcat.util.net.NioEndpoint.initServerSocket(NioEndpoint.java:300)
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:253)
at org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1204)
at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1290)
at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:614)
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1071)
... 29 common frames omitted
DockerFile I use to build SCDF Image. I build SCDF jar separately with Oracle driver and just use the below docker file to convert into Dockerimage. This is just to reduce the build time.
DockerFile:
FROM openjdk:8-jre-alpine
WORKDIR /app
COPY src/main/resources/spring-cloud-dataflow-server-2.8.0.jar /app/
ENTRYPOINT ["java", "-jar", "spring-cloud-dataflow-server-2.8.0.jar"]
Thanks.
After a bit of a research, I found the answer for this question. I get the Caused by: java.net.SocketException: Permission denied error. This denotes that the port I'm using which is 80 for SCDF server is not permitted for use in the particular environment. Hence I changed the port to 8081 (Just to have the usual one) and it's started working fine.
I've created a new project with Spring Initializr and I configured connection with SSMS database:
spring.datasource.url=jdbc:sqlserver://xxxxxxxx;databaseName=yyyyyy
spring.datasource.username=
spring.datasource.password=
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.show-sql=true
spring.jpa.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
spring.jpa.hibernate.ddl-auto=update
I also created a test model class to check everything works fine:
#Getter
#Setter
#AllArgsConstructor
#NoArgsConstructor
#EqualsAndHashCode(callSuper = false)
#ToString
#Builder
#Entity
#Table(name = "USR", schema = "dbo")
public class User {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private Integer usrId;
}
This is my console output:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.4.1)
2020-12-21 21:15:06.574 INFO 22192 --- [ restartedMain] c.e.employees.EmployeesApplication : Starting EmployeesApplication using Java 11.0.8 on DESKTOP-OEEHFPE with PID 22192 (C:\Alina\employees\target\classes started by olaru in C:\Alina\employees)
2020-12-21 21:15:06.577 INFO 22192 --- [ restartedMain] c.e.employees.EmployeesApplication : The following profiles are active: #spring.profiles.active#
2020-12-21 21:15:06.637 INFO 22192 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2020-12-21 21:15:07.211 INFO 22192 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-12-21 21:15:07.226 INFO 22192 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 5 ms. Found 0 JPA repository interfaces.
2020-12-21 21:15:07.646 INFO 22192 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-12-21 21:15:07.695 INFO 22192 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.25.Final
2020-12-21 21:15:07.798 INFO 22192 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2020-12-21 21:15:07.902 INFO 22192 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-12-21 21:15:08.200 INFO 22192 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-12-21 21:15:08.220 INFO 22192 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.SQLServer2012Dialect
2020-12-21 21:15:08.710 INFO 22192 --- [ restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-12-21 21:15:08.721 INFO 22192 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-12-21 21:15:08.761 INFO 22192 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2020-12-21 21:15:08.873 INFO 22192 --- [ restartedMain] c.e.employees.EmployeesApplication : Started EmployeesApplication in 2.792 seconds (JVM running for 4.218)
2020-12-21 21:15:08.885 INFO 22192 --- [extShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2020-12-21 21:15:08.892 INFO 22192 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2020-12-21 21:15:08.898 INFO 22192 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
Process finished with exit code 0
I don't see any error in the console, but the table is not created. Please let me know if you have any idea what's wrong.
Did you add the required dependencies?
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>
You also need to enable entity scan, in case you didn't:
#Configuration
#EntityScan(basePackages = {"my.package"})
#EnableJpaRepositories(basePackages = {"my.package"})
Basically your first three properties would be enough, but the others shouldn't harm.
spring.datasource.url=jdbc:sqlserver://localhost;databaseName=my-app
spring.datasource.username=sa
spring.datasource.password=<<YOUR_PASSWORD>>
If you like create a Spring Boot app for MS SQL at https://bootify.io to see the full configuration.
I don't understand why my spring boot app takes 15 seconds to start when I run it in regular mode vs 15 minutes when I run it in debug mode.
Debug mode Logs:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.3.RELEASE)
2020-02-28 16:57:27.214 INFO [my-project,,,] 5740 --- [ restartedMain] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : https://config-server.my-company.org
2020-02-28 16:57:29.442 INFO [my-project,,,] 5740 --- [ restartedMain] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=my-project, profiles=[dev], label=null, version=c656a6ca556f4fc58135e673a7e5c4e97a2e5088, state=null
2020-02-28 16:57:33.537 INFO [my-project,,,] 5740 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-02-28 16:57:33.537 INFO [my-project,,,] 5740 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 4023 ms
2020-02-28 16:57:37.986 INFO [my-project,,,] 5740 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-02-28 17:00:22.158 INFO [my-project,,,] 5740 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2020-02-28 17:02:21.271 WARN [my-project,,,] 5740 --- [ restartedMain] aWebConfiguration$JpaWebMvcConfiguration : 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-02-28 17:03:37.441 INFO [my-project,,,] 5740 --- [ restartedMain] o.s.b.a.e.web.EndpointLinksResolver : Exposing 16 endpoint(s) beneath base path '/actuator'
2020-02-28 17:04:22.272 INFO [my-project,,,] 5740 --- [ restartedMain] pertySourcedRequestMappingHandlerMapping : Mapped URL path [/v2/api-docs] onto method [public org.springframework.http.ResponseEntity<springfox.documentation.spring.web.json.Json> springfox.documentation.swagger2.web.Swagger2Controller.getDocumentation(java.lang.String,javax.servlet.http.HttpServletRequest)]
2020-02-28 17:04:58.404 WARN [my-project,,,] 5740 --- [ restartedMain] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2020-02-28 17:04:58.416 INFO [my-project,,,] 5740 --- [ restartedMain] 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.
2020-02-28 17:04:58.753 WARN [my-project,,,] 5740 --- [ restartedMain] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2020-02-28 17:04:58.765 INFO [my-project,,,] 5740 --- [ restartedMain] 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.
2020-02-28 17:05:58.718 INFO [my-project,,,] 5740 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-02-28 17:07:05.596 INFO [my-project,,,] 5740 --- [ restartedMain] o.e.s.filters.AnnotationSizeOfFilter : Using regular expression provided through VM argument org.ehcache.sizeof.filters.AnnotationSizeOfFilter.pattern for IgnoreSizeOf annotation : ^.*cache\..*IgnoreSizeOf$
2020-02-28 17:07:29.728 INFO [my-project,,,] 5740 --- [ restartedMain] c.my-company.security.idp.BeanFactory : override default IdpOAuthManager userInfoCallDisabled = true, IdpUser will only contains uid
2020-02-28 17:08:24.056 INFO [my-project,,,] 5740 --- [ restartedMain] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService
2020-02-28 17:09:58.919 INFO [my-project,,,] 5740 --- [ restartedMain] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: any request org.springframework.web.filter.CorsFilter#7430bc1e,
2020-02-28 17:12:03.101 INFO [my-project,,,] 5740 --- [ restartedMain] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
2020-02-28 17:12:05.749 INFO [my-project,,,] 5740 --- [ restartedMain] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s) org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#69e6f894]
2020-02-28 17:12:17.850 INFO [my-project,,,] 5740 --- [ restartedMain] s.d.s.w.s.ApiListingReferenceScanner : Scanning for api listing references
2020-02-28 17:13:54.484 INFO [my-project,,,] 5740 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2020-02-28 17:13:54.837 INFO [my-project,,,] 5740 --- [ restartedMain] c.d.i.b.p.MySpringBootApplication : Started MySpringBootApplication in 988.725 seconds (JVM running for 989.776)
2020-02-28 17:14:17.835 INFO [my-project,,,] 5740 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 6879 ms
2020-02-28 17:14:35.004 INFO [my-project,b5277242974c5225,b5277242974c5225,false] 5740 --- [nio-8080-exec-1] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : https://config-server.my-company.org
2020-02-28 17:14:42.858 INFO [my-project,b5277242974c5225,b5277242974c5225,false] 5740 --- [nio-8080-exec-1] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=my-project, profiles=[dev], label=null, version=c656a6ca556f4fc58135e673a7e5c4e97a2e5088, state=null
Any help or explanation would be appreciated.
Thanks
You probably have a breakpoint on a method call, those can slow down a Java application by quite a lot, instead if you can try to put your breakpoint on the first line of code in the method.
Breakpoints or conditional breakpoints usually cause this issue. Remove all breakpoints and run it.