lochalhost:8080 does not display Centos 8 Tomcat SpringBoot server contents - spring-boot

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.

Related

SpringBoot3 + POI + Log4j GraalVm Native Image Runtime Error: Defining hidden classes at runtime is not supported

In the SpringBoot3 application built by Graalvm Native Image, I use Apache Poi to depend on log4j. The construction is successful, but the following errors occur at running. How can I configure it to avoid this error?
I tested in Spring Boot 2.7.1 + Spring Native, there is no problem.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.0.0)
2022-12-06T11:53:05.855+08:00 INFO 18532 --- [ restartedMain] com.example.dataserver.Application : Starting AOT-processed Application using Java 17.0.5 with PID 18532 (D:\work-ide\IDEA\data-server\target\data-server.exe started by westinyang in D:\work-ide\IDEA\data-server\target)
2022-12-06T11:53:05.855+08:00 INFO 18532 --- [ restartedMain] com.example.dataserver.Application : No active profile set, falling back to 1 default profile: "default"
2022-12-06T11:53:05.855+08:00 INFO 18532 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2022-12-06T11:53:05.855+08:00 INFO 18532 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2022-12-06T11:53:05.889+08:00 INFO 18532 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2022-12-06T11:53:05.889+08:00 INFO 18532 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-12-06T11:53:05.889+08:00 INFO 18532 --- [ restartedMain] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.1]
2022-12-06T11:53:05.897+08:00 INFO 18532 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-12-06T11:53:05.897+08:00 INFO 18532 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 41 ms
2022-12-06T11:53:05.920+08:00 INFO 18532 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2022-12-06T11:53:05.921+08:00 INFO 18532 --- [ restartedMain] com.example.dataserver.Application : Started Application in 0.072 seconds (process running for 0.078)
ERROR StatusLogger Unable to load services for service class org.apache.logging.log4j.spi.Provider
java.lang.InternalError: com.oracle.svm.core.jdk.UnsupportedFeatureError: Defining hidden classes at runtime is not supported.
at java.base#17.0.5/java.lang.invoke.InnerClassLambdaMetafactory.generateInnerClass(InnerClassLambdaMetafactory.java:413)
at java.base#17.0.5/java.lang.invoke.InnerClassLambdaMetafactory.spinInnerClass(InnerClassLambdaMetafactory.java:315)
at java.base#17.0.5/java.lang.invoke.InnerClassLambdaMetafactory.buildCallSite(InnerClassLambdaMetafactory.java:228)
at java.base#17.0.5/java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:341)
at org.apache.logging.log4j.util.ServiceLoaderUtil.loadClassloaderServices(ServiceLoaderUtil.java:93)
at org.apache.logging.log4j.util.ServiceLoaderUtil.loadServices(ServiceLoaderUtil.java:74)
at org.apache.logging.log4j.util.ServiceLoaderUtil.loadServices(ServiceLoaderUtil.java:68)
at org.apache.logging.log4j.util.ProviderUtil.<init>(ProviderUtil.java:67)
at org.apache.logging.log4j.util.ProviderUtil.lazyInit(ProviderUtil.java:145)
at org.apache.logging.log4j.util.ProviderUtil.hasProviders(ProviderUtil.java:129)
at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:90)
at org.apache.poi.util.IOUtils.<clinit>(IOUtils.java:43)
at org.apache.poi.poifs.filesystem.FileMagic.valueOf(FileMagic.java:177)
at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:309)
at cn.hutool.poi.excel.WorkbookUtil.createBook(WorkbookUtil.java:120)
at cn.hutool.poi.excel.WorkbookUtil.createBook(WorkbookUtil.java:70)
at cn.hutool.poi.excel.ExcelReader.<init>(ExcelReader.java:71)
at cn.hutool.poi.excel.ExcelReader.<init>(ExcelReader.java:50)
at cn.hutool.poi.excel.ExcelUtil.getReader(ExcelUtil.java:151)
at cn.hutool.poi.excel.ExcelUtil.getReader(ExcelUtil.java:127)
at com.example.dataserver.AppRunner.run(AppRunner.java:23)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:758)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:748)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at com.example.dataserver.Application.main(Application.java:13)
at java.base#17.0.5/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:775)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.windows.WindowsPlatformThreads.osThreadStartRoutine(WindowsPlatformThreads.java:178)
Caused by: com.oracle.svm.core.jdk.UnsupportedFeatureError: Defining hidden classes at runtime is not supported.
at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:89)
at java.base#17.0.5/java.lang.ClassLoader.defineClass0(ClassLoader.java:338)
at java.base#17.0.5/java.lang.System$2.defineClass(System.java:2307)
at java.base#17.0.5/java.lang.invoke.MethodHandles$Lookup$ClassDefiner.defineClass(MethodHandles.java:2439)
at java.base#17.0.5/java.lang.invoke.MethodHandles$Lookup$ClassDefiner.defineClassAsLookup(MethodHandles.java:2420)
at java.base#17.0.5/java.lang.invoke.MethodHandles$Lookup.defineHiddenClass(MethodHandles.java:2127)
at java.base#17.0.5/java.lang.invoke.InnerClassLambdaMetafactory.generateInnerClass(InnerClassLambdaMetafactory.java:407)
... 28 more
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
2022-12-06T11:53:05.981+08:00 INFO 18532 --- [ restartedMain] com.example.dataserver.AppRunner : 3
2022-12-06T11:53:05.981+08:00 INFO 18532 --- [ restartedMain] com.example.dataserver.AppRunner : Service running on 127.0.0.1:8080
pom.xml dependencies
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.10</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.3</version>
</dependency>
I tried some solutions, but there is no effect yet,I joined the native-image parameter --initialize-at-run-time=org.apache.logging.log4j.spi.Provider
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<configuration>
<buildArgs>
<arg>--no-fallback</arg>
<arg>--initialize-at-run-time=org.apache.logging.log4j.spi.Provider</arg>
<arg>-H:+AddAllCharsets</arg>
</buildArgs>
</configuration>
</plugin>

