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.

5 comments:

  1. I do agree with all the ideas you have presented in your post. They’re really convincing and will certainly work. Still, the posts are very short for newbies. Could you please extend them a little from next time?..Keep this great work.
    Fake news

    ReplyDelete
  2. I really appreciate your professional approach.These are pieces of very useful information that will be of great use for me in future.

    หนังสงคราม

    ReplyDelete
  3. Artikel yang sangat menarik gan, jangan lupa kunjungi blog saya ya https://keranjangpoker.blogspot.com/

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete