Change of port number not workingin sprintboot - java

I changed default port number from 8080 to 8082 in application.properties file using server.port=8082. Even after changing port number, if I try to run sprint boot app, server is taking default port 8080 and application is not starting.
Error message;
Description:
Web server failed to start. Port 8080 was already in use.
Action:
Identify and stop the process that's listening on port 8080 or configure this application to listen on another port.

i solved it like this
Solution
Enter 'server.port='8080' (changed port number) in the following 'application.properties' file where you can create a project.
After connecting to the terminal
Type 'sudo lsof -i :[port number you want to check]' to see which ports are running.
Delete server.port and run it again.

Related

Not able to access keycloak on kubernetes

I am facing a weird issue, my keycloak is running successfully in minikube but at the same time I am not able to access by port forwarding to 8080. I wanted my own spi to be deployed so created a new docker image file as shown below.
FROM jboss/keycloak:latest
ADD common-keycloak-spi-0.1.jar /opt/jboss/keycloak/standalone/deployments/
ENTRYPOINT ["/usr/bin/env"]
CMD ["sh","/opt/jboss/tools/docker-entrypoint.sh"]
Now this runs fine in docker container but when I am trying to depoloy it on kubernetes I am unable to access the service by using port forwading.
vipul#vipul-Latitude-5530:~/Downloads$ kubectl port-forward springdoc-64f8dbf547-xrqcl 8080:8080
Forwarding from 127.0.0.1:8080 -> 8080
Forwarding from [::1]:8080 -> 8080
Handling connection for 8080
Handling connection for 8080
E0216 15:24:29.872454 24829 portforward.go:407] an error occurred forwarding 8080 -> 8080: error forwarding port 8080 to pod 5ad97759ea56d8d9acbeecc9dc3cda33bdb0ff138b5c126de37cb7bad985b74f, uid : exit status 1: 2023/02/16 09:54:29 socat[93218] E connect(5, AF=2 127.0.0.1:8080, 16): Connection refused
E0216 15:24:29.873263 24829 portforward.go:233] lost connection to pod
Handling connection for 8080
E0216 15:24:29.874222 24829 portforward.go:345] error creating error stream for port 8080 -> 8080: EOF
vipul#vipul-Latitude-5530:~/Downloads$ kubectl exec springdoc-64f8dbf547-xrqcl -- /bin/bash
And also getting NONE for any port and host port in kubectl describe .
Thanks
You can check the following step to troubleshoot the issue:
Check whether the firewall is blocking the port. “netstat -anp | grep 8080”
Check the pod is configured correctly with port and host port in the config yaml file. Use thislink as a reference.
If you are using the same port configuration in Docker container and in the kubectl will not access the same port so try to check the port number.
Also you can check the blog by Ales Nosek for hostport.

ZooKeeper Starting on Incorrect Port

I am trying to start a zookeeper server from a a Java code withing a webapp. But somehow I see that it is trying to start on the Tomcat port rather than the port provided in the properties file.
I keep seeing this:
WARN | o.e.j.s.ServletContextHandler#269d82e2{/,null,UNAVAILABLE} contextPath ends with /*
WARN | Empty contextPath
StartZooKeeperServer EXCEPTION: org.apache.zookeeper.server.admin.AdminServer$AdminServerException: Problem starting AdminServer on address 0.0.0.0, port 8080 and command URL /commands
org.apache.zookeeper.server.admin.AdminServer$AdminServerException: Problem starting AdminServer on address 0.0.0.0, port 8080 and command URL /commands
at org.apache.zookeeper.server.admin.JettyAdminServer.start(JettyAdminServer.java:107)
at org.apache.zookeeper.server.ZooKeeperServerMain.runFromConfig(ZooKeeperServerMain.java:138)
But I have the clientPort set in the properties as 2182.
If you need any more information please do let me know.
The problem is not with the Zookeeper server but with the Admin Server.
Admin Server binds by default to port 8080. However, this port is allocated in your system so this exception is thrown.
You can add the following property to your zookeeper configuration:
admin.serverPort=9876 (any port other than 8080)
You can even disable this server if you do not need it using:
admin.enableServer=false
More information on the Zookeeper admin server:
https://zookeeper.apache.org/doc/r3.6.1/zookeeperAdmin.html#sc_adminserver

