Technology

Browse this blog to know more about technology

Facebook

Look out for facebook timeline and games information and hacks.

Movies,games,software

check out the movie,game,software reviews

Monday, May 23, 2016

Debug Tomcat Application in Eclipse

Dear Viewers,

Eclipse application are debugged using traditional ways like System.out.println, restart the application, update the jar and verify their coding workflow through logs. Its better to debug your application and step over each line of code to check your result, and saves more time too.

1. Open run.sh file  and add the following code before the line where catalina gets executed . sh ../tomcat/bin/catalina.sh run
           
Here, I have used PORT 8000 as listen port, You may use your own free port
      
JAVA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y"    export  JAVA_OPTS = "$JAVA_OPTS"
Learn more at JDWP


2. Run the run.sh file. Now, The Shell script listens to the port 8000

3. Now, Open your eclipse where you have configured your build with all dependencies.

4. Go To Debug configuration from Run Menu

 



5. Find the Remote Java Application from the left pane. Create a new one

6. Now, Give a name and Choose your project from the right pane and give the listening port 8000 in the Connection Properties

7. Click Apply and Debug

8. Next time, you need to debug, Go to Run-->Debug History -->Choose your debug name

9. Now, You must see the run.sh which was waiting for the listen port would have started. Double click on the left side of the line number to insert a breakpoint. 


10. And its done. Happy Debugging :P :) 


Feel free to post your queries.