I use embedded undertow server in my web project. It works well in Idea with listening port 80 and 443, following the log in idea.
2018-08-04 11:32:31.394 INFO 4933 --- [ main] o.s.b.w.e.u.UndertowServletWebServer : Undertow started on port(s) 443 (https) 80 (http) with context path ''
But when I run it on my ubuntu server or local command line:
java -jar xxxx.jar
Output log is
Undertow started on port(s) 443 (https) with context path ''
wihout listening port 80. I can only visit the site by inputing https://xxxx
handly.
I compared the log. The server log print the extra two lines
2018-08-04 11:38:37.950 WARN 14835 --- [ main] io.undertow.websockets.jsr : UT026009: XNIO worker was not set on WebSocketDeploymentInfo, the default worker will be used
2018-08-04 11:38:37.950 WARN 14835 --- [ main] io.undertow.websockets.jsr : UT026010: Buffer pool was not set on WebSocketDeploymentInfo, the default pool will be used
I din't know what's wrong. Any answer is helpful. Thanks.
Related
I wrote a simple backend application by spring boot and kotlin, here you can see the full settings https://github.com/lifeodyssey/demo
this bug performed as
I can start and access the application by ./gradlew bootRun
I can start and access the application by java -jar demo.jar
But I could not access the application when I try to start it in a container, even I can see a successful log by docker logs containerID. The log is given below
2022-11-12 15:50:33.017 INFO 1 --- [ main] com.example.demo.DemoApplicationKt : Starting DemoApplicationKt using Java 11.0.16 on eeb1dfe09e6a with PID 1 (/Demo-0.0.1.jar started by root in /)
2022-11-12 15:50:33.029 INFO 1 --- [ main] com.example.demo.DemoApplicationKt : No active profile set, falling back to 1 default profile: "default"
2022-11-12 15:50:34.315 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode
2022-11-12 15:50:34.320 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data MongoDB repositories in DEFAULT mode.
2022-11-12 15:50:34.346 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 15 ms. Found 0 MongoDB repository interfaces.
2022-11-12 15:50:35.564 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8000 (http)
2022-11-12 15:50:35.595 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-11-12 15:50:35.596 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.68]
2022-11-12 15:50:35.787 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-11-12 15:50:35.788 INFO 1 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2628 ms
2022-11-12 15:50:38.155 WARN 1 --- [ main] o.s.b.a.m.MustacheAutoConfiguration : Cannot find template location: classpath:/templates/ (please add some templates, check your Mustache configuration, or set spring.mustache.check-template-location=false)
2022-11-12 15:50:38.346 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8000 (http) with context path ''
2022-11-12 15:50:38.412 INFO 1 --- [ main] com.example.demo.DemoApplicationKt : Started DemoApplicationKt in 6.588 seconds (JVM running for 7.745)
And here is the Dockerfile
FROM openjdk:11
COPY /build/libs/demo-0.0.1-SNAPSHOT.jar Demo-0.0.1.jar
EXPOSE 8000
ENTRYPOINT ["java","-jar","/Demo-0.0.1.jar"]
Here is the commmand I used to build image and run container
docker build -t demo .
docker run -dp 8000:8000 demo:latest
I could not find where is the problem. Can you help me with it ?
Update
Thanks for the comments below, here is what showed when I access localhost
This site can’t be reached localhost refused to connect.
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED
I have tried change -dp 8000 to -d -p 8000, but nothing changed.
Try to connect to it using 127.0.0.1:8000 instead of localhost:8000, maybe localhost is not resolving to 127.0.0.1.
If not try a different port and/or browser. Finally your firewall might be blocking your server so check that.
I finally found the issue.
I installed two application two run my docker. One is colima, another is Docker Desktop.
I guess the problem is that docker do not know which one is the "localhost".
This problem fixed after I uninstall docker desktop and link docker to colima.
I am using default docker image of MongoDB and trying to connect using simple spring Boot application on windows box.
mongoDB image is getting stared correctly
IP in mongoDB image
I have spring-boot-starter-data-mongodb in my class path. i am using all spring boot default and only using below property in application.properties.
spring.data.mongodb.host=192.168.99.100
On application startup getting Connection refused: connect error
Logs
019-03-06 06:15:06.096 INFO 4664 --- [ main] org.mongodb.driver.cluster : Cluster created with settings {hosts=[192.168.99.100:27017], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
2019-03-06 06:15:06.096 INFO 4664 --- [ main] org.mongodb.driver.cluster : Adding discovered server 192.168.99.100:27017 to client view of cluster
2019-03-06 06:15:06.356 WARN 4664 --- [ main] o.s.d.m.c.m.BasicMongoPersistentProperty : Customizing field name for id property not allowed! Custom name will not be considered!
2019-03-06 06:15:06.928 INFO 4664 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-03-06 06:15:07.164 INFO 4664 --- [68.99.100:27017] org.mongodb.driver.cluster : Exception in monitor thread while connecting to server 192.168.99.100:27017
What i am missing here ?
Not a MongoDB expert, but a moderate Docker user speaking: It looks like you are not publishing the port MongoDB runs by default: 27017. That's why your spring application could not get a connection and throws this exception:
Exception in monitor thread while connecting to server 192.168.99.100:27017
So you may try publishing the port by using -p 27017:27017when initiating mongo container.
I have a Spring Boot application which runs on a remote server. When I build it to work over HTTP everything works fine. But when I am trying to setup SSL the application not work. It doesn't throw errors or anything. But I can't access any page in the browser (I have tried https://www.example.com, https://www.example.com:8443, https://example.com etc).
I have built keystore.jks on remote server machine from certificate.crt (which I have bought for my domain on ssl).
I have the following application.properties:
server.port=8443
server.ssl.key-store=classpath:keystore.jks
server.ssl.key-store-password=PASSWORD
server.ssl.key-password=PASSWORD
I have tried different configurations but no results. The same story happens when I trying to run it on my local machine (I thought it is because of I am going to localhost when the certificate is for example.com but maybe it is the same problem).
Here is the server output:
INFO 11041 --- [ main] o.e.jetty.util.ssl.SslContextFactory : x509=X509#2a492f2a(jetty,h=[www.example.com, example.com],w=[]) for >SslContextFactory#3277e499(jar:file:/root/application.jar!/BOOT->INF/classes!/keystore.jks,null)
2018-05-13 13:21:56.175 INFO 11041 --- [ main] >o.e.jetty.server.AbstractConnector : Started >ServerConnector#7ac2e39b{SSL,[ssl, http/1.1]}{0.0.0.0:8443}
2018-05-13 13:21:56.176 INFO 11041 --- [ main] >.s.b.c.e.j.JettyEmbeddedServletContainer : Jetty started on port(s) 8443 (ssl, http/1.1)
2018-05-13 13:21:56.179 INFO 11041 --- [ main] >c.b.product.BootApplication : Started BootApplication in 4.786 seconds (JVM running for 5.151)
So everything seems to be fine but it doesn't work.
Problem solved. It was just wrong generated keystore.jks.
I'm testing spring-boot-devtools with livereload on intelliJ.
I have simple SpringBootApplication that works fine.
When I start the app from maven command "mvn spring-boot:run" all works fine excepting that livereload server dont' start. No message on console appears and the chrome extensions show error that It's not possible to connect to livereload server.
If I start app with (right mousse button/Run Application.java), all works fine even livereload server. Message appears on console and browser is able to connect to livereload server.
Starting app from right mousse button/Run Application.java
Console message
2016-07-13 16:39:47.947 INFO 10440 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-07-13 16:39:48.026 INFO 10440 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2016-07-13 16:39:48.077 INFO 10440 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2016-07-13 16:39:48.145 INFO 10440 --- [ restartedMain] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8090 (http)
Starting app from mvn command "mvn spring-boot:run"
Chorme extension message:
Could not connect to LiveReload server. Please make sure that a compatible LiveReload server is running. (We recommend guard-livereload, until LiveReload2 comes to your platform.)
Console message. See that not show message LiveReload server is running on port....
2016-07-13 16:38:56.749 INFO 6924 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-07-13 16:38:56.852 INFO 6924 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2016-07-13 16:38:56.898 INFO 6924 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8090 (http)
Why maven command don't start livereload server?
You need to tell Maven to fork a separate JVM to run your application, rather than it running in the same JVM as Maven:
$ mvn spring-boot:run -Dfork=true
I'm using spring cloud Brixton.M4 and spring boot is v1.3.1, with eureka first approach and application starts on random port server.port=0 but its register it self at port 0 with eureka server.
here is my bootstrap.properties file
server.port=0
spring.application.name=course-composite-service
spring.cloud.config.fail-fast=true
spring.cloud.config.label=config-dev
spring.cloud.config.discovery.enabled=true
spring.cloud.config.discovery.serviceId=config-server
eureka.client.serviceUrl.defaultZone=http://localhost:8002/eureka/
and below its the log
2016-01-11 18:36:50.286 INFO 17233 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_COURSE-COMPOSITE-SERVICE/192.168.17.178:course-composite-service:0: registering service...
2016-01-11 18:36:50.288 INFO 17233 --- [ main] .w.c.c.CourseCompositeServiceApplication : Started CourseCompositeServiceApplication in 5.325 seconds (JVM running for 5.856)
2016-01-11 18:36:50.321 INFO 17233 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_COURSE-COMPOSITE-SERVICE/192.168.17.178:course-composite-service:0 - registration status: 204
and eureka dashboard shows
COURSE-COMPOSITE-SERVICE UP (1) - 192.168.17.178:course-composite-service:0
why its not registering with the actual port its running?
i'm providing other eureka configurations from the Config Sever they are
eureka.client.register-with-eureka=true
eureka.instance.leaseRenewalIntervalInSeconds=10
eureka.instance.leaseExpirationDurationInSeconds=5
eureka.instance.preferIpAddress=false
eureka.instance.metadataMap.hostname=${vcap.application.application_uris[0]}
eureka.instance.metadataMap.instanceId=${vcap.application.instance_id:${spring.application.name}:${spring.application.instance_id:${random.value}}}