Rest API in Spring Boot application not able to access on local network

I'm developing a REST api using Spring Boot with tomcat. The API is accessible on the same system using postman but not able access on other system which is connect with same wifi.
application.properties
#Mongo db setting ...
spring.data.mongodb.database=testdb
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
#setting for server port
server.port=8080
server.address=192.168.0.117
spring.http.multipart.max-file-size=10MB
spring.http.multipart.max-request-size=10MB
Just Enable Firewall port for tomcat on your windows machine.
Goto Windows Firewall->Advanced Settings->Inbound Rules.
In the Right side click on New Rule->Then select Port from the dialog box and Next->Then type port "8080" (As by default Tomcat run on this port) and Next->Then select "Allow the connection"->Next->Give a Name ->Finish.
Maybe opening the port will help
If you use Windows you can run this bat file to open the port:
#echo off
set port=8080
netsh advfirewall firewall add rule name="Port%port%" protocol="TCP" localport=%port% action=allow dir=IN
echo %port% port opened
pause
To close the port:
#echo off
set port=8080
netsh advfirewall firewall delete rule name="Port%port%"
echo %port% port closed
pause
P.S. Didn't noticed that Jun already answered about firewall rule.

Issue with apache tomcat server always running a program its showing that port 8080 is already used..?

Issue with apache tomcat server always running a program its showing that port 8080 is already used..
netstat -ano | findstr < Port Number >
taskkill /F /PID < Process Id >
I tried this every time that error is shown the problem is solved.
but has to done each time the server to be started or restarted.
I want a permanent solution to resolve this instead of each and every time manually stop the process in 8080..
you could either change the port of the other process to avoid a port conflict, or simply change it in tomcat
How to change tomcat port number
and change it to something like 8081
Looks like a service automatically starts on each startup, have you had a look between your services which automatically restarts?
You can have a look which executable is running on which port with following command (needs admin privileges):
netstat -a -b
Got the command from here:
How can you find out which process is listening on a port on Windows?
and you should have an output like this:
TCP 0.0.0.0:8080 WS1515:0 LISTENING
[java.exe]
This should give already a hint which process automatically start on each startup, you can have a look in the service tab (you open a run window and input services.msc and press enter)
Since you are using netstat, I believe you are using Windows. There are two ways in which you can handle the issue:
Disable tomcat service that is running by checking in services.msc. You can change the mode of startup from automatic to manual. This usually happens when you have installed a software using an msi that installs the tomcat service as a part of it.
You can try to change your tomcat server port by editing the following lines in the /conf/server.xml:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443"/>
Change port = 8080 to something else like port = 8082. In that way, you can continue using the customized tomcat without harming any other essential service that has been installed as mentioned in point #1 above

How to create a domain data grid in Payara Server with domain discovery mode?

I want to create a Domain Data Grid in Payara Server 5.191 with Domain Discovery Mode, where each node discovers each other by knowing the node IP address and port. According to the documentation, the nodes are configured in the domain.xml. However, I couldn't find anything on how to exactly specify the nodes in the domain.xml. What is the name of the configuration option, where the nodes are specified?
It is similar to Glassfish.
Create it in the Windows Operating System
You must download the application server. enter link description here
when installed a directory is created
C:\Payara_Server
C:\Payara_Server\bin
We open shell command window
and inside the command window
C:\Payara_Server\bin ./asadmin
asadmin> create-domain --adminport 4848 domain1
Enter admin user name[Enter to accept default]>
Using port 4848 for Admin.
Default port 8080 for HTTP Instance is in use. Using 1161
Using default port 7676 for JMS.
Using default port 3700 for IIOP.
Using default port 8081 for HTTP_SSL.
Using default port 3820 for IIOP_SSL.
Using default port 3920 for IIOP_MUTUALAUTH.
Default port 8686 for JMX_ADMIN is in use. Using 1162
Distinguished Name of the self-signed X.509 Server Certificate is:
[CN=moonbeam.gateway.2wire.net,OU=GlassFish,O=Oracle Corp.,L=Redwood Shores,ST
California,C=US]
Domain domain1 created.
Command create-domain executed successfully.
C:\Payara_Server\glassfish\domains\domain1 created
Start the server
asadmin> start-domain domain1
link it with IDE NETBEANS

Categories

Resources