Error while running Springboot app in Kubernetes in Docket Desktop

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/

Getting error while trying to runa n maven based simple springboot project

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.

Deploy Spring Eureka Service Registry on Azure with docker image

I created a Docker Image and loaded it via the docker hub. Then is tried to run it as a docker container and exposed the port 8080. The container is listed and the port column shows the following: 0.0.0.0:8080->8080/tcp.
So in my opinion the service is running but I cant access it with the ip-addres/eureka.
How is it possible to open the Eureka dashboard?
Edit:
I changed the port and now the port column of the containers shows: 0.0.0.0:8761->8761/tcp
This is the log:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.5.RELEASE)
2019-07-03 12:04:04.714 INFO 1 --- [ main] d.h.d.DiscoveryServiceApplication : No active profile set, falling back to default profiles: default
2019-07-03 12:04:06.481 WARN 1 --- [ main] o.s.boot.actuate.endpoint.EndpointId : Endpoint ID 'service-registry' contains invalid characters, please migrate to a valid format.
2019-07-03 12:04:07.232 INFO 1 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=ce95a042-2fd4-339b-a733-0cc54c83f3f1
2019-07-03 12:04:07.484 INFO 1 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$f3fe9d60] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-07-03 12:04:08.092 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8761 (http)
2019-07-03 12:04:08.166 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-07-03 12:04:08.170 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.19]
2019-07-03 12:04:08.352 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-07-03 12:04:08.352 INFO 1 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3607 ms
2019-07-03 12:04:08.606 WARN 1 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2019-07-03 12:04:08.620 INFO 1 --- [ 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.
2019-07-03 12:04:08.669 INFO 1 --- [ main] c.netflix.config.DynamicPropertyFactory : DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration#1863d2fe
2019-07-03 12:04:10.133 INFO 1 --- [ main] c.s.j.s.i.a.WebApplicationImpl : Initiating Jersey application, version 'Jersey: 1.19.1 03/11/2016 02:08 PM'
2019-07-03 12:04:10.331 INFO 1 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2019-07-03 12:04:10.338 INFO 1 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2019-07-03 12:04:10.685 INFO 1 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2019-07-03 12:04:10.694 INFO 1 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2019-07-03 12:04:11.443 WARN 1 --- [ main] o.s.c.n.a.ArchaiusAutoConfiguration : No spring.application.name found, defaulting to 'application'
2019-07-03 12:04:11.445 WARN 1 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2019-07-03 12:04:11.445 INFO 1 --- [ 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.
2019-07-03 12:04:11.843 INFO 1 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-07-03 12:04:12.932 INFO 1 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2019-07-03 12:04:13.018 INFO 1 --- [ main] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2019-07-03 12:04:13.018 INFO 1 --- [ main] com.netflix.discovery.DiscoveryClient : Client configured to neither register nor query for data.
2019-07-03 12:04:13.041 INFO 1 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1562155453040 with initial instances count: 0
2019-07-03 12:04:13.162 INFO 1 --- [ main] c.n.eureka.DefaultEurekaServerContext : Initializing ...
2019-07-03 12:04:13.169 INFO 1 --- [ main] c.n.eureka.cluster.PeerEurekaNodes : Adding new peer nodes [http://localhost:8761/eureka/]
2019-07-03 12:04:13.569 INFO 1 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2019-07-03 12:04:13.570 INFO 1 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2019-07-03 12:04:13.571 INFO 1 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2019-07-03 12:04:13.571 INFO 1 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2019-07-03 12:04:13.841 INFO 1 --- [ main] c.n.eureka.cluster.PeerEurekaNodes : Replica node URL: http://localhost:8761/eureka/
2019-07-03 12:04:13.859 INFO 1 --- [ main] c.n.e.registry.AbstractInstanceRegistry : Finished initializing remote region registries. All known remote regions: []
2019-07-03 12:04:13.860 INFO 1 --- [ main] c.n.eureka.DefaultEurekaServerContext : Initialized
2019-07-03 12:04:13.890 INFO 1 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 2 endpoint(s) beneath base path '/actuator'
2019-07-03 12:04:14.103 INFO 1 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Registering application unknown with eureka with status UP
2019-07-03 12:04:14.123 INFO 1 --- [ Thread-11] o.s.c.n.e.server.EurekaServerBootstrap : Setting the eureka configuration..
2019-07-03 12:04:14.138 INFO 1 --- [ Thread-11] o.s.c.n.e.server.EurekaServerBootstrap : Eureka data center value eureka.datacenter is not set, defaulting to default
2019-07-03 12:04:14.139 INFO 1 --- [ Thread-11] o.s.c.n.e.server.EurekaServerBootstrap : Eureka environment value eureka.environment is not set, defaulting to test
2019-07-03 12:04:14.181 INFO 1 --- [ Thread-11] o.s.c.n.e.server.EurekaServerBootstrap : isAws returned false
2019-07-03 12:04:14.182 INFO 1 --- [ Thread-11] o.s.c.n.e.server.EurekaServerBootstrap : Initialized server context
2019-07-03 12:04:14.182 INFO 1 --- [ Thread-11] c.n.e.r.PeerAwareInstanceRegistryImpl : Got 1 instances from neighboring DS node
2019-07-03 12:04:14.182 INFO 1 --- [ Thread-11] c.n.e.r.PeerAwareInstanceRegistryImpl : Renew threshold is: 1
2019-07-03 12:04:14.183 INFO 1 --- [ Thread-11] c.n.e.r.PeerAwareInstanceRegistryImpl : Changing status to UP
2019-07-03 12:04:14.225 INFO 1 --- [ Thread-11] e.s.EurekaServerInitializerConfiguration : Started Eureka Server
2019-07-03 12:04:14.253 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8761 (http) with context path ''
2019-07-03 12:04:14.259 INFO 1 --- [ main] d.h.d.DiscoveryServiceApplication : Started DiscoveryServiceApplication in 12.423 seconds (JVM running for 13.3)
2019-07-03 12:05:14.187 INFO 1 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 0ms
2019-07-03 12:06:14.187 INFO 1 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 0ms
Container information
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8994d80a4ee2 marcelv93/service-discovery:latest "java -Djava.securit…" 6 minutes ago Up 6 minutes 0.0.0.0:8761->8761/tcp api
For your issue, you cannot access the container. As I know the possible reasons below:
the container is not running well.
the container is running well, but the application is not running well inside the container.
both container and the application is running well, but you expose a wrong port. The port is not the one that the application listens to inside the container.
So you need to check it for the point above. And I find the default port is 8761 and you need to set the configuration. Take a look at the Containerize-Spring-Cloud-Eureka-Server.

Starting Spring Cloud Config Server on Docker - InvalidRemoteException: Invalid remote: origin

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]

Resources