I am trying to remote debug my application. This is what i have done till now.
1 - environment variable set - JPDA_TRANSPORT=dt_socket
2 - environment variable set - JPDA_ADDRESS=4000
3 - In startup.bat file, the following line
call "%EXECUTABLE%" start %CMD_LINE_ARGS%
is replaced with
call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%
4 - in the setenv.bat file, the following line has been added
set "CATALINA_OPTS=%CATALINA_OPTS% -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=4000, suspend=n"
In Eclipse, In debug configuration window, I set the port to 4000, pointed the source. Restarted the eclipse.
Behavior
When is start the Tomcat, the Only following line is printed on the server console, nothing else.
*Listening for transport dt_socket at address: 4000*
When i go into Eclipse, do in debug configuration and press debug , the tomcat(server) window disappears. I have no logs and no clue what is happening.
Note
I am using windows 8.1 , Eclipse Luna, Java 7
Any help will be highly appreciated.
Add this line in catalina.bat
set JPDA_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9876
in the end of startup.bat make sure jpda is present startup.bat file
call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%
Related
I have created Local Tomcat (8.5.15) run configuration in IntelliJ IDEA (2019.2). I am running Windows 10. When I try to run the configuration, I get error:
Error running 'Local Tomcat': Cannot run program "C:\apache-tomcat-8.5.15\bin\catalina.bat" (in directory "C:\apache-tomcat-8.5.15\bin"): CreateProcess error=2, The system cannot find the file specified
Environment variables are set:
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_221
CATALINA_HOME=C:\apache-tomcat-8.5.15
%JAVA_HOME%\bin and %CATALINA_HOME%\bin added to PATH
In Run/Debug Configurations -> Startup/Connection, Startup script and Shutdown script are set to valid paths:
C:\apache-tomcat-8.5.15\bin\catalina.bat run
C:\apache-tomcat-8.5.15\bin\catalina.bat stop
When run from terminal, Tomcat starts correctly.
I have replaced catalina.bat with some mock script (just echo sth) as Startup script in run configuration, got the same error.
No other logs are visible in IntelliJ.
Changing system environment variable ComSpec does the job.
In my case I had two cmd.exe configured 32 bit and 64.
I removed 32 bit and it started working. Look out as after edit - there might be ; that also need to be removed.
Tomcat is not starting in debug mode. Getting below logs.
C:\ApacheSoft\apache-tomcat-7.0.67\bin>catalina.bat jpda start
Using CATALINA_BASE: "C:\ApacheSoft\apache-tomcat-7.0.67"
Using CATALINA_HOME: "C:\ApacheSoft\apache-tomcat-7.0.67"
Using CATALINA_TMPDIR: "C:\ApacheSoft\apache-tomcat-7.0.67\temp"
Using JRE_HOME: "C:\Program Files\Java\jdk1.7.0_79"
Using CLASSPATH: "C:\ApacheSoft\apache-tomcat-7.0.67\bin\bootstrap.jar;C:\ApacheSoft\apache-tomcat-7.0.67\bin\tomcat-juli.jar"
=transport=dt_socket was unexpected at this time.
Let me guess, you read a link called "HOW TO REMOTELY DEBUG APPLICATION RUNNING ON TOMCAT FROM WITHIN INTELLIJ IDEA" on blog.trifork.com.
The instructions say to do this for Windows in your setenv.bat:
set JPDA_OPTS="-agentlib:jdwp=transport=dt_socket, address=1043, server=y, suspend=n"
Yeah, that's not going to work. catalina.bat adds its own quotes, so it winds up trying to do this:
if not ""-agentlib:jdwp=transport=dt_socket, address=1043, server=y, suspend=n"" == "" goto gotJpdaOpts
A better plan is to do this:
set JPDA_OPTS=-agentlib:jdwp=transport=dt_socket,address=1043,server=y,suspend=n
I know this is from almost a year ago, but I ran into this, and ultimately had to remove "#echo off" from the Tomcat batch files and chase this down myself. Hopefully, this will get voted up so that it can save someone else this grief.
There is another possibility that you configure both two different ways to enable JPDA in jvm during starting tomcat in remote debug mode.
In windows, there're several ways to enable JPDA in jvm.
1.one way is :
open the startup.bat.
add the lines below
set JPDA_ADDRESS=8001
set JPDA_TRANSPORT=dt_socket
call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%
2.the second way is:
create a setenv.bat file under CATALINA_HOME/bin directory.
and add the line below:
set JPDA_OPTS=-agentlib:jdwp=transport=dt_socket, address=1043, server=y, suspend=n
of course, they're other ways.
I have the same problem with you, but then I found I configured in these ways both, it will result in the failure to open the JPDA port, without any error details.
Then I chose the method 1 only, the port was opened successfully.
Hope this can help other newbies on this.
The space char in C:\Program Files\Java\jdk1.7.0_79 cause the problem.
Replace it with short name could solve the problem.
Execute command dir c:\PROGRA~1\Java\jdk1.7.0_79 and check the file list to verify whether PROGRA~1 is correct. If not, try PROGRA~2 and so on...
Then change environment variable JAVA_HOME or JRE_HOME to try again.
When running Groovy Grails Tool Suite (GGTS) version 3.6.4 (latest as of June 2015), on Windows 7 Home 64bit, I get a "Error occurred during initialization of VM Too small initial heap for new size specified". I have a JAVA_OPTS System Environment variable of "-Xms512m -Xmx512m" I also have that same value inside the GGTS Menu: Run => Debug Configurations... Arguments Tab, VM arguments. This error does not happen when I do a run-app inside GGTS, and the app successfully starts. But, when I do try to run using Debug, with the run-app Debug Configuration, I do get this error. Where else could I possibly set the heap values to make this work in Debug? Any ideas of what else to test, fix, or set to fix this issue?
Could not get GGTS to launch my app, no matter what changes I made to -Xms and -Xmx everywhere I could find to make the change. Kept getting the same error. Finally, I stumbled upon this method of setting up the debug. Step 1, start the app from the console (not within GGTS):
grails -debug run-app
Step 2, in GGTS follow these directions to hook-up to the "grails -debug run-app" you just started (use port 5005 - as displayed in the console window), and when done, click the Debug button at the bottom: Create a Remote Java Application launch
Now, debug launches and I can set and view breakpoints inside GGTS.
I have an application that I deployed in tomcat. Later I configured the code as a project in Eclipse. I want to connect to the tomcat via eclipse and debug the application.
Trying to setup a remote debug connection is throwing up errors. Is there any entry that I need to add somewhere in tomcat?
First, you need to run Tomcat in debugging mode. The easiest way to do that is to modify the startup file (.bat or .sh depending if you are Windows or not). Find the line near or at the end of the file that contains the start command, and change it to jpda start. This will cause Tomcat to start in debugging mode listening on port 8000.
Next, to connect to this process via Eclipse, select the Run menu and choose Debug Configurations.... In the pane on the left, choose Remote Java Application and click the New launch configuration button above the list. The important settings to note are the Host and Port fields. The host value must match the hostname of the Tomcat process, and the port should be 8000. You also might need to add entries on the Source tab to ensure that all of the source code is available to step through.
Create a new tomcat server
Create a new dynamic web project
Export war to tomcat server
Tomcat debug configuration(important), first double click tomcat server, then select "Use Tomcat installation (takes control of Tomcat installation)"
Add breakpoints
Run tomcat in debug mode
Test war in web browser
Edit source path
Debug source code in Tomcat
The war file is available here.
yes, you need to configure tomcat to accept remote debugging connections. There is a FAQ on how to do it with various IDEs.
http://wiki.apache.org/tomcat/FAQ/Developing#Q2
Simply change the line in startup.bat (if you are using Windows)
from:
call "%EXECUTABLE%" start %CMD_LINE_ARGS%
to:
call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%
Right Click on the project you want to debug and go to Debug As Menu and in the list click on Debug Configurations.
Then Double click on the Remote Java Application from left menu list. browse for the project u wanna add in then click apply.
Also change the listening port to 7999, then after you started the web app from your localhost click the debug button on the same window. Then any break point's will be hit after that.
Steps to setup the tomcat Debugger with eclipse
Install the following things:
java 1.8+
eclipse EE version
download tomcat 8+
open eclipse and go to servers tab and add a new server(window-> show View-> Others -> Search Servers)
Mark your project as Dynamic web Project(Rightclick on Project-> project facets -> select Dynamic web module)
Export war (File-> Export-> search war -> select module and choose the path)
Run as -> Run on Server
Start the tomcat Server in Debug or Run Mode
check on localhost:8080
Debug worked for me. I was using tomcat 8, configured on centos 7. Debug port opened for me after changing 2 settings.
Open tomcat/conf/bin/startup.sh and added below lines
export JPDA_ADDRESS=8000
export JPDA_TRANSPORT=dt_socket
In the same file startup.sh, added jpda before start command.
exec "$PRGDIR"/"$EXECUTABLE" jpda start "$#"
Restart the tomcat.
In eclipse go to Run>Debug configuration>Remote java application>Add host ip and port(8000) where tomcat is running.
In my case i required to open 8000 through firewall too.
firewall-cmd --zone=public --permanent --add-port=8000/tcp
firewall-cmd --reload
Beside remote debugging, you can debug your app locally within eclipse if you added tomcat in eclipse.
just start server and wright click your app and from debug menu hit debug on server.
If you have multi module maven project, debug on server just shown up for module with war packaging.
If you want debug a class that runs at startup by self, like methods that annotated with #PostConstruct, remember that you should increase server timeout.
To do that, go to server view and double click on tomcat and in server preview tab, increase the timeout value.
I would like to debug my separately running JSP/Struts/Tomcat/Hibernate application stack using the Eclipse IDE debugger. How do I setup the java JVM and eclipse so that I can set breakpoints, monitor variable values, and see the code that is currently executing?
I just Googled it. :)
http://bugs.sakaiproject.org/confluence/display/BOOT/Setting+Up+Tomcat+For+Remote+Debugging
Many more on google.
Effectively, set your JPDA settings:
set JPDA_ADDRESS=8000
set JPDA_TRANSPORT=dt_socket
bin/catalina.bat jpda start
Then, in Eclipse, Run->Debug Configurations...->Remote Applications.
Follow these steps:
Add the following arguments to the java command that is used to launch Tomcat (on Windows, I think this is in TOMCAT\bin\catalina.bat)
-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
In Eclipse, create a 'Remote Java Application' debug configuration and set the port to 8787 and the host to the name (or IP address) of the machine where Tomcat is running. If Tomcat is running on the same machine as Eclipse, use 'localhost'.
In the 'source' tab of the debug configuration, add any projects that you want to debug into
Start Tomcat
Launch the debug configuration you created in step 2
Eclipse should now stop at any breakpoints that you've set in the projects you added in step 3.
Notes:
You can change the port to any other available port if for some reason you can't use 8787
If you want Tomcat to wait for the remote debugger to start, use 'suspend=n' in the command above to 'suspend=y'
You could do what they suggest, or use this Eclipse plugin, which makes it easier to configure Tomcat to begin with: Eclipse Tomcat Plugin
When launching tomcat via this plugin, it starts in debug mode by default, you must explicitly disable debugging mode if you want it to not allow Eclipse to connect a remote debugger.
For Tomcat 5.5 on Windows:
Edit bin/startup.bat
Find the line that reads:
call "%EXECUTABLE%" start %CMD_LINE_ARGS%
Replace it with these lines:
set JPDA_ADDRESS=8000
set JPDA_TRANSPORT=dt_socket
call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%