130 likes | 229 Views
Web Servers and Server-Side Debugging. Jetty. In this course we are using Maven Jetty Plugin for convenience Maven plugin configuration: To run Jetty execute from Maven Web project root: mvn jetty:run. <plugin> <groupId>org.mortbay.jetty</groupId>
E N D
Jetty • In this course we are using Maven Jetty Plugin for convenience • Maven plugin configuration: • To run Jetty execute from Maven Web project root: mvn jetty:run <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>8.1.7.v20120910</version> </plugin>
Enable remote debugging • Set environment variable MAVEN_OPTS with value -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n • E.g. create a BAT file for running Jetty: set MAVEN_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n mvn jetty:run
Debug configuration in Eclipse > Run > Debug Configurations…
Debugging • Start Jetty • Launch Debug configuration in Eclipse
Debugging • Add breakpoint, e.g. in Servlet code and send HTTP request • Server will stop at breakpoint
Download Tomcat • Download the Apache Tomcat http://tomcat.apache.org • Un-zip the distribution file • Deploy your application • Copy WAR file inside <TOMCAT_HOME>\webapps • Tomcat server can be started by executing BAT script <TOMCAT_HOME>\bin\startup.bat
Set up remote debugging • Stop Tomcat (Ctrl+C or close console window) • Open the startup script: startup.bat • Add the following lines at the first blank line in the file (around line 8) set JPDA_ADDRESS=8787 set JPDA_TRANSPORT=dt_socket • Change the execute line at the end to include jpda start call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS% • Run the startup script to run Tomcat in debug mode http://confluence.sakaiproject.org/display/BOOT/Setting+Up+Tomcat+For+Remote+Debugging
Download JBoss • Download the JBoss application server https://www.jboss.org/jbossas/downloads/ • Un-zip the distribution file • Deploy your application • Copy WAR file inside <JBOSS_HOME>\server\workspace\deploy • JBoss server can be started by executing BAT script <JBOSS_HOME>\bin\run.bat
Enableremote debugging • Stop JBoss (Ctrl+C or close console window) • Add or un-comment the following line in run.bat rem JPDA options. Uncomment and modify as rem appropriateto enable remote debugging. set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket, address=8787,server=y,suspend=n %JAVA_OPTS% 3. Create new “Remote Java Application” debug configuration in Eclipse: Run Open Debug Dialog