I have following deployments and service but still not able to access the service on my Windows machine with minikube installed on it.
# kubectl get deployment
NAME READY UP-TO-DATE AVAILABLE AGE
helloworld-dep 3/3 3 3 9h
# kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
greet-api-demo 1/1 Running 2 (23m ago) 6d9h 172.17.0.5 minikube <none> <none>
helloworld-dep-f8586dd84-28dxg 1/1 Running 1 (23m ago) 9h 172.17.0.6 minikube <none> <none>
helloworld-dep-f8586dd84-p4pg9 1/1 Running 1 (23m ago) 9h 172.17.0.7 minikube <none> <none>
helloworld-dep-f8586dd84-tgmcj 1/1 Running 1 (23m ago) 9h 172.17.0.8 minikube <none> <none>
# kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
helloworld-service NodePort 10.96.44.199 <none> 80:30008/TCP 4m1s
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 191d
# kubectl logs helloworld-dep-f8586dd84-28dxg
Setting Active Processor Count to 8
Calculating JVM memory based on 11276448K available memory
For more information on this calculation, see https://paketo.io/docs/reference/java-reference/#memory-calculator
Calculated JVM Memory Configuration: -XX:MaxDirectMemorySize=10M -Xmx10889346K -XX:MaxMetaspaceSize=79901K -XX:ReservedCodeCacheSize=240M -Xss1M (Total Memory: 11276448K, Thread Count: 50, Loaded Class Count: 11693, Headroom: 0%)
Enabling Java Native Memory Tracking
Adding 124 container CA certificates to JVM truststore
Spring Cloud Bindings Enabled
Picked up JAVA_TOOL_OPTIONS: -Djava.security.properties=/layers/paketo-buildpacks_bellsoft-liberica/java-security-properties/java-security.properties -XX:+ExitOnOutOfMemoryError -XX:ActiveProcessorCount=8 -XX:MaxDirectMemorySize=10M -Xmx10889346K -XX:MaxMetaspaceSize=79901K -XX:ReservedCodeCacheSize=240M -Xss1M -XX:+UnlockDiagnosticVMOptions -XX:NativeMemoryTracking=summary -XX:+PrintNMTStatistics -Dorg.springframework.cloud.bindings.boot.enable=true
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.0.0)
2022-12-23T03:38:53.397Z INFO 1 --- [ main] com.playground.k8s.K8sDemoApplication : Starting K8sDemoApplication using Java 17.0.5 with PID 1 (/workspace/BOOT-INF/classes started by cnb in /workspace)
2022-12-23T03:38:53.403Z INFO 1 --- [ main] com.playground.k8s.K8sDemoApplication : No active profile set, falling back to 1 default profile: "default"
2022-12-23T03:39:14.389Z INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2022-12-23T03:39:14.648Z INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-12-23T03:39:14.650Z INFO 1 --- [ main] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.1]
2022-12-23T03:39:15.883Z INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-12-23T03:39:15.888Z INFO 1 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 21396 ms
2022-12-23T03:39:19.693Z INFO 1 --- [ main] o.s.b.a.w.s.WelcomePageHandlerMapping : Adding welcome page template: index
2022-12-23T03:39:23.699Z INFO 1 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 1 endpoint(s) beneath base path '/actuator'
2022-12-23T03:39:25.262Z INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2022-12-23T03:39:25.397Z INFO 1 --- [ main] com.playground.k8s.K8sDemoApplication : Started K8sDemoApplication in 35.178 seconds (process running for 38.144)
Tried minikube ip, clusterip and node ip but none of them worked !
# curl http://192.168.49.2:30008/actuator
curl: (28) Failed to connect to 192.168.49.2 port 30008 after 21061 ms: Timed out
# curl http://10.96.44.199:30008/actuator
curl: (28) Failed to connect to 10.96.44.199 port 30008 after 21034 ms: Timed out
# curl http://172.17.0.6:30008/actuator
curl: (28) Failed to connect to 172.17.0.6 port 30008 after 21052 ms: Timed out
Not sure from where you are truing to hit the curl but you will be only able to curl those IP if truing inside of Kubernetes cluster.
Cluster IP is internal, you will be able to access it internal or internal services can use it to access it.
You can run one container extra to test this
kubectl run -it --rm --image=curlimages/curl curly -- sh
after command try curl <clusterIP> or curl helloworld-service
If you want to try from outside from Host machine you can check URL with
minikube service helloworld-service --url
try once curl localhost:30008/actuator
For node port you can get minikube IP with command
minikube ip
curl MinikubeIP:30008
Related
I am new to SpringBoot and when am trying to run the Application i have encountered this problem in Tomcat.
Do we have to have any specific tomcat verison only to run Spring boot.
Following are the Configurations in my system:
Java 17
Apache Tomcat version 8.036
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.4.5)
2022-11-08 16:40:04.056 INFO 2848 --- [ main] c.g.s.SpringBootSecurityApplication : Starting SpringBootSecurityApplication using Java 17.0.5 on DESKTOP-3JTUENI with PID 2848 (C:\Users\User.DESKTOP-3JTUENI\Downloads\Spring Boot Security\Spring Boot Security\Final Project\spring-boot-security\spring-boot-security\target\classes started by User in C:\Users\User.DESKTOP-3JTUENI\Downloads\Spring Boot Security\Spring Boot Security\Final Project\spring-boot-security\spring-boot-security)
2022-11-08 16:40:04.093 INFO 2848 --- [ main] c.g.s.SpringBootSecurityApplication : No active profile set, falling back to default profiles: default
2022-11-08 16:40:10.257 INFO 2848 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-11-08 16:40:10.623 INFO 2848 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 300 ms. Found 3 JPA repository interfaces.
2022-11-08 16:40:13.193 WARN 2848 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is java.lang.NoSuchMethodError: 'void org.apache.tomcat.util.modeler.Registry.disableRegistry()'
2022-11-08 16:40:13.260 INFO 2848 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-11-08 16:40:13.341 ERROR 2848 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:183)
The following method did not exist:
'void org.apache.tomcat.util.modeler.Registry.disableRegistry()'
The method's class, org.apache.tomcat.util.modeler.Registry, is available from the following locations:
jar:file:/C:/Users/User.DESKTOP-3JTUENI/Downloads/apache-tomcat-8.5.82/apache-tomcat-8.0.36/lib/tomcat-coyote.jar!/org/apache/tomcat/util/modeler/Registry.class
jar:file:/C:/Users/User.DESKTOP-3JTUENI/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.45/tomcat-embed-core-9.0.45.jar!/org/apache/tomcat/util/modeler/Registry.class
The class hierarchy was loaded from the following locations:
org.apache.tomcat.util.modeler.Registry: file:/C:/Users/User.DESKTOP-3JTUENI/Downloads/apache-tomcat-8.5.82/apache-tomcat-8.0.36/lib/tomcat-coyote.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.apache.tomcat.util.modeler.Registry
In pom.xml gave this dependency
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
Can anyone let me know if we have to have any specific version of tomcat / Springboot or any other solution for this.
As part of a local deployment of a GitHub project using a Centos 8 Vagrant virtual machine, I have obtained the following results after running "vagrant up" in GitBash:
Virtual machine log:
default:
default: |\ _,,,--,,_
default: /,`.-'`' ._ \-;;,_
default: _______ __|,4- ) )_ .;.(__`'-'__ ___ __ _ ___ _______
default: | | '---''(_/._)-'(_\_) | | | | | | | | |
default: | _ | ___|_ _| | | | | |_| | | | __ _ _
default: | |_| | |___ | | | | | | | | | | \ \ \ \
default: | ___| ___| | | | _| |___| | _ | | _| \ \ \ \
default: | | | |___ | | | |_| | | | | | | |_ ) ) ) )
default: |___| |_______| |___| |_______|_______|___|_| |__|___|_______| / / / /
default: ==================================================================/_/_/_/
default:
default: :: Built with Spring Boot :: 2.4.5
default:
default: 2021-08-09 00:25:52.606 INFO 27111 --- [ main] o.s.s.petclinic.PetClinicApplication : Starting PetClinicApplication v2.4.5 using Java 1.8.0_302 on localhost.localdomain with PID 27111 (/home/vagrant/spring-petclinic/target/spring-petclinic-2.4.5.jar started by vagrant in /home/vagrant/spring-petclinic)
default: 2021-08-09 00:25:52.624 INFO 27111 --- [ main] o.s.s.petclinic.PetClinicApplication : No active profile set, falling back to default profiles: default
default: 2021-08-09 00:25:54.610 INFO 27111 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
default: 2021-08-09 00:25:54.696 INFO 27111 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 76 ms. Found 4 JPA repository interfaces.
default: 2021-08-09 00:25:55.664 INFO 27111 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
default: 2021-08-09 00:25:55.685 INFO 27111 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
default: 2021-08-09 00:25:55.685 INFO 27111 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.45]
default: 2021-08-09 00:25:55.885 INFO 27111 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
default: 2021-08-09 00:25:55.886 INFO 27111 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3152 ms
default: 2021-08-09 00:25:56.535 INFO 27111 --- [ main] org.ehcache.core.EhcacheManager : Cache 'vets' created in EhcacheManager.
default: 2021-08-09 00:25:56.552 INFO 27111 --- [ main] org.ehcache.jsr107.Eh107CacheManager : Registering Ehcache MBean javax.cache:type=CacheStatistics,CacheManager=urn.X-ehcache.jsr107-default-config,Cache=vets
default: 2021-08-09 00:25:56.563 INFO 27111 --- [ main] org.ehcache.jsr107.Eh107CacheManager : Registering Ehcache MBean javax.cache:type=CacheStatistics,CacheManager=urn.X-ehcache.jsr107-default-config,Cache=vets
default: 2021-08-09 00:25:56.672 INFO 27111 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
default: 2021-08-09 00:25:56.950 INFO 27111 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
default: 2021-08-09 00:25:57.220 INFO 27111 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
default: 2021-08-09 00:25:57.324 INFO 27111 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.30.Final
default: 2021-08-09 00:25:57.493 INFO 27111 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
default: 2021-08-09 00:25:57.655 INFO 27111 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
default: 2021-08-09 00:25:58.813 INFO 27111 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
default: 2021-08-09 00:25:58.826 INFO 27111 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
default: 2021-08-09 00:25:59.968 INFO 27111 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
default: 2021-08-09 00:26:01.442 INFO 27111 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 13 endpoint(s) beneath base path '/actuator'
default: 2021-08-09 00:26:01.533 INFO 27111 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
default: 2021-08-09 00:26:01.568 INFO 27111 --- [ main] o.s.s.petclinic.PetClinicApplication : Started PetClinicApplication in 9.688 seconds (JVM running for 10.503)
Vagrant file:
Vagrant.configure("2") do |config|
config.vm.box = "centos/8"
config.vm.synced_folder ".", "/vagrant", type: "rsync"
config.vm.network "forwarded_port", guest: 8443, host: 8080
config.vm.provider "virtualbox" do |vb|
vb.memory = "4096"
vb.cpus = "2"
end
config.vm.provision "shell", privileged: false, inline: <<-SHELL
echo "whoami..."
whoami
echo "pwd..."
pwd
# echo "upgrading..."
# sudo yum upgrade -y
echo "installing unzip..."
sudo yum install unzip -y
echo "installing git..."
sudo yum install git -y
echo "installing mysql..."
sudo dnf install mysql-server -y
sudo systemctl enable mysqld
sudo systemctl start mysqld.service
sudo systemctl status mysqld
echo "installing java..."
sudo yum install java-11-openjdk-devel -y
sudo yum install maven -y
git clone https://github.com/spring-projects/spring-petclinic.git
sleep 30
cd spring-petclinic
echo "running project jar"
./mvnw package
java -jar target/*.jar
SHELL
end
As shown, the Tomcat server seems to be running on the correct port without obvious errors. However, upon entering http://localhost:8080/ (the correct address of entry) into my Chrome search bar, I get an error screen with the following message:
This page isn’t working
localhost didn’t send any data.
ERR_EMPTY_RESPONSE
The site uses an H2 in-memory database which can typically be accessed by navigating to http://localhost:8080/h2-console, but this doesn't work and produces the same error.
I tried running another application on port 8080 afterwards, and was able to confirm that port 8080 was indeed in use by my initial webapp as the second one did not run and produced an error.
Assuming there is nothing wrong with the source GitHub project (which I can confidently claim there is not), what have I done incorrectly to cause this issue, and how can it be resolved?
In the log it show Tomcat started on port(s): 8080 (http) with context path but you are connecting 8080 on the host to port 8443 on the guest.
Try changing the target port on the guest to 8080 as well. See vagrant forwarded ports
config.vm.network "forwarded_port", guest: 8080, host: 8080
The whole concept of running a server in the vagrant shell seems very odd. I assume it is just some quick and very dirty test. Better look at using something like ansible for configuring you guests.
I created a simple spring boot application and created a docker image. Tested the docker image on local (windows 10 professional) machine and it worked. Then I tried to run the image using kubectl run command, but it doesn't work.
Here are the details :
Environment - Windows 10 Professional, Docker Desktop, Java 8, Created Spring Boot app in Spring Tool Suite
Spring Boot project
application.properties has following entry
server.port=8085
The controller contains following
#RestController
public class TomcatController {
#GetMapping("/hello")
public Collection<String> sayHello() {
return IntStream.range(0, 10)
.mapToObj(i -> "Hello number " + i)
.collect(Collectors.toList());
}
}
Dockerfile contains following
FROM openjdk:8
ADD target/demowar1.jar demowar1.jar
EXPOSE 8085
ENTRYPOINT ["java" , "-jar" , "demowar1.jar"]
Used docker build command to create the image
docker build -t sudhirj8/demowar1 .
Ran the docker run command and verified it works
docker run --name demowar1 -p 8085:8085 sudhirj8/demowar1
In browser, used localhost:8085 and see proper output
Removed the running container
Ran following command to run in Kubernetes
kubectl run demowar1 --image sudhirj8/demowar1
Pod is created successfully
But when I run localhost:8085/hello browser, I get error
Unable to connect
Ran command kubectl logs demowar1 and see that tomcat started on port 8085 properly
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.5.1)
2021-06-11 23:52:15.037 INFO 1 --- [ main] com.example.demo.Demowar1Application : Starting Demowar1Application v0.0.1-SNAPSHOT using Java 1.8.0_292 on demowar1-pod with PID 1 (/demowar1.jar started by root in /)
2021-06-11 23:52:15.039 INFO 1 --- [ main] com.example.demo.Demowar1Application : No active profile set, falling back to default profiles: default
2021-06-11 23:52:15.937 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8085 (http)
2021-06-11 23:52:15.948 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-06-11 23:52:15.948 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.46]
2021-06-11 23:52:15.999 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-06-11 23:52:15.999 INFO 1 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 915 ms
2021-06-11 23:52:16.491 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8085 (http) with context path ''
2021-06-11 23:52:16.499 INFO 1 --- [ main] com.example.demo.Demowar1Application : Started Demowar1Application in 1.83 seconds (JVM running for 2.22)
The Pod here can't be reached from your machine until it's exposed. You can do that by creating a service which directs your requests to the pods.
https://kubernetes.io/docs/concepts/services-networking/service/
Alternatively, If you want to test only without exposing your app, you can do port-forward from your machine to pods, like below
kubectl port-forward pods/demowar1 8085:8085
and then do localhost:8085 on your machine.
Documentation for the same -> https://kubernetes.io/docs/tasks/access-application-cluster/port-forward-access-application-cluster/
I was trying to run the springboot project at port 8082. But it is failing again and again. Please give me a feasible solution.
Full Stacktrace:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.2.RELEASE)
2019-12-26 18:02:23.947 INFO 3680 --- [ restartedMain] c.i.s.w.s.SpringBootFirstWebApplication : Starting SpringBootFirstWebApplication on DESKTOP-BK9RRM4 with PID 3680 (C:\Users\zunayeed\springboot-workspace01\spring-boot-first-web-application\spring-boot-first-web-application\target\classes started by zunayeed in C:\Users\zunayeed\springboot-workspace01\spring-boot-first-web-application\spring-boot-first-web-application)
2019-12-26 18:02:23.953 INFO 3680 --- [ restartedMain] c.i.s.w.s.SpringBootFirstWebApplication : No active profile set, falling back to default profiles: default
2019-12-26 18:02:24.294 INFO 3680 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2019-12-26 18:02:24.295 INFO 3680 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2019-12-26 18:02:29.465 INFO 3680 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8082 (http)
2019-12-26 18:02:29.514 INFO 3680 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-12-26 18:02:29.515 INFO 3680 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.29]
2019-12-26 18:02:29.926 INFO 3680 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-12-26 18:02:29.927 DEBUG 3680 --- [ restartedMain] o.s.web.context.ContextLoader : Published root WebApplicationContext as ServletContext attribute with name [org.springframework.web.context.WebApplicationContext.ROOT]
2019-12-26 18:02:29.927 INFO 3680 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 5628 ms
2019-12-26 18:02:30.726 INFO 3680 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-12-26 18:02:30.744 DEBUG 3680 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerAdapter : ControllerAdvice beans: 0 #ModelAttribute, 0 #InitBinder, 1 RequestBodyAdvice, 1 ResponseBodyAdvice
2019-12-26 18:02:31.039 DEBUG 3680 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : 2 mappings in 'requestMappingHandlerMapping'
2019-12-26 18:02:31.130 DEBUG 3680 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Patterns [/webjars/**, /**] in 'resourceHandlerMapping'
2019-12-26 18:02:31.165 DEBUG 3680 --- [ restartedMain] .m.m.a.ExceptionHandlerExceptionResolver : ControllerAdvice beans: 0 #ExceptionHandler, 1 ResponseBodyAdvice
2019-12-26 18:02:31.345 WARN 3680 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : Unable to start LiveReload server
2019-12-26 18:02:31.811 INFO 3680 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2019-12-26 18:02:31.830 INFO 3680 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-12-26 18:02:31.832 ERROR 3680 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Web server failed to start. Port 8082 was already in use.
Action:
Identify and stop the process that's listening on port 8082 or configure this application to listen on another port.
2019-12-26 18:02:31.837 INFO 3680 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
Description:
Web server failed to start. Port 8082 was already in use.
Action:
Identify and stop the process that's listening on port 8082 or configure this application to listen on another port.
Possible causes:
Either you have already been running the application
Or another application is running in the same port
Solutions:
Configure the application to listen on another port(ex: 8081)
If you are using applcation.properties,
server.port=8081
If you are using application.yml
server:
port: 8081
Identify and stop the process that's listening on a port(8082)
window
ubuntu
mac
and restart your application
If you are using cmd or git bash , use the command :
netstat -ano
or further fine grain query :
nestat -ano | grep {port addr}
(note : grep only works in linux or gitbash , use findstr for cmd)
to identiy all the PID s that are currently running , which uses the particular port address that you want to use in your application. If the PIDs are not relevant , you could kill the PIDs using the command kill -9 {pid}. After that you could start your application in the same port.
Another easy approach is to use another port address which is not used by any other application. Just set the property server.port=8086 in your application.properties, or pass it as an argument when you start the application.
I am trying to start a Spring Cloud Config Server on a Docker container and I am getting Invalid Remote exception. Reading the logs it seems that the Docker container doesn't have access to the Volume but I am not sure. I am using CentOs. any suggestion will be appreciatted.
Dockerfile
FROM openjdk:8-jdk-alpine
MAINTAINER jimis.drpc#gmail.com
COPY files/config-server-0.0.1-SNAPSHOT.jar /opt/spring-cloud/lib/
ENV SPRING_APPLICATION_JSON='{"spring": {"cloud": {"config": {"server": {"git": {"uri": "/var/lib/spring-cloud/config-repo", "clone-on-start": true}}}}}}'
ENTRYPOINT ["/usr/bin/java"]
CMD ["-jar", "/opt/spring-cloud/lib/config-server-0.0.1-SNAPSHOT.jar"]
VOLUME /var/lib/spring-cloud/config-repo
EXPOSE 8888
Spring Boot application.properties
server.port=8888
management.security.enabled=true
spring.autoconfigure.exclude=org.springframawork.boot.autoconfigure.SecurityAutoConfiguration
logs:
test]$ docker build --no-cache --file=Dockerfile --tag=config-server:latest --rm=true .
Sending build context to Docker daemon 30.3MB
Step 1/8 : FROM openjdk:8-jdk-alpine
---> 88d1c219f815
Step 2/8 : MAINTAINER jimis.drpc#gmail.com
---> Running in a204b40b9f04
Removing intermediate container a204b40b9f04
---> 456dacbfaefa
Step 3/8 : COPY files/config-server-0.0.1-SNAPSHOT.jar /opt/spring-cloud/lib/
---> 55d1d05d4999
Step 4/8 : ENV SPRING_APPLICATION_JSON='{"spring": {"cloud": {"config": {"server": {"git": {"uri": "/var/lib/spring-cloud/config-repo", "clone-on-start": true}}}}}}'
---> Running in 5036de819188
Removing intermediate container 5036de819188
---> dfecf1c03d37
Step 5/8 : ENTRYPOINT ["/usr/bin/java"]
---> Running in bfbbe5d1ec20
Removing intermediate container bfbbe5d1ec20
---> 9395dc9a8c81
Step 6/8 : CMD ["-jar", "/opt/spring-cloud/lib/config-server-0.0.1-SNAPSHOT.jar"]
---> Running in 0f5bc5285e8b
Removing intermediate container 0f5bc5285e8b
---> fc8e287837e7
Step 7/8 : VOLUME /var/lib/spring-cloud/config-repo
---> Running in 9125b1dcd48e
Removing intermediate container 9125b1dcd48e
---> 780c5215f875
Step 8/8 : EXPOSE 8888
---> Running in 7e752e7e84be
Removing intermediate container 7e752e7e84be
---> 8a664539c179
Successfully built 8a664539c179
Successfully tagged config-server:latest
[jimis#bv-vpc-1097 test]$ docker volume create --name=spring-cloud-config-repo
spring-cloud-config-repo
[jimis#bv-vpc-1097 test]$ docker run --name=config-server --publish=8888:8888 --volume=spring-cloud-config-repo:/var/lib/spring-cloud/config-repo config-server:latest
2019-04-11 16:22:17.683 INFO 1 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$9b802ec4] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.3.RELEASE)
2019-04-11 16:22:17.983 INFO 1 --- [ main] c.m.c.ConfigServerApplication : No active profile set, falling back to default profiles: default
2019-04-11 16:22:19.548 INFO 1 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=11be5ef3-61b1-3539-a246-b6326ba4f12c
2019-04-11 16:22:19.631 INFO 1 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$9b802ec4] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-04-11 16:22:20.199 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8888 (http)
2019-04-11 16:22:20.250 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-04-11 16:22:20.251 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.16]
2019-04-11 16:22:20.269 INFO 1 --- [ 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: [/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64:/usr/lib/jvm/java-1.8-openjdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
2019-04-11 16:22:20.561 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-04-11 16:22:20.561 INFO 1 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2551 ms
2019-04-11 16:22:21.652 WARN 1 --- [ main] .c.s.e.MultipleJGitEnvironmentRepository : Error occured cloning to base directory.
org.eclipse.jgit.api.errors.InvalidRemoteException: Invalid remote: origin
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:251) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar!/:5.1.3.201810200350-r]
at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:306) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar!/:5.1.3.201810200350-r]
at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:200) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar!/:5.1.3.201810200350-r]
at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.cloneToBasedir(JGitEnvironmentRepository.java:589) [spring-cloud-config-server-2.1.1.RELEASE.jar!/:2.1.1.RELEASE]