I've connected my Nexus One device to the PC. The USB debugging on the device is on. When I run the app from Eclipse, it works fine on the device. However, if I attempt to Debug, i get a message box on the Nexus One stating that it's waiting for the debugger to attach. On the Eclipse side, after about 20 or so seconds of thinking I get the following in the Console
Attempting to connect debugger to 'com.angryhacker.printerfun' on port 8600
Launch error: Failed to connect to remote VM. Connection timed out.
What am I missing?
1) Enabling USB debugging on the device is the first step. It sounds like you've done that ... but it wouldn't hurt to double check everything:
http://developer.android.com/guide/developing/device.html
2) As the same link also says, make sure debugging is enabled in your project's AndroidManifest.xml
3) Definitely check your host PC's firewall (for example, Windows firewall) to make sure it isn't blocking any ports.
4) For troubleshooting purposes, you can also try:
a) setting a longer timeout
b) trying a different port#
ADDENDUM:
Q: I'm assuming you've NEVER successfully downloaded and run an .apk from your Eclipse compiler to your NexusOne handset. Correct?
Q: I'm also assuming that when you try "Debug As", you see your physical handset in the GUI, and you've selected it. Correct?
Test to see if it works when your PC is not connected to the net (no WiFi, no network cables). If it does work under those conditions, then it may be that you need to make sure that addresses are resolving to localhost properly. The messages that DDMS and adb.exe use for debugging and communicating to the VM must properly resolve to localhost on your PC. (Yes, it's odd that other commands using DDMS & adb work just fine but debugging doesn't. Seems that something in DDMS or adb needs to be standardized so they all work under the same conditions.)
If you need to make sure that things are resolving to localhost properly:
1) Make sure that this line is in your /Windows/System32/drivers/etc/hosts file:
127.0.0.1 localhost
(you can have any amount of whitespace between "127.0.0.1" and "localhost")
2) If that doesn't work, then you may need to also add your PC's IPv4 address to the hosts file, and resolve it to localhost. (You can find out the IPv4 address for your machine with the ipconfig command.) If, for example, your machine's IPv4 address is 192.168.1.100 then you'd add the line
192.168.1.100 localhost
to your hosts file. (You can add it below the "127.0.0.1 localhost" line in the file.)
You can verify that adb (and your emulator if you're running one) is listening on ports by using the netstat -b command. (Note that you need admin privileges for the -b option. I open a command window using "Run as Administrator.")
I had the same error on Windows 8. I tried all the points as suggested by the answer from #paulsm4 but still nothing worked.
The problem got fixed when I set the compatibility mode for eclipse.exe to Windows XP SP3.
Hint: Right click on eclipse.exe => Properties => Compatibility => Compatibility Mode => Set the compatibility mode to "Windows XP (Service Pack 3)"
One more possible cause of such issues is the intent-filters in your activity.
When some intents are defined for your activity, you might not be able to debug the application. For example:
<action android:name="android.intent.action.DEVICE_INITIALIZATION_WIZARD" />
<action android:name="com.android.setupwizard.COMPLETED" />
Related
Respected Experts,
I have a stand alone java application and want to monitor the threads created by it. I am planning to use a tool like JConsole or JVisualVM. However, I am not able to connect these tools locally to my Java Application.
I am using Windows machine. JConsole and Java program are running locally. I have tried to run Java application with following JMV arguments with no success:
java -Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false LinkedListTest
When I try to connect using JConsole, my process id is greyed and following message appears:
Note: The management agent is not enabled on this process
I think I should be able to connect JConsole to a stand alone java application. Any thoughts what I am missing here
Thanks and Regards
Thanks for the inputs. I was able to solve the problem and the details are as follows:
As #Holger mentioned, both JConsole and JVisualVM can connect to the local Java Application running without any JMX arguments. The problem that I was facing was machine specific. I restarted the machine and deleted the following directory:
%TMP%\hsperfdata_User.Name
(I was not able to delete this directory without doing a restart)
Restarted JConsole/JVisualVM and was able to connect to local java processes using the process id.
In fact, the use of JVisualVM pointed me towards this fix. On start of JVisualVM, I got an error message stating something like local processes/applications can't be monitored. The message had a link to Troubleshooting guide. I am reproducing the relevant snippet:
Local Applications Cannot Be Monitored (Error Dialog On Startup)
Description: An error dialog saying that local applications cannot be monitored is shown >immediately after VisualVM startup. Locally running Java applications are displayed as Application> (pid ###).
Resolution: This can happen on Windows systems if the username contains capitalized letters. In >this case, username is UserName but the jvmstat directory created by JDK is >%TMP%\hsperfdata_username. To workaround the problem, exit all Java applications, delete the >%TMP%\hsperfdata_username directory and create new %TMP%\hsperfdata_UserName directory.
However, on my machine directory had the following format:
%TMP%\hsperfdata_User.Name
So, my recommendations are:
-check the name of the above mentioned directory for presence of camel case user name
-If not, follow the steps from the Trouble Shooting guide
-If the problem persists, delete the directory (may require machine reboot, as in my case)
-Restart JConsole/JVisualVM
Hopefully, the problem would be resolved.
Thanks and Regards
I am trying to start Tomcat from Eclipse, but a problem occured:
Port 8080 required by Tomcat v6.0 Server at localhost is 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).
I tried to list processes connected to this port using command on Windows:
netstat -aon
But on the listing there is no process with PID = 8080. I also tried:
netstat -aon | find "8080"
But it also didn't find anything. Can anyone help me?
PID is the process ID - not the port number. You need to look for an entry with ":8080" at the end of the address/port part (the second column). Then you can look at the PID and use Task Manager to work out which process is involved... or run netstat -abn which will show the process names (but must be run under an administrator account).
Having said that, I would expect the find "8080" to find it...
Another thing to do is just visit http://localhost:8080 - on that port, chances are it's a web server of some description.
Open eclipse go to Servers panel, right click or press F3 to open Overview window and go to Ports (Modify the server ports). You will get the following:
tomcat adminport
HTTP/1.1
AJP/1.3
You can change the port numbers (e.g. HTTP/1.1 port number 8080 to 8082).
In windows " wmic process where processid="pid of the process running" get commandline " worked for me. The
culprit was wrapper.exe process of webhuddle jboss soft.
If no other process is using the port 8080, Eventhough eclipse shows the port 8080 is used while starting the server in eclipse, first you have to stop the server by hitting the stop button in "Configure Tomcat"(which you can find in your start menu under tomcat folder), then try to start the server in eclipse then it will be started.
If any other process is using the port 8080 and as well as you no need to disturb it. then you can change the port.
In my case, there was a conflict with the virtualization function of Windows 10. This problem occurred after installing Hyper-V, virtual machine platform, and hypervisor platform to use hyper-v, docker, and bluestack together.
Even if I check with netstat, it is not a port in use, and even if I restart Windows and change the port, it does not start up saying that it is in use for all ports.
So, by changing the following services to Disabled in Windows Services, the Tomcat problem was solved, but bluestack, docker, etc. execution became impossible.
After starting Tomcat, when I manually changed the services again, bluestack was executed.
Hyper-V Host Compute Service
HV Host Service
Host network service
Network virtualization service
I need to debug a web application for Tomcat6 in IntelliJ IDEA.
When I try to run my web application, I get two errors:
Address localhost:1099 is already in use
Unable to open debugger port: java.net.SocketException
Launching the Apache Tomcat 6 service manually works fine.
What should I do in order to be able to debug web applications in Apache Tomcat 6 from Intellij IDEA?
Following the below steps work:-
Open command prompt and type the command netstat -ano
You will see a list of active TCP connections with PID as the last column
See the second column listing the local addresses and find the one using port 1099 from it and you'll get its PID
Now open your Task Manager, click the Process tab and get the PID column to display [either by right clicking on the heading row and selecting PID OR click View, and then click Select Columns and select PID.]
Now find the PID we got from Step3 and end the process.
Now you are good to go :)
I face this issue all the time. Here's how to fix it
LINUX
Open a terminal instance.
fuser 1099/tcp
This should return you a process ID.
1099/tcp: 31596
where 31596 is the process ID. Now you can either use the process ID to kill it or just bash the following -
fuser -k 1099/tcp
WINDOWS
Open a command prompt instance.
netstat -aon | find "1099"
This will return you an instance of the process.
output:
TCP 0.0.0.0:1099 0.0.0.0:0 LISTENING 15776
Here 15776 is the process ID. To kill this, enter -
taskkill /F /PID 15776
Cheers!
You can change the JMX port (1099 per default) in the Run/Debug Configuration dialog. Just try a different port number (i.e. 9099).
If you had the web application up and running before, there may be an old debug server that did not close down properly running in the background. See this post about how to find what process that uses port 1099. If it proves to be a java process, kill it.
How can you find out which process is listening on a port on Windows?
(If you use the GUI sw suggested in the link above, you may kill the process(es) by marking all java processes that uses port 1099, right click and press "End Process...")
As said before, there's an old debug server running in the background.
My solution was to close the Java process that was left open from the Windows Task Manager.
Please verify that you can close this process before doing so!
Change your http port to 8080(default for tomcat) and debug port to something that is not being used currently by any processes. You can use anything that is upwards of 1024, but since you are getting an error on 1099, try something that is greater that 6000.
Debugger setting can be found here
There might be other program or server running at the background. First close other server running in the background and then restart your server.
I found this answer helpful:
How can you find out which process is listening on a port on Windows?
I opened the resource monitor and looked for what was using the ports. Then opened task manager and ended those processes
What worked for me was. I assumed I would need to have the "Apache Tomcat" service running under "Services" [Windows + R >> services.msc]
I went and stopped the Tomcat service here. Then I came to my Java application and ran it in Intellij, which allowed me to run it.
Hope this helps!
Just close all other unnecessary servers while using InteliJ.
I stopped my WAMP in order to remove this error "Port is already in use".
When I fire up Jetty, it gives me the standard URL: http://127.0.0.1:8888/index.jsp?gwt.codesvr=127.0.0.1:9997
Great. I can see this URL from my machine. However, I cannot access this URL from other machine, and replacing the 127.0.0.1 with my actual IP address does not work either.
Does anyone know how I can make my server "sharable" so that other people in my network can hit off my machine as well?
Try to start the server with -bindAddress option using your external IP. See this.
Just follow the following Steps,
Right Click on Project
Go to run as ---- > Run Configurations
Select Arguments and add -bindAddress 0.0.0.0 to Program Arguments
Click On Apply & Run
Now resolved - see end of question.
I am attempting to debug a Java process with IntelliJ Community Edition's debugger. The socket is listening - but when I try to connect the debug process shows the following
'Connecting to the target VM, address: ':8003', transport: 'socket'
It never makes the connection to the VM and I cannot debug.
I have moved to a Windows 7 64 bit PC - on my old XP machine and could connect and debug this Java process (it's an app I build and maintain).
It does not fail with the standard "Connection refused: Connect" error that you would get if no process was there to connect to. Netstat also shows the port is listening when the app is running.
TCP 0.0.0.0:8003 :0 LISTENING
Debug args for the app
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8003
-Xdebug
If I attempt to run the debug session from IntelliJ on a remote machine, I can connect to the process running on my local machine, and debug.
If I run the Java app on a remote machine, and use IntelliJ on my local machine, I can debug.
It is only if I run and debug on the same machine that it fails - unfortunately this is what I need to do almost all the time.
The only similar issues I have found are from 2004, to do with file paths with spaces, and were NetBeans, not IntelliJ. I have rebuilt and rerun my app ensuring no spaces or underscores in the path, no joy.
My intelliJ debug settings are to debug my local machine on socket, attach mode port 8003 - sorry as a new user I can't attach an image.
Other things I have attempted:
Changing JRE versions
Debugging using shared memory rather than socket transport
I have not re-installed IntelliJ - I am using the same build as my fellow devs (10.5 IC 107-105) who don't have this problem.
Changing the port the debugging process listens on (from 8003 to various other, unused according to netstat)
I have tried using PC name, IP Address and 'localhost' to refer to the PC in the debug settings.
Stuck. Any help much appreciated.
Thanks
Steve
Resolved
Well, a day of failing to solve then I find the answer 20 mins after posting. An invalid JNI signature character, only picked up when debugging. Solved by adding this arg when debugging.
-Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6547438
Thanks for the assistance. Still don't know why it would work when debugging remotely but not locally before.
It sounds like a strange firewall issue.
It appears that you should be able to try telnet localhost 8003 and it should fail. This means nothing can connect to your app on that port.
EDIT: If shared memory does work either and you cannot connecft it via telnet, there is a problem with the way you are running the app.
You will get this type of error if the application is not running.
Can you try debugging a simple program you lauch from IntelliJ?