Running Spring project causes warnings "RMI TCP Accept-0: accept loop for ServerSocket[addr=0.0.0.0/0.0.0.0,localport=54571] throws" - spring

When I'am running start project from spring initializr I've this warning message
2021-06-03 15:48:38.987 WARN 9168 --- [MI TCP Accept-0] sun.rmi.transport.tcp : RMI TCP Accept-0: accept loop for ServerSocket[addr=0.0.0.0/0.0.0.0,localport=54408] throws
java.io.IOException: The server sockets created using the LocalRMIServerSocketFactory only accept connections from clients running on the host where the RMI remote objects have been exported.
at sun.management.jmxremote.LocalRMIServerSocketFactory$1.accept(LocalRMIServerSocketFactory.java:114) ~[na:1.8.0_291]
at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.executeAcceptLoop(TCPTransport.java:405) [na:1.8.0_291]
at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.run(TCPTransport.java:377) [na:1.8.0_291]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_291]
2021-06-03 15:48:39.081 INFO 9168 --- [ main] r.p.mmsclient.MmsclientApplication : Starting MmsclientApplication using Java 1.8.0_291 on d102 with PID 9168 (C:\Users\NTI\Downloads\mms-client\target\classes started by NTI in C:\Users\NTI\Downloads\mms-client)
2021-06-03 15:48:39.082 INFO 9168 --- [ main] r.p.mmsclient.MmsclientApplication : No active profile set, falling back to default profiles: default
2021-06-03 15:48:39.314 WARN 9168 --- [MI TCP Accept-0] sun.rmi.transport.tcp : RMI TCP Accept-0: accept loop for ServerSocket[addr=0.0.0.0/0.0.0.0,localport=54408] throws
java.io.IOException: The server sockets created using the LocalRMIServerSocketFactory only accept connections from clients running on the host where the RMI remote objects have been exported.
at sun.management.jmxremote.LocalRMIServerSocketFactory$1.accept(LocalRMIServerSocketFactory.java:114) ~[na:1.8.0_291]
at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.executeAcceptLoop(TCPTransport.java:405) [na:1.8.0_291]
at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.run(TCPTransport.java:377) [na:1.8.0_291]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_291]
2021-06-03 15:48:39.986 INFO 9168 --- [ main] r.p.mmsclient.MmsclientApplication : Started MmsclientApplication in 1.556 seconds (JVM running for 2.575)
Process finished with exit code 0

I believe that this is related to the local JMX agent and the configuration of the hosts file. First, ensure your hosts file has an appropriate mapping of localhost to 127.0.0.1. Then, add the following VM option:
-Djava.rmi.server.hostname=localhost
If you are using IntelliJ, you can find instructions for adding this VM option here.

Related

The Tomcat connector configured to listen on port 28081 failed to start in the linux

I'm doing a spring boot project , and this project can run successfully in the eclipse and war use cmd. However it failed to start in the linux environment.
I have used netstat -ano | grep 28081 , the port is not in use.
2019-04-02 05:49:50.628 WARN 25548 --- [localhost-startStop-1] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [cluster-ClusterId{value='5ca33035b36bfd63cc6ff647', description='null'}-lswsstpfdb3u.nam.nsroot.net:28120] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.waitForSignalOrTimeout(DefaultServerMonitor.java:226)
com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.waitForNext(DefaultServerMonitor.java:207)
com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:154)
java.lang.Thread.run(Thread.java:745)
2019-04-02 05:49:50.640 INFO 25548 --- [defaultTaskExecutor-4] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2019-04-02 05:49:50.646 ERROR 25548 --- [main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
The Tomcat connector configured to listen on port 28081 failed to start. The port may already be in use or the connector may be misconfigured.
Action:
Verify the connector's configuration, identify and stop any process that's listening on port 28081, or configure this application to listen on another port.
Local war instruction is :
C:\tmp\jdk1.8.0_31_x64\jre\bin\java -DaEnv=UAT -Denv=UAT -Da.domainName=pfDomain -Drealtime.nodeName=Node1 -jar C:\aServices.war -Djava.protocol.handler.pkgs=javax.net.ssl -Djavax.net.ssl.keyStore=C:\SSL-keystore.UAT.jks -Djavax.net.ssl.trustStore=C:\SSLTrust.UAT.jks
The application can start successfully.
In the application.properties file , the ssl location is wrong , it should like this :
server.ssl.key-store=/opt/a/etc/SSL-keystore.jks
server.ssl.trust-sotre=/opt/a/etc/certs/SSLTrust.jks

Docker, Mongodb,Spring Boot on Windows getting Connection refused error

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.

Undertow http and https

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.

Spring Boot Jetty server not works over https (SSL)

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.

Spring boot with spring.data.mongodb.uri=mongodb://otherhost/test

I developed a Spring boot application with MongoDB. While the MongoDB in the localhost, it works fine, but when the MongoDB is in different the server, I changed the setting in application.properties as
spring.data.mongodb.uri=mongodb://192.168.7.31/gcp
spring.data.mongodb.username=xxx
spring.data.mongodb.password=xxxxxxx
the application faileds as it still looks for the mongoDB in localhost
2017-01-04 11:47:46.161 INFO 15610 --- [ main] org.mongodb.driver.cluster : Adding discovered server localhost:27017 to client view of cluster
2017-01-04 11:47:46.218 INFO 15610 --- [localhost:27017] org.mongodb.driver.cluster : Exception in monitor thread while connecting to server localhost:27017
com.mongodb.MongoSocketOpenException: Exception opening socket
at com.mongodb.connection.SocketStream.open(SocketStream.java:63) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:114) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.connection.DefaultServerMonitor$ServerMonitorR
Anyone can help to tell me how to set the parameters?

Resources