Thursday 15 September 2011

Java Debugger - local and server applications.

Help to find the bug in local and server applications. Java Debugger is Dynamic, Controlled and Assignment based debugging tool.

Default JPDA(Java Platform Debugger Architecture)  syntax:
-Xdebug -Xrunjdwp::transport=dt_socket,server=y,suspend=n,address=1044

Steps to Debug a web application?

1) Create a war/web project using maven. 
        1.1)  mvn archetype:create -DgroupId=com.sify.maven2example -DartifactId=maven2example_webapp -DarchetypeArtifactId=maven-archetype-webapp
        1.2) edit index.jsp and put the following code in it.
                     <H1>While Loop in Jsp</H1>
                     <%
                             int n = 0;
                               out.println("Number:");
                              while(n<10){
                             out.println(" , "+ n);
                                 n++;
                          }
                     %>
2) do mvn eclipse:eclipse
3) import the project in eclipse,
4)
Now in eclipse, go to Run->Debug Configuration. Double click on "Remote Java Application", select the project, set the connection props(host: localhost, port: 1044) and then click debug.
5) open the directory in command prompt and type " MAVEN_OPTS="$MAVEN_OPTS -server -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=1044,server=y,suspend=n" mvn tomcat:run "
6) Start debug with application with-in eclipse.
 

No comments:

Post a Comment