Related
In Eclipse, I got this error:
run:
[java] Error creating the server socket.
[java] Oct 04, 2012 5:31:38 PM cascadas.ace.AceFactory bootstrap
[java] SEVERE: Failed to create world : java.net.BindException: Address already in use: JVM_Bind
[java] Java Result: -1
BUILD SUCCESSFUL
Total time: 10 seconds
I'm not sure why it came up now, but it ran fine just a few hours ago. Do I need to restart my machine? How do i get to the bottom of it? I appreciate any tips or advice.
If you know what port the process is running you can type:
lsof -i:<port>.
For instance, lsof -i:8080, to list the process (pid) running on port 8080.
Then kill the process with kill <pid>
Yes you have another process bound to the same port.
TCPView (Windows only) from Windows Sysinternals is my favorite app whenever I have a JVM_BIND error. It shows which processes are listening on which port. It also provides a convenient context menu to either kill the process or close the connection that is getting in the way.
In windows
netstat -ano
will list all the protocols, ports and processes listening .
Use
taskkill -pid "proces to kill" /f
to kill the process listening to the port.
e.g
taskkill -pid 431 /f
In Ubuntu/Unix we can resolve this problem in 2 steps as described below.
Type netstat -plten |grep java
This will give an output similar to:
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 1001 76084 9488/java
Here 8080 is the port number at which the java process is listening and 9488 is its process id (pid).
In order to free the occupied port, we have to kill this process using the kill command.
kill -9 9488
9488 is the process id from earlier. We use -9 to force stop the process.
Your port should now be free and you can restart the server.
In Mac:
Kill process
Terminal: kill <pid>
Find pid:
Terminal: lsof -i:<port>
From Diego Pino answer
(Windows Only)
To kill a process you first need to find the Process Id (pid)
By running the command :
netstat -ano | findstr :yourPortNumber
You will get your Process Id (PID), Now to kill the same process run this command:
taskkill /pid yourid /f
For windows :
Find the process id
netstat -nao | find "8080"
It will show you the process ID as a number.
Example:
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 18856
Here 18856 is the process ID
Kill that process
taskkill /PID 18856 /F
Output : SUCCESS: The process with PID 18856 has been terminated.
Here using taskkill you are killing the process ID:18856
For linux/Mac:
sudo kill -9 $(sudo lsof -t -i:8080)
Here you find the process by port 8080 using sudo lsof -t -i:8080 and killing it by sudo kill command
You have another process running on the same port.
You could try killing one of the java.exe services running in your task manager - ps make sure you dont kill eclipse since that is listed as java.exe as well. If nothing else works, restarting your machine will fix it anyhow. It looks like youre not shutting down a socket from a previous test. Hope this helps.
For those who are looking for the simplest of the answers (as that is what we usually miss), just stop your running project and start it again.
Most of the time what we do is we forget to stop the project we ran earlier and when we re-run the project it shows such an issue.
I am also attaching a photo to make it clearer (I use 'Spring tool suite').
So what you need to do is either click the button on the extreme right, if you want to relaunch the same project or first click on the button which is 2nd from the right to stop your project and then the button on the extreme left to run your project. I hope this will solve the issue of few of the newer programmers. :)
In Windows CMD line, find out the Process ID that hold a connection on the bind port by entering following command:
C:> netstat -a -o
-a show all connections
-o show process identifier
And then Terminate the process.
You need to close your port
if you are a linux user then type
fuser -k 8080/tcp
This BindException would come when another process is already running in the specified port(8080).
You can use anyone of the following approach.
Change the server port: If you are using Tomcat server and IntelliJ IDE, you can configure the server port by configuring the tomcat server
or
Go to tomcat>conf folder
Edit server.xml
Search "Connector port"
Replace "8080" by your port number
Restart tomcat server.
Kill the existing running process in that port and start the server.
For Linux/Mac
sudo kill -9 $(sudo lsof -t -i:8080)
For Windows
netstat -ano | findstr :8080
taskkill /PID typeyourPIDhere /F
Note: (/F forcefully terminates the process)
Yes, as Guido Simone said it because another process listening to the same port.If you are in Ubuntu You can simply kill that process giving command
sudo kill $(sudo lsof -t -i:[port number])
ex: sudo kill $(sudo lsof -t -i:8080)
But once it didn't work for me.
i gave the command
$ lsof -i:[port]
and it shows nothing.
I checked my docker containers using command
docker ps -a but non of them alive.All containers has stopped
(but i remember ,i stopped one container which was used same port few minutes ago.).To make sure that docker is not the reason,I stop whole docker process using command sudo service docker stop and try again.
Surprisingly eclipse didn't show the error at that time .It run my program perfectly.
Hope my experience will help some one.
The port is already being used by some other process as #Diego Pino said u can use lsof on unix to locate the process and kill the respective one, if you are on windows use netstat -ano to get all the pids of the process and the ports that everyone acquires. search for your intended port and kill.
to be very easy just restart your machine , if thats possible :)
Restart the PC once, I think it will work. It started working in my case. One more thing can be done go to Task Manager and End the process.
In my case Tomcat was running in a background. I've installed it as a external servlet while using Eclipse.
With a Spring Boot in Intellij it has it own server but cannot start while it's already occupied.
In my case Tomcat starts automatically I turn on my OS, that is why I need to shut down him manualy:
$ sudo service tomcat stop
of course "tomcat" depends what version of tomcat you are using.
Hope it might help to someone.
I faced similar issue in Eclipse when two consoles were opened when I started the Server program first and then the Client program. I used to stop the program in the single console thinking that it had closed the server, but it had only closed the client and not the server. I found running Java processes in my Task manager. This problem was solved by closing both Server and Client programs from their individual consoles(Eclipse shows console of latest active program). So when I started the Server program again, the port was again open to be captured.
Your port must be busy in some Other Process. So you can download TCPView on https://technet.microsoft.com/en-us/sysinternals/bb897437 and kill the process for used port.
If you don't know your port, double click on the server that is not starting and click on Open Server Properties Page and click on glassfish from left column. You will find the ports here.
(1) check the port is in use or not, kill that process
$ lsof -i:[port]
(2) another reason is the port is used by ipv6, solution:
edit /etc/sysctl.conf
add this to the file
net.ipv6.conf.all.disable_ipv6 = 1
then make it effect
$ sudo sysctl -p /etc/sysctl.conf
or just reboot
It means some other process is already using the port. In case if this port is being used by some other critical applications and you don't want to close that application, the better way is to choose any other port which is free to use.
Configure your application to use any other port which is free and you will see your application working.
You can close every Java Process and start again your app:
taskkill /F /IM java.exe
start your app again...
I actually just used the Terminate button in Console Tab. It's a small red box. Hope that hepls.
I'm using IntelliJ Idea Community Edition IDE and I'm trying to run a Maven WebApp with Jetty by command line. I'm on a RedHat box
I run this command:
mvn clean install -P deployJetty -Djetty.port=8083
And I get this error:
Listening for transport dt_socket at address: 5005
Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 1099; nested exception is:
java.net.BindException: Address already in use
The funny thing is that when I close IntelliJ Idea, the 1099 port is released.
I can't find the reason why and how Idea is using this port.
Any ideas ? Thank you.
Note: As a workaround, I'm closing Idea, running Jetty and then opening Idea (and I guess forcing it to pick another port)
I am sure IntelliJ Idea does not use 1099 port internally. I have used this PORT for Tomcat. I would suggest checking if any of idea plugins that you have installed are running on this port. Most of the operating systems can give you the application name that is running on that port.
Eg: lsof -w -n -i tcp:8080 would give me the application running on 8080 on my linux machine.
Hope this helps.
Go to terminal and kill the session
ps -aef | grep 1099
kill -9 PID
on windows :
step 1] find the process : netstat -ano or netstat -aon |find /i "listening" |find "Port no"
step 2] kill the process : Taskkill /F /IM (Process id obtained from above step)
Please see example below:
make sure you have localhost defined in your /etc/hosts file, and that it's defined only once
localhost 127.0.0.1
it was leaving the maven process in intelliJ hanging which caused the port 1099 already in use error even after changing the jmx port to something different.
On my Mac a process called "fsnotifier" is using port 1099. A google on this indicates that it's an IntelliJ file system watcher. Solved by using a different port for JMX.
In my case I got disconnected from the JBoss instance that I had started in IDEA, and the server continued to run, thus using the 1099 port for JMX.
You can either kill the server process using that port (it'll be a java process using a lot of memory) or create a remote debug configuration that you can use in case you don't want to restart the server. Use the same debug ports for the local and remote debug configurations.
Since it is easy to tackle with Terminal.
Open the Terminal and type following.
fuser 1099/tcp
If a process uses above port, it should return something output like this.
1099/tcp: 2222
The last column value (2222) is referred to the Process ID (PID).
Just KILL it as follows.
kill -9 2222
Now you can start debugging.
On windows command line :
1. find which process uses port 1099
netstat -ano -p tcp |find "1099"
2. Process with PID 2112 is listening on port 1099. Now we can query task list to find the process.
tasklist |find "2112"
Also You can check the windows task manager.
3. Kill the process from task manager, by right click on the item and selecting End task or via command line :
taskkill /F /PID 2112
I recently downloaded Glassfish 4.0 and I want to use it in NetBeans for making some Web Applications, but when I want to start the domain1 (asadmin> start-domain domain1) I keep getting this error:"There is a process already using the admin port 4848 -- it probably is another instance of a GlassFish server". Any clue what could be the problem?
Glassfish could not resolve the host name. Diagnose the problem (on Linux) as follows:
Open a Terminal.
Type hostname.
Type: ping $(hostname)
If the ping command fails (could not find the host), then add the host name to /etc/hosts. This can be accomplished as follows:
Switch to root: sudo su -
Type: echo "127.0.0.1 $(hostname)" >> /etc/hosts
Kill GlassFish
Restart GlassFish
your system using port 4848 that is why.
when glassfish starts its need three port numbers one for administrations, one for http applications other for https.
so in you system 4848 is already reserved by some program or server.
Or you can change default port number as per your need like below.
type in command prompt.
To change the HTTP port to 10080:
asadmin set server.http-service.http-listener.http-listener-1.port=10080
To change the HTTPS port to 10443:
asadmin set server.http-service.http-listener.http-listener-2.port=10443
To change the administration server port to 14848:
asadmin set server.http-service.http-listener.admin-listener.port=14848
Try lsof -i:4848 on the terminal.
Kill the java processes listed using the command kill -9 <PID>.
If you have a GUI task manager, say like Activity Monitor on OSX, then you can just kill the java processes listed there.
Hope this works for anyone facing this problem.
1- Go to the config folder inside your domain.
(In my case: C:\Glassfish\glassfish\domains\mydomain\config\ )
2-Open the file domain
3-Update the port number on these three lines:
4-Restart your domain:
--Note
For restarting the domain:
1-Open cmd console
2-Navigate yo your domain
3-Execute: asadmin restart-domain mydomain
--I hope it helps :-)
Solution can be this:
in console type:
echo $HOSTNAME
then make sure the output follows 127.0.0.1 string in
/etc/hosts
For example:
127.0.0.1 dev.myserv.pl
Do a
netstat -aon
from command line and check which process is using your port.
If it's not important, kill it as a quick'n'dirty solution.
I'm getting the following error when I try to run a simple JSP program on Tomcat in Eclipse.
Several ports (8005, 8080, 8009) required by Tomcat v6.0 Server at localhost are already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s).
How is this caused and how can I solve it?
You've another instance of Tomcat already running. You can confirm this by going to http://localhost:8080 in your webbrowser and check if you get the Tomcat default home page or a Tomcat-specific 404 error page. Both are equally valid evidence that Tomcat runs fine; if it didn't, then you would have gotten a browser specific HTTP connection timeout error message.
You need to shutdown it. Go to /bin subfolder of the Tomcat installation folder and execute the shutdown.bat (Windows) or shutdown.sh (Unix) script. If in vain, close Eclipse and then open the task manager and kill all java and/or javaw processes.
Or if you actually installed it as a Windows service for some reason (this is namely intented for production and is unhelpful when you're just developing), open the services manager (Start > Run > services.msc) and stop the Tomcat service. If necessary, uninstall the Windows service altogether. For development, just the ZIP file is sufficient.
Or if your actual intent is to run two instances of Tomcat simultaneously, then you have to configure the second instance to listen on different ports. Consult the Tomcat documentation for more detail.
kill $(ps -aef | grep java | grep apache | awk '{print $2}')
no need to restart Eclipse
if you get the above error, just enter this line in terminal
again start the tomcat in Eclipse.
works only in Linux based system ( Ubuntu ..etc )
If you are running on windows try this in the command line prompt:
netstat -ano
This will show all ports in use and the process id PID # of the process that is using that port.
Then Ctrl+Alt+Del and open Task Manager to see which process is that.
You can then choose either to close/stop it or configure your server to use another port.
To check if the new choosen port (let's say 8010) is available do this:
netstat -ano | grep 8010
If it does not return any lines then you are fine.
To change the port go to the Server view, open server.xml and change the port there.
Mine has this entry:
Connector port="8010" protocol="AJP/1.3" redirectPort="8443"
If you are on mac environment, here is what I did.
Find the process id running on this port from terminal, eg, 8080:
lsof -i :8080
and kill it:
kill -9 <PID>
Example:
You may see following result:
MacSys:bin krunal.$ lsof -i :8080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 21347 krunal 52u IPv6 XXX 0t0 TCP *:http-xxx (LISTEN)
and kill it: (kill -9 21347)
Steps to free port which is already used to run tomcat server in Eclipse
For example , suppose 8080 port is used , we need to make free 8080 to run tomcat
Step 1:
C:\Users\username>netstat -o -n -a | findstr 0.0:8080
TCP 0.0.0.0:3000 0.0.0.0:0 LISTENING 3116
Now , we can see that LISTENING port is 3116 for 8080 ,
We need to kill 3116 now
Step 2:-
C:\Users\username>taskkill /F /PID 3116
Step 3:
Go to Eclipse and start Server , it will run
If you use Eclipse then double click on servers and double click on tomcat server then one file will open. In that file change HTTP port to some other port number and save(Ctrl+S) then again start the server.
If Eclipse says
Several ports (8005, 8080, 8009) required by Tomcat v6.0 Server at localhost are already in use
This error comes because tomcat may be running in background so first stop that server..follow the below details.
Solution is:
Open the "console" view (window->show view->Console)
Then stop the tomcat server.
Then open the "server" view and start the server it will work.
Thanks!
I have no another instance of Tomcat running ad no other process using "Tomcat port" (in my case, the 8088 port).
Eclipse send the same message on starting Tomcat:
....The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s).
I solve the problem in this way:
go to bin of tomcat by prompt
launch startup.bat
launch shutdown.bat
start tomcat by Eclipse
What I did after reading all the suggested answer and as I know my port was already in use. I double clicked on Tomcat under the Servers tab in eclipse and it opened overview information and then find port information. Just changed conflicting port as mine was 8009 port (error mentioned during starting the server). I have changed it to 8008 and it works fine. Give a try if the changed port would not be in use server will start.
Step 1: netstat -a -o -n and it will bring up a network list,search for the local address like 127.0.0.1:8080 and note the PID (eq 3624)
C:\>netstat -a -o -n
Step2 : taskkill /F /PID 3624 . Run this command to kill that process.
C:\>taskkill /F /PID 3624
link to post
On Windows use command for stopping the already running tomcat instance and try running it again in eclipse, it may work.
net stop tomcat7
Or you can change the port in server's XML if you just want to run on some other ports.
Easy way to solve your problem:
The server may already be running in another process, or a system process may be using the port. In order to kill that port, do the following:
1) Download TCPView(only 285kb) from following link.
http://technet.microsoft.com/en-in/sysinternals/bb897437.aspx
2) Extract folder and start TCPView application.
3) Right click on java.exe(because 8009,8005 ports are commonly used by java process) and select End Process option.
this would stop another process easily..
NOTE: Running TOMCATPATH/bin/shutdown.bat may not shutdown Tomcat when it contains some demon or unmanaged
threads. In such cases TCPView works fine without any issues.
I checked all the answers but informing only to kill PID.
In case if you have terminal access shared by all it will not help or maybe you do not have permission to kill PID.
In this case what you can do is:
Double click on server
Go to Overview and change ports in Ports like this:
If you are in Java EE prospective in Eclipse and trying to start the Tomcat Server in Eclipse in debug mode, then you will get such errors. You must switch to debug prospective in Eclipse. I have solved my problem like this.
Sometimes if the ports are not freed even after attempting shutdown.bat what #BalusC suggested,you can kill the javaw process. Do following steps :
Click on Start Menu and open "Windows powershell"
Right click before opening and select "Run as administrator"
Enter command ps. You may see a image as follows :
See the process number of process "javaw".The process number is the rightmost number in the columns, I have highlighted in the image process number of javaw for example.
Enter command kill . javaw is killed and now you must be able to run the program.
Here's one more option to try if none of the efforts above helped. You might be using Eclipse from a Shared Drive (for eg, H:). If so, move/copy it the entire Eclipse directory to C: and try again.
My Eclipse could not open ports for Tomcat server (with the above error), nor even connect to internet. I also tried another Tomcat plugin (Sysdeo) which failed to open the ports too.
These are the options I tried:
Check and Kill Other Tomcat Instances
In command prompt, netstat -ano and check if any other processes are using the conflicted ports.
Find the PID and kill it
Try starting the server again.
Change Tomcat Ports in Eclipse
In Eclipse Server tab, double click the Tomcat instance. This will open the configuration tab.
Under Ports, change the port numbers. (for eg, 18080).
Kill java.exe and javaw
In Task Manager, find and kill java.exe and javaw (see https://stackoverflow.com/a/25334782/4212710 and https://stackoverflow.com/a/26136890/4212710)
Try starting the server again.
See my other answer for Eclipse not connecting to Internet (https://stackoverflow.com/a/37246087/4212710).
For windows users:
Go to Task Manager directly with CTRL+SHIFT+ESC key combination.
Kill the "java.exe" processes by right clicking and selecting "End Task".
The simpler fix that works for me is deleting my current deployed webapps from tomcat through the "Server" tab. Once I remove them the problem goes away. Simply re-deploy your project by going on Run As > Run on Server.
The problem often arises when Apache Tomcat fails to terminate, properly, even though a shutdown instruction was sent. In my case, using Tomcat 8, this happens with annoying regularity. Luckily, you can use Windows PowerShell and the netstat command to create a simple script to kill the process.
The following PowerShell script will parse the output from netstat to find any process that is listening on 127.0.0.1:8005, extract its PID and then kill that process:
netstat -a -o -n `
| select -skip 4 `
| % {$a = $_ -split ' {3,}'; New-Object 'PSObject' -Property #{Original=$_;Fields=$a}} `
| ? {$_.Fields[1] -match '127\.0\.0\.1\:8005$'} `
| % {Write-Host "Killing PID" $_.Fields[4] "..."; taskkill /F /PID $_.Fields[4] }
If your server.xml configures Tomcat to use a different port or IP, edit the regular expression on the script's fourth line accordingly.
Finally, I should point out that the situation is better on Linux because you can instruct Tomcat to save its PID to a file at startup-time and use a switch to force the shutdown, later - the shutdown script for 'nix systems already features the ability to kill the process and the sleuth-work with netstat is not required.
If the above issue occurs in Windows 7 or 10 based OS, the problem occurs because Tomcat is running as Windows Service. To stop Tomcat running as Windows Services, Open Windows Control Panel. Find the service "Apache Tomcat" and Stop it.
The Another way is to kill the process running on port 8080 using cmd.
Open cmd running it as administrator.
C:\users\username>netstat -o -n -a|findstr 0.0:8080
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 2160.
The above 2160 is process id of process running on port 8080 and kill that process using the following command
C:\users\username>taskkill /F /PID 2160
Go to IDE and start Server, it will run
It may be because you are not stopping your tomcat service properly. To do that, Open your task manager there you can see a javaw.exe service. First stop that service. Now restart your tomcat it works fine.
In my case, it was giving me the error: Port 8005 required by Tomcat v8.0 Server at localhost is already in use
I changed 8005 port in apache-tomcat-8.0.39\conf\server.xml but changes were not getting reflected. Then I did these changes from eclipse. by double clicking server and modifying the port from 8005 to 8006 and it works.
Before putting 8006 I checked in windows shell if this port is available or not. By executing following command:
netstat -a -o -n | findstr 8006
I face the same problem and after searching the answer as shown below:
1. open Monitor Tomcat as shown below:
Simply press stop as shown in below picure:
Finally it works with me after many trials and suggested solutions.
Best Regards,
Kerelos Mikhail
On Eclipse make a raw delete of Tomcat configuration folder under project "Servers".
I tried it as last hope and it worked.
In case of windows, I experienced a new stuff...
stopping tomcat from /bin folder will immediately not releasing the port 8080. It takes around 5-10 mins to release the port. After 10 mins again if i try to run my project
Run-> Run on server .. it allows to run.
I'm unsure whether my understanding is correct!
Refer to the following blog "how to kill tomcat without have to restart your computer"
http://stanicblog.blogspot.fr/2012/01/how-to-kill-apache-tomcat-without.html
Hope this will help someone in the future.
It occurs when others in the project are also using the same port numbers as you are using!
double click tomcat server, change port numbers to anything 8585 or whatever. The code will now begin to run!
How to kill a windows service using PID -
open command prompt and type netstat -ano
find the PID of the ports which are in used, in this case, it will be 8080, 8005,8009. Let's say PID of these ports are 5760.
Now Type taskkill /f /pid 5760
it will close the PID and ports will be available for use. Now you can start tomcat as normal by Windows services or by eclipse itself.
Thanks
kill a Windows service that's stuck on stopping or starting
Several ports (8005, 8080, 8009) required by Tomcat vX.X Server at localhost are already in use
To check whether another instance of Tomcat already running or some other process is using the ports you can use:
netstat -b -a in command prompt for windows. This lists the ports in use and gives you the executable that's using each one. You need to be in the admin group to do this.
You might get something like this:
TCP 192.168.0.1:8009 192.168.0.1:0 LISTENING 196 [Tomcat7.exe]
TCP 192.168.0.1:8080 192.168.0.1:0 LISTENING 196 [Tomcat7.exe]
TCP 192.168.0.1:8005 192.168.0.1:0 LISTENING 196 [Tomcat7.exe]
Open task manager Ctrl+Shift+Esc, and kill Tomcat7.exe or any other process using these ports.
Your Tomcat is probably running already. That's why you have got an error. I've had the same problem before. I solved it very simply:
Restart your computer
Open Eclipse
Run your Tomcat
That's all.
If checked the other questions regarding this issue but so far no soultion.
Here is my setup:
TC6 runs on a debian vm on my macbook. in /etc/default/tomcat6.0 I have following options set:
CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8086 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
netstat -ntlp gives me:
tcp6 0 0 :::8080 :::* LISTEN 6550/java
tcp6 0 0 :::8086 :::* LISTEN 6550/java
Where 6550:
root 6550 3.3 6.8 224888 52984 pts/0 Sl 10:31 0:43 /usr/lib/jvm/java-6-sun/bin/java -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=/var/lib/tomcat6.0/conf/logging.properties -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8086 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.endorsed.dirs=/usr/share/tomcat6.0/common/endorsed -classpath :/usr/lib/jvm/java-6-sun/jre//lib/jcert.jar:/usr/lib/jvm/java-6-sun/jre//lib/jnet.jar:/usr/lib/jvm/java-6-sun/jre//lib/jsse.jar:/usr/share/tomcat6.0/bin/bootstrap.jar:/usr/share/tomcat6.0/bin/commons-logging-api.jar -Dcatalina.base=/var/lib/tomcat6.0 -Dcatalina.home=/usr/share/tomcat6.0 -Djava.io.tmpdir=/var/lib/tomcat6.0/temp org.apache.catalina.startup.Bootstrap start
Firewall:
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT all anywhere anywhere
Chain FORWARD (policy DROP)
target prot opt source destination
Chain OUTPUT (policy DROP)
target prot opt source destination
ACCEPT all anywhere anywhere
When I try to connect from OSX using jvisualm:
- adding a new host with the hostname of my vm (added it to /etc/hosts)
- adding a new JMX-Connection
VisualVM fails with:
Cannot connect using service:jmx:rmi///jndi/rmi://<vmhostname>:8086/jmxrmi
When I connect to my VM using ssh -X and start jvisualvm on the same machine that tomcat is running on, I do not initially see TC, but I can add the jmx connection as above.
Could this be an issue with foreign hosts being misteriously prevented to access the rmiregistry?
Why would anyone do such a dumb thing?
What am I doing wrong?
(sorry 4 the lengthy post)
Here is a tutorial on how to connect Visual VM to Tomcat 7. It is a bit on the verbose side, but should help steer you around a number of the problems most people run into.
Check out the jmx listener on this page.
http://tomcat.apache.org/tomcat-6.0-doc/config/listeners.html
It lets you set both the JMX port and the RMI registry port, both of which have to open on your firewall.
Try adding to catalina_opts: -Djava.rmi.server.hostname=vmhostname
and ensure that your mac is able to resolve this hostname, e.g.
nc -v vmhostname 8086
should succeed in opening the connection.
You may try to add actual ip and hostname to /etc/hosts where jstatd is running.
Follow this steps,
Download jvisualvm setup from Download Jvisualvm
Unzip this setup and go to bin directory from command line
Use this command to start the visualvm:
\bin>visualvm.exe -J-Dnetbeans.system_socks_proxy=localhost:9998 -J-Djava.net.useSystemProxies=true
get the putty setup ,go to installation directory of putty use following command to ssh tunnel to remote system
putty -D 9998 -load Name_of_the_saved_putty_session
saved_putty_session should have tunnel to localhost:JMX_port and some_source_port
now in visualvm UI in Left nav ,right click the remote and "Add remote host" , with public ip of remote host
Now on this added remote host right click and say "ADD JMX CONNECTION"
In a connection box say localhost:source_port_provided_in_putty_tunnel
Click on the ok button and you are done.
So the above worked for me:
service:jmx:rmi:///jndi/rmi://machinedomainname:1099/jmxrmi
After spending 1/2 day on this. Following all the usual instructions and getting frustrated the above cracked it.
I have a play application deployed in amazon ec2 with the following flags:
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=<myport>
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.local.only=false
-Djava.rmi.server.hostname=<mymachinedomainname>
I have jvisualvm running locally on my mac.
I added a jvisualvm remote host with host name:
<mymachinedomainname>
Then added added a jmx connection to this host.
I tried the recommended
service:jmx:rmi://<mymachinedomainname>:<myport>
but it would just not connect.
But as soon as i did
service:jmx:rmi:///jndi/rmi://<mymachinedomainname>:<myport>/jmxrmi
instead. it connected and works.
No idea why! but it works.
Make sure that you can
a) ping <vmhostname>
b) telnet <vmhostname> 8086
Note also that you can use IP address instead of <vmhostname>
Make sure the jstatd process is running on the remote machine which you want to monitor, with required permissions.
I would suggest using this option:
-Dcom.sun.management.jmxremote.port=1099
Then, connect with
service:jmx:rmi:///jndi/rmi://machinedomainname:1099/jmxrmi
As long as RMI is listening on all interfaces ( ie. 0.0.0.0) then there should be no problem connecting from a remote server as long as the firewall is off (or carefully configured).
I have actually just tackled this problem myself and figured it out.
I would wager that the problem is the RMI connections - you can't predict which ports it will use and so you can't get it to work with a firewall.
The workaround is to use an SSH proxy:
SSH to the box where your application is running but use the -D option like this:
ssh user#remoteHost -D 9999
This will start a socks proxy on your local machine on port 9999.
Open JVisualVM and in the preferences, under 'network' configure it to use a socks proxy at localhost, on port 9999.
If you do the above, you should then be able to connect to the remote machine as normal and since all the RMI traffic is now going over the SSH proxy, it is punched through the firewall and works nicely.
Good luck :-)