I'm assuming that the alfresco 4.0.2 installed
with in built tomcat and in c:\alfresco folder.
Configure the tomcat the jpda start option. Go to the following directory
in the command window.
c:\alfresco\tomcat\bin directory and create the following environment variables.
(Adjust the memory to overcome permGen memory
issue.)
set CATALINA_OPTS=-server -Xmx384m -XX:MaxPermSize=192m
set JPDA_ADDRESS=8000 and press enter
set JPDA_TRANSPORT=dt_socket and press enter
Now we need to start tomcat in debug mode.
c:\alfresco\tomcat\bin>catalina.bat jpda
start
Now open Eclipse and open your project.
Go to Run menu -->Debug configuration-->Remote Java application-->New Launch
Configuration-->Select your Projecthere--> [Don't do anything appart from this]
check the box marked "Allow termination of remote JVM" --> Click Apply--> Click
Debug button.
Now, eclipse will the window perspective to Debug perspective and if you've the
breakpoints in your code, the debugger will hit it.
Please find the original blog here.