The problem:
Debugging a java web application deployed in Tomcat 7 is not working. Eclipse seems to connect to Tomcat but breakpoints are ignored when I try to debug. I did the following:
First of all I have also tried: Remote debugging Tomcat with Eclipse.
started Tomcat7 in debug mode with :
set JPDA_OPTS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
catalina.bat jpda start
Debug as - > Remote Java Application with host : localhost and port : 8000.
Created a few breakpoints on a servlet where the request should suspend and let me debug but it's like there is no breakpoint set.
Thank you all,
Daniel
P.S. This is my first question so please be kind .
One possible explanation is that the class files in your WAR file (deployed on Tomcat) do not contain line numbers.
If you told us with which compiler and compiler plugin (Oracle javac, Eclipse, ANT, Maven, etc.) the class files were produced and what settings were used we may be able to provide further details.
Update
Author says in comment that ANT is used to compile. Follow-up:
The ANT javac task is just a wrapper around a concrete compiler. So, the options you can set depend on the actual javac. However, what you're looking for is debug="true" debuglevel="lines". ANT will then pass -g:lines to javac (see docs).
Sidenote: optimize="true" is ignored (check the docs).
Related
I configure launch.json to launch Java debugger and working successfully. After a short while, I see error ERROR: transport error 202: recv error: Connection reset by peer. I did google it, and it was suggested to change the debug argument from:
-agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=localhost:52252
to:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:52252
The debug arguments above are auto generated by vscode. How I can change it? I didn't find a way to configure such argument. The only option is to configure a task to run the command, and configure a debug option to run the task to launch the debugger and attached to that debugger session.
I am checking if there is a way to change the part to server=y as it is much easier.
Stack Overflow seems to have these answers. I never tested them myself though.
How to set java vmargs in vscode at workspace level
vsCode java.test.config vmArgs not working
Thanks to your mention, there is an article with a lot of details to configure a launch request with a preLaunchTask task configuration at https://github.com/microsoft/vscode-java-debug/blob/388c842bcc854a9e2f7f1e8fc5aa9520cb7fecf6/Configuration.md#attach-to-a-debuggee
If it helps, one of the SO questions, and a comment here, has a link to the VSCode configuration reference, https://code.visualstudio.com/docs/java/java-debugging#_attach . There you can see the attach request options.
My understanding of the attach vs launch is that
launch runs your App, and then automatically attaches a debugger to it.
attach is used only in cases where you have an already running JVM, lets say on some remote server, and you want to debug it.
How are you running starting your JVM? My guess would be that if you are starting the JVM from terminal, then put the server=y option there. If you want the VSCode to run the JVM, which I assume is the case, then the launch request is what you want.
I have a tomcat running after making configuration and when I type jdb in terminal it says initializing. So I like to know
How to attach jdb with tomcat and specify servlet name.
What is the compile option (like in C its eg. -g with gdb) to include debugging symbols when compiling servlet with javac
I have opt/tomcat/apache-tomcat-10.0.10 so I guess Tomcat version is 10
The javac command switch to add all debugging symbols is ... -g. Line numbers and source file names are actually added by default, you only gain information on local variables (see this question).
You can not connect a debugger to a running JVM, unless it was started with the appropriate command line option (see this question).
Tomcat has a helper script bin/catalina.sh that can help you start it with the correct parameters:
catalina.sh jpda start starts Tomcat in the background with debugging enabled. You can connect to it with:
jdb -attach localhost:8000
catalina.sh jpda run works as in the previous case, but in the foreground,
catalina.sh debug starts Tomcat through jdb. You just need to use run to start it.
Once you are connected you can use:
stop in <class id>.<method>
to add break points.
Remark: Both javac and jdb are not often used these days. Most people use tools like Ant, Maven, Gradle, etc. to compile their projects and IDEs to debug the code.
I have a Java app that I'm attempting to debug inside of (because a particular error only happens when the app is run from inside Docker, which is fun), but I can't figure out how to get IntelliJ to attach for debugging.
I have the Docker Integration plugin installed, but when I go to run my container, the deploy log has a line that says Cannot retrieve debug connection: Debug port not specified. Google told me that I needed to add a debugPort entry to my workspace.xml file, but when I did that, my Run/Debug configuration complained that "Debug port forwarding not found". Clicking "Fix" resulted in a container_settings.json file being created, which IntelliJ immediately informed me wasn't supported in 2017.3+, and that i should use command line options instead. However, I have no idea what those command line options should be.
When I tried specifying the forwarding port in the Run/Debug configuration, the deploy log ended with Cannot retrieve debug connection: java.net.MalformedURLException: unknown protocol: unix, which makes no freaking sense.
Help!
You can even use dcevm / HotswapAgent in dockerized application and modify code/resorces without restart. Look at this project https://github.com/HotswapProjects/hotswap-docklands
I am running Ubuntu 16.04 and I need to install and run Restcomm JSS7 stack as a JBoss AS Service.
I followed this video tutorial to install JBoss AS 7. Then I set the JBOSS_HOME environment variable to installation directory of JBoss AS 7. As a result, I was able to start the JBoss AS successfully by executing ./run.sh in the bin sub-folder of the installation directory.
Then I followed this guide to install Restcomm JSS7 stack. For that, I downloaded restcomm-jss7-7.4.1404.zip, unzipped it to /opt/ and then navigated to the ss7-jboss sub-directory and then executed ant deploy,
and the result was
...
BUILD SUCCESSFUL
which according to the guide is an indication of the service deployed successfully.
Then I am following CHAPTER 4 SECTION 4.1 of this user manual to run it as a JBoss AS Service. According to it,
All you have to do to start the Service is start the JBoss AS. This
will automatically start the SS7 Service. To start the JBoss Server
you must execute the run.sh (Unix) or run.bat (Microsoft Windows)
startup script in the /bin folder (on Unix or
Windows).
TWO PROBLEMS:
My <jboss_install_directory>/bin does NOT have a run.sh script. Because of this reason, I tried by running JBoss AS by using the regular standalone.sh script.
Next in the user manual, it is stated:
Result: If the service started properly you should see following lines
in the Unix terminal or Command Prompt depending on your environment:
(Note: I have pasted the following excerpt from user manual here, since it is too long to paste in this question.)
But I see none of those lines in my terminal. Rather, my terminal output of running ./standalone.sh is pasted here.
So I don't know how and where to proceed from here. Please help.
NOTE: This question is NOT a duplicate of my other question. Like I mentioned in the question titles, this question is about why my JBoss AS installation doesn't contain a run.sh script, and what would be its alternative. The other question is about some possible command to find out the JBoss Services started when it is running? When a beginner is starting to learn something, their entire purpose Not getting the job done. They have many confusions/questions in their mind.
The documentation documents how to start a JBoss 5.1 server but your installation uses a JBoss 7.1 server, which is why you have to use standalone.sh instead of run.sh to start the server and why the logs are different.
Since you correctly reach the JBoss AS 7.1.0.Final "Thunder" started in 3955ms line I wouldn't worry too much (except about using a documentation that is clearly outdated).
The documentation of your product only declares compatibility with JBoss 5.1.0. While it may work on later releases, you might want to check if there's a more recent version of your product. I wouldn't recommend installing JBoss AS 5.1.0 as it isn't supported anymore and will contain security breaches.
Im trying to enable remote debugging for an eclipse plugin project, for the purpose of using IntelliJ IDEA as a debugger.
The steps I've taken so far:
Launch Eclipse.
Run -> Debug Configurations...
Create a new "Eclipse Application" (as to launch a local workspace which loads the plugin).
Add -Xdebug -Xrunjdwp:transport=dt_socket,address=1044,server=y,suspend=n to VM arguments.
Press the Debug button.
I get the following error:
ERROR: Cannot load this JVM TI agent twice, check your java command line for duplicate jdwp options.
Error occurred during initialization of VM
agent library failed to init: jdwp
What steps should I be taking to get IntelliJ IDEA to be able to debug an Eclipse Plugin running in a runtime workspace?
Run -> Debug Configurations...
Add -Xdebug -Xrunjdwp:transport= dt_socket,address=1044,server=y,suspend=n to VM arguments.
This is redundant. Using a debug configuration already starts the application with the eclipse debugger attached to the process. Start it as a run configuration instead if you want to enable debugging through a server socket.
You can then create an additional "remote java application" debug configuration to attach to that socket.
I would suggest you NOT try to launch the Eclipse app from within Eclipse.
Export the app to be a stand alone eclipse application.
Modify the eclipse.ini file and add the necessary debug parameters to the '-vmargs' entry.
Launch the stand alone app as you normally would.
Attach the development Eclipse instance to the test app as you would normally do for a remote debug.
Tomcat Configuration:->
By default remote debug happens at 8000 port.If you want to change this then go to catalina.bat file and update this line
set JPDA_ADDRESS=localhost:8000 to desired port no.
And you can also set this property in setenv.bat file. Generally this file is not there in tomcat so just create one batch file with name
setenv and write this line set JPDA_ADDRESS=localhost:8000.
Now go to bin directory then open command promt and write "catalina jpda start". It will make the tomcat run in debug mode. You can verify it
by seeing something like this "Listening for transport dt_socket at address: 8000"
1)Eclipse
Go to run->debug configuration->Remote Java Application->Click on new Launch configuration
And then fill the detials like project ,port(Give same port no as you have configured in tomcat), host(If you are using local you can give
local then apply and debug
I am using eclipse 2020.09 .
Eclipse remote debug img
2)Intellij Idea:
Go to Add configuration->click on +->and select remote jvm debug->Then give the same port no and name(any name) then apply.
Intellij Idea Remote Debug img