Starting tomcat in debug mode – Linux

To start tomcat in debug mode, you need to set JPDA_TRANSPORT=dt_socket and JPDA_ADDRESS=9000 environment variable. To set these variable for a session only, open command prompt and run following commands

export CATALINA_HOME=/home/xyz/opt/tomcat
export JPDA_TRANSPORT=dt_socket
export JPDA_ADDRESS=9000

now start tomcat using following command

$ %CATALINA_HOME%/bin/catalina.sh jpda start

Setting this variable in your personal ~/.bashrc file has the advantage that it will always be set (for you, as a user) each time you log in or reboot the system. To do so, open ~/.bashrc in a text editor (or create the file if it doesn’t already exist) and insert the following line anywhere in the file

export CATALINA_HOME=/home/xyz/opt/tomcat
export JPDA_TRANSPORT=dt_socket
export JPDA_ADDRESS=9000

Save and close .bashrc.
You must logout and login again to make your change take effect. or source your .bashrc file to make your change take effect for the current session

$ source ~/.bashrc

Start tomcat6 (installed as a windows service) debug mode using eclipse remote debugging

I have spent around 5 hrs in google to know how to start tomcat6 (installed as a windows service) debug mode using eclipse remote debugging. Here are the steps.

1) Go to your catalina_home/bin.
2) You will find a file called tomcat6w.exe
3) double click on the file and a window will be opened.
4) In the opened window, go to “java” tab.You will find a “text area box” with label as “Java Options”

5) Add the following lines of the code at the the beginning of the text area. (I mean above the first -D…)

6) The below are the lines which you need to add.
-Xdebug -Xnoagent -Djava.compiler=NONE
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005

7) Once you have added go to your eclipse and go to Debug–>Debug Configurations and create a new configuration for your project with the port as 5005 (as given above) and save it.

8) Now start your tomcat service. You’ll observe at the middle of starting of your service it will become very slow and not responsive. At that time start your already configured debugger. Now you see your server started successfully in debug mode. Remember that as i mention above, if when your service start up is slow and you have not started your eclipse debugger at that time, then your server won’t start and you’ll get some error.

I have spent a lot of time on this and so i am posting it so that, the people who sees this can continue their work from here easily….

Changing project type form general to java in eclipse

You have a project, which is basically a java project but during checking out the project or creating a new project, you didn’t selected type of project as java. You are stuck now as there is no option to change it to java type in eclipse UI.
You can change type of project by modifying.projectfile, located in the root directory of your project. Open .project file in any text editor and search for text “natures”. You’ll see an empty natures node.

<natures>
</natures>

Change this value to

<natures>
        <nature>org.eclipse.jdt.core.javanature</nature>
</natures>