Search code examples
javaeclipsetomcatubuntutomcat7

Setting up JPDA for Tomcat7 in ubuntu-server


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?


Solution

  • 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.