JPDA doesn't seem to work in IDEA deployed with JBoss - java

I have a Java project which is deployed on remote JBoss server that I'm trying to debug using JPDA in IDEA.
The following was added to JBoss config to turn this feature on:
"JAVA_OPTS=$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n"
I created a new debug configuration in IDEA for the server and it seems that the port is opened and I'm able to connect:
Connected to the target VM, address: 'here's goes the IP:8787', transport: 'socket'
However, when I add breakpoints in the app it doesn't seem to stop executing the code.
There's a REST controller which is I'm absolutely sure should trigger the breakpoint when request is sent to the server. But for some reason that's not the case.
Here's what I've tried so far:
Invalidate Caches/Reset IDEA
Make request to server via Postman instead of browser
But with no luck.
The code on the server should match with my local project.
I'm pretty convinced that the problem has to be on my side.
I've only debugged applications deployed with Tomcat, maybe there's something specific about JBoss?
Might be related to IntelliJ IDEA: Breakpoint not being hit, and is shown without the tick, just a red dot since there's no ticks and also gradle is used.
In addition, I remember when I debugged a tomcat + maven project with JPDA and added breakpoint, IDEA would evaluate and calculate something for a considerable amount of time but in the current project there's no sign of it.

Related

How to debug dynamic web page in Eclipse?

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.

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 )

Getting a project started in JBoss within Eclipse

I've inherited a project which i'd like to test in JBoss - the problem is I cant get it to start within Eclipse. It works outside of Eclipse but I have to do a maven build, deploy the WAR files to JBoss and restart JBoss each time I make a change which is a nightmare.
In Eclipse I have added a JBoss 6 server, started it which appears to be fine (i.e. no errors in the console), then I try to run the 2 applications (one server then one client) - however nothing gets printed to the console log - no error or anything. It says started pretty much straight away. Just get a 404 error when going to the localhost:8080/name address.
I understand this may be difficult for someone to assist me here as there is no error message but if anyone has any suggestions or advice it would be much appreciated. I would have thought this should be simple but dont know what im doing wrong...
Eclipse may be running the JBoss server so it listens to a different port. Either that or the 8080 port is already bound so Eclipse can't open it.
Try configuring the JBoss project in Eclipse so it listens at a different port.
[Edit]
Here is a thread on jboss.org that discusses changing the port used by JBoss when running in Eclipse.

How do I debug Java servlet filters, on-the-fly, from a remote machine (I'm using Eclipse and Apache Tomcat 5.5)

I wrote a Java servlet filter on my local machine and deployed it a remote (machine) web server. Unfortunately, it's been very difficult and time-consuming trying to trace errors reported by Apache Tomcat 5.5, my JSP/servlet engine. I can't keep writing System.out.println(...), saving, deploying, testing JSP pages, and so on. It's taking too long. There has to be a better, faster way.
Is it possible to remotely debug servlet filters? I don't have a web server on my local machine, which is why I'm asking about remote debugging. Specifically, I'm looking for a way to debug, line-by-line, the servlet filter, on-the-fly, as it's happening on the remote web server. Does such a method exist?
Or, is there a better method than writing to standard output. It's taking too long and I feel that must be a more efficient means of debugging Java servlet filters.
Note: I'm using Eclipse for development.
Thank you very much for any help.
Update
Thank you all for your help. I really appreciate it.
I added the JVM argument to Tomcat, restarted Tomcat. Then, on the machine with Eclipse, I entered in the appropriate info in the Debug config, put the breakpoint in, and tested. Unfortunately, it did not work. In the config, I left it as Socket Attach, clicked apply, and that was it. I pressed the debug button and it said the connection was refused. I tried ports 8000 and 8001 and both did not work.
Let me explain what I'm trying to do, that might be better.
I have a login page called login.jsp. On that page, is a form whose action attribute is servlet/LoginServlet. When the user submits the form, it calls servlet/LoginServlet, which is mapped to a class in the web.xml file. Let's call this class com.mysite.mypkg.classA. In class A, it calls a method from another class called com.custom.mypkg.classB. I want to put a breakpoint in classB.
So, using the url with login.jsp page in the Eclipse debugger won't call it. I tried using servlet/LoginServlet and that also did not work.
What should I put in for the URL? Or, do I debug this type of setup?
Thank you.
Update 2
I found this site here, which is pretty comprehensive. I ran netstat -a and noticed that the debug port is not listed. Windows Firewall is turned off, but there could be another thing blocking the port, who knows. Anyway, I placed the VM argument here and it's not working.
Thank you.
For remote debugging you need to start the server in debug mode. There are couple of ways doing that.
1 > start the server using
catinlina.bat jpda start
2 > Add an jvm argument to the tomcat java process
-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
Once the server is started in debug mode , you need to change the perspective of the project in eclipse to debug.
Then go to Run - > Debug configuration.
Double click remote java application and enter the details such as
Remote IP address
Debug port . Default tomcat debug port is 8000. If you use jvm argument, use the port mentioned in the jvm argument.
Click Apply
Go to the java file you want to debug.
Put a break point in the source code and run the scenario you want to test (Eg Web application using browser)
Also , ensure that the code in the java file is in sync with code deployed on remote server.
Happy Debugging!!!
Peace.
Sanket Raut
You can attach a debugger to a running Tomcat instance, provided that you gave it the right command line options when you launched it.
The Tomcat Development Wiki explains how to do this, and as a bonus gives you instructions on how to set up to debug from the Eclipse or NetBeans IDEs.
Of course, attaching a debugger to a running Tomcat has both security and performance implications*.
* And OH&S issues - you might get badly scratched if you tried this on the wrong kind of tomcat ...
You should run your remote tomcat with the following starup parameter:
bin/catalina.bat jpda start
Then in Eclipse on your local machine go to Run -> Debug Configurations -> Remote Java Application, create new configuration here, use IP of the remote machine as a host and 8000 as a port there
Run this configuration and use the breakpoints in Eclipse for debugging

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