Reputation: 2796
I am attempting to setup the JPDA for Tomcat7 in ubuntu.
I have used the apt-get method of installing Tomcat7.
By attempting to edit the /usr/share/tomcat7/startup.sh file with the following lines I try to get tomcat7 to boot into debug mode and allow remote debugging via eclipse.
JPDA_TRANSPORT="dt_socket"
JPDA_ADDRESS="8000"
exec "$PRGDIR"/"$EXECUTABLE" jpda start "$@"
After editing the startup.sh file, I reboot tomcat7 using:
sudo service tomcat7 restart
Then attempt to connect to the tomcat jpda in eclipse with the IP address and port 8000. I receive a "Connection Refused" error from Eclipse.
I have attempted to manually start tomcat7 using the startup.sh script rather than the service executable method as I thought perhaps the startup.sh was not being called.
sudo ./startup.sh
This failed with the following output:
Using CATALINA_BASE: /usr/share/tomcat7
Using CATALINA_HOME: /usr/share/tomcat7
Using CATALINA_TMPDIR: /usr/share/tomcat7/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar
touch: cannot touch `/usr/share/tomcat7/logs/catalina.out': No such file or directory
./catalina.sh: 389: ./catalina.sh: cannot create /usr/share/tomcat7/logs/catalina.out: Directory nonexistent
I have also attempted to alter the startup script at /etc/init.d/tomcat7 as I am using service to start/restart tomcat7 to no avail...
What am I doing wrong?
Upvotes: 14
Views: 13790
Reputation: 21
Settings required in Tomcat:
1)Create setenv.sh file under */tomcat/bin/. The location will be same as the catalina.sh file
2)Place the below content inside it.
export CATALINA_OPTS="-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n" Now start the Tomcat server. Once it is started please proceed with the below steps.
Settings required in Eclipse:
3)In Eclipse go to Windows-->Preference--> General-->Network Connection --> Active Provider should be Direct. After changing to direct restart the eclipse.
4)In eclipse right click on project and debug as ->debug configuration ->Remote java application ->Create new configuration.
Fill the below fields
Name: as your wish
Project: Select the project which you need to debug.
ConnectionType: Standard socket attach
Host: Localhost Port: 8000(It should be same as mentioned in point 2)
Then click debug.
The debug will start at port 8000. Now you can verify by keeping breakpoints.
Upvotes: 1
Reputation: 22441
In Ubuntu 12.04+ there is a section like this in /etc/default/tomcat7
:
# To enable remote debugging uncomment the following line.
# You will then be able to use a java debugger on port 8000.
#JAVA_OPTS="${JAVA_OPTS} -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"
So just uncomment it and run sudo service tomcat7 restart
.
Upvotes: 37