How to debug dynamic web page in Eclipse? - java

I am trying to debug my dynamic web application in Eclipse (Helios) as Debug mode but it could not work out. I have googled eventually i confirmed that i have to do Remote Debug. I trying to do Remote Debug. It seems doesn't work. Could please any one help me out to how to do set up Remote Debug and please mention steps to setup.

What app. server (web container) are you using ? I.e. tomcat , Add that server to your eclipse using "add server" and add project to it then run server in debug mode.

Sometimes its an issue with port.The port which you are trying to access is already occupied and wouldn't be released and you get this exception.Try restarting your system,in my case it worked.See the below post for more troubleshooting.
See Also
Eclipse : Failed to connect to remote VM. Connection refused.

Related

IntelliJ throwing Java.Net.SocketException: unable to open debugger, "socket closed"

I have seen several topics on this problem, but all of them are either for Android Studio or Glassfish.
Problem:
I'm sending a POST Request from Postman to a web app hosted in WebSphere. I set a breakpoint in the web service code in IntelliJ, but when I fire up the debugger, I get this error:
Error running 'WebSphere Traditional 8.5.5.0': Unable to open debugger port
(127.x.x.x:xxxxx): java.net.SocketException "socket closed"
WebSphere Debug Configuration in IntelliJ:
Things I've tried:
read this SO post and discovered the WebSphere debug configuration
restart the app server
restart the web service
restart IntelliJ
restart my PC
read several Android Studio posts on the same subject
read the JavaDoc on Java.net.SocketException
blasphemed
Questions:
If the issue is simply that I need to change the debug port, how can I determine what to change it to?
If necessary, where in the WebSphere Application Server admin console would I navigate to if I wanted to check the sockets? I'm very new to WebSphere AS and the documentation is a bit scattered.
The problem was human error.
Because of my poor understanding of WebSphere, I was starting the server manually, and then starting the web service in IntelliJ.
IntelliJ was trying to launch the server for me, but when it saw that the server was already running, it threw an error stating that the socket was closed.
The solution was simply to let IntelliJ to launch the server as part of the Run process.

The Eclipse plugin cannot communicate with the GlassFish server

I need use Glassfish in a project we're currently working on in Eclipse IDE.
My problem is after installing Glassfish Tools in Eclipse I manage to correctly create a new glassfish server en SERVERS tab but when I try to start it the following error message pop up:
The Eclipse plugin cannot communicate with the GlassFish server....
The Eclipse plugin cannot communicate with the GlassFish server. A
GlassFish Enterprise Server may be running on the same admin or HTTP
port, but with a different root installation.Please also check for
antivirus software, firewall configuration, or VPN setup which might
block some ports.
Actually the problem looks more complex since not only I'm not able to start server but I cannot execute any action on server. Neither deploying, nor clean or whaterever else do work resulting in popping up the above message.
In the internet developers communities I only find clues about CREDENTIAL ERROR but this is not the case.
Looking in the Glassfish log folder there is no trace of any access attempt.
Everythings points at Eclipse plug-in neither be able to communicate with glassfish by any circumstance.
This issue occours either with Glassfish 3.1 (using jdk1.7) and 4.1 (using jdk1.8) and in Eclipse Luna and Mars.
I already tried to create, delete and manage glassfish domains (as suggested in other questions here at StackOverflow) to get over potential "credential-related" issues but no result.
Tried to uninstall and reinstall Glassfish Tools from Eclipse too but still no way.
Both Glasshfish 3.1 an 4.1 start flawlessly manually and NetBeans manage to start them without any problem but, as said, I need to work with eclipse so switching to NetBeans is not the solution (and, please, don't suggest me a manual deploy and server start).
As a last attempt, since I work in Windows, in a console window I tried this:
netstat -a -b
to verify no other service is "taking" port 8080 (although it doesn't seem to be a port problem but a "plug-in communication" one) but it resulted free.
I'm into this mess by days.
Please help.
Thank you
I had exactly the same problem. When I set "preserve sessions across redeployment" in the Eclipse properties dialog for GlassFish, tab "GlassFish", to false (true being the default), everything worked out fine.
I just set the proxy configuration in Eclipse menu Window -> Preferences -> General -> Network Connections (changing the Active Provider value from "Native" to "Manual" and inserting all the needed values for HTTP and HTTPS rows) and added "localhost" and "127.0.0.1" to the section "Proxy bypass".
I have faced the same problem. Generally, the programs that get dynamicly port numbers causes this. Etc: skype, teamviewer.
For me, I solved the problem with starting eclipse before them.
Maybe this works for you too.
I had the same problem, and I solved it by removing the glassfish server from Eclipse, and adding it again.
What I noticed in my own case was that other applications where using port number 4848, so I had to stop all use of port 4848 and restart the domain again ( restart glassfish server )

Debugging an already deployed JAX-WS service in Eclipse

There is a Webservice written in Java (using jax-ws api's), already deployed on server. Suddenly, it has started giving wierd results, for some HTTP requests, that I could not reproduce on my local-box. Is it possible that I fire the HTTP request on the same server, and start debugging the code on eclipse installed on my local box.
Please help me with the steps for the same.
Thanks
On what application server are deployed your web service ?
You need to enable remote debug on your Tomcat, JBoss, Websphere, whatever application server, and just need to create a remote debug task in eclipse to connect on the right ip/port.
This is all you have to do.
To activate remote debugging for your application server, just add the following line to the JAVA_OPTS: -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
For eclipse you can follow this link

Remote debugging Java web app running in Glassfish

I have a web application. It is currently deployed on a remote server in a Glassfish instance. Is it possible to remotely connect to the server and debug the application (like I would a normal java application) using Netbeans?
If someone has done this and could provide insight or could point me to a guide, that would be great.
I know this functionality exists with Visual Studio and ASP.Net. I was not sure if there is a java equivalent.
Most examples that I have seen online are for applications that are simply running on a remote machine or for debugging a Glassfish application running on the local machine.
Yes, it is possible.
Once you have GlassFish running in debug mode, go to the Debug menu in NetBeans and click on Attach Debugger..., which brings up the Attach dialog. You'll probably go with something like:
Debugger: Java Debugger (JPDA)
Connector: SocketAttach
Transport: dt_socket
Host: hostname_or_ip_address
Port: 9009
Timeout may be left blank. When you click OK on this dialog, you should be able to connect your NetBeans debugger to GlassFish.
Remember:
The firewall on your remote server (and any gateways in between) should allow connections to the debugger port (9009 in my example).
Make sure you're using matching port numbers. In the GlassFish admin console, usually at: http://localhost:4848
Expand Configurations.
Expand server-config (or whichever you are using).
Click JVM Settings.
Check Debug to Enabled.
Verify that Debug Options contains:
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9009
Read the JPDA docs for other options you can use.

Can't debug servlet Eclipse + Glassfish

The server is in debugging mode. I've set 10 breakpoints and the browser just skips them all. Why? This happens with JSPs also in that project. Why?
Have you checked that the Debbuger is indeed connected with Glassfish? Also please note that it is not possible for the debugger to stop at breakpoints which have been set inside jsp. AFAIK, debugger works only pure java code
So you are connecting to external server with "debug remote java application".
What is your server's debug port? Port 8000 is default setting in eclipse debug configuration for remote java appilcation. You should change that value to one that GlassFish server is configured for debugging.
Also, take a look at How do I debug GlassFish 3 using Eclipse Helios?

Categories