Tuesday, 24 December 2013

Remote Debug with tomcat and Eclipse


Configuration
As stated in the Apache Tomcat documentation, in order to enable remote debugging support, you'll need to pass the following argument to the JVM used by Tomcat, when it starts : 

-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
Since Apache has already announced that they'll stop supporting Tomcat 5 soon, therefore I won't address this version of Tomcat's configuration. 
Regarding Tomcat 6 (and later), it already provides all the required configuration in the catalina.bat file : the default transport type is already set to "dt_socket" (the other supported transport type is "shared memory" but this one is not commonly used - actually, I haven't used it so far so I won't be able to tell you what it is about precisely) and the default port is set to 8000. In case the port number 8000 is already in use in your environment, you can simply change it by editing the catalina.bat file. 
Here's the section from the catalina.bat file that would interest you :


 **
if not ""%1"" == ""jpda"" goto noJpda
set JPDA=jpda
if not "%JPDA_TRANSPORT%" == "" goto gotJpdaTransport
set JPDA_TRANSPORT=dt_socket
:gotJpdaTransport
if not "%JPDA_ADDRESS%" == "" goto gotJpdaAddress
set JPDA_ADDRESS=8000
:gotJpdaAddress
if not "%JPDA_SUSPEND%" == "" goto gotJpdaSuspend
set JPDA_SUSPEND=n
:gotJpdaSuspend
if not "%JPDA_OPTS%" == "" goto gotJpdaOpts
set JPDA_OPTS=-agentlib:jdwp=transport=%JPDA_TRANSPORT%,address=%JPDA_ADDRESS%,server=y,suspend=%JPDA_SUSPEND%
:gotJpdaOpts
shift
:noJpda








Suppose you need to change the default port, you'll, then, set another value to the JPDA_ADDRESS variable.

Running Tomcat with remote debugging enabled
  • deploy the application you need to debug as usually
  • start Tomcat by executing the catalina.bat script and providing the "jpda" argument 
(ex.: D:\Develtools\apache-tomcat-7.0.26\bin>catalina jpda start)
Then, all you need to do is to create a remote Java application in Eclipse through these few steps : 
1° Open the debug configurations 
2° Create a new Remote Java application : 



3° Specify the project you're debugging (in my example, I've configured remote debugging for one on my sample projects, named "Blog - Remote Tomcat debugging")
4° Specify the host on which the application to debug is deployed
5° Specify the port that is opened for debugging purpose (same as the one configured as JPDA_ADDRESS in the catalina.bat file from Tomcat)
6° Launch the Remote application by clicking on "Debug" 
At this point, you could set breakpoints wherever you want in the project's source code and if the code marked with your breakpoints is executed, the running thread will be suspended and you'll be able to watch variables' value, execute expression, and so on.

Thursday, 19 December 2013

Remote Debug glasfish with Idea Intellij 12.x


Steps to debug glassfish with IDEA:
> Go to domain.xml of glasfish
     C:\new_server\glassfish4\glassfish\domains\mozart_app\config
> Search for :

   <java-config debug-options="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9009" debug-enabled="true" system-classpath="" classpath-suffix="">

server=y,suspend=n,   This properties should be like this only and  debug-enabled should be true.

>Go to run >> Edit Confoguration >> click "+" >> Remote . On right side frame write name (any in my case written as TEst)



and set port to 9009 <IT should be similar with domain.xml >


> Now Start glassfish from command line with one added option  :  --debug=true 
for eg: >  asadmin start-domain --debug=true domain1

and start newly created Test debug.


thats it falk :)


Remote Debugging with Eclipse :
http://www.eclipsezone.com/eclipse/forums/t53459.html
http://java.dzone.com/articles/how-debug-remote-java-applicat
http://www.myeclipseide.com/documentation/quickstarts/remotedebugging/

Remote Debugging with IntelliJ IDEA :
http://www.javaranch.com/journal/200408/DebuggingServer-sideCode.html

Remote Debugging Web Services, Apache Axis 2 :
http://wso2.org/library/225
http://wso2.org/library/3851
http://amilamanoj.blogspot.com/2011/09/running-debugging-apache-axis2-inside.html
http://shameerarathnayaka.blogspot.com/2011/09/remote-debugging-apache-axis2-with.html






























Saturday, 14 December 2013

Configure Apache Web server for redirection to Tomcat in Windows

1> create a an workers.properties file with following content

# Define a worker named 'worker1' (more workers can be added as comma separated values)

  worker.list=worker1

  # Set worker properties

  worker.worker1.type=ajp13

  worker.worker1.host=localhost

  worker.worker1.port=8009
2> download apache web server installer  "download httpd-2.0.65-win32-x86-openssl-0.9.8y.msi "
from http://apache.osuosl.org/httpd/binaries/win32/ custom_install
 Or you can install manually manual_install_apache.

3> install it as shown in link

4>dowload apache tomcat connector :
tomcat-connectors-1.2.37-windows-i386-httpd-2.0.x

5>copy mod_jk.so file in module folder of apaches home folder

6>Modify httpd.config file with following content

<pre class="brush: csharp">

# Load mod_jk module
# Update this path to match your modules location
LoadModule    jk_module  modules/mod_jk.so

# Where to find workers.properties
# Update this path to match your conf directory location (put workers.properties next to     httpd.conf)
JkWorkersFile conf/workers.properties

# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
# This can be commented out, to disable logging
JkLogFile     logs/mod_jk.log

# Set the jk log level [debug/error/info]
# Only matters if JkLogFile is being used.
JkLogLevel    info

# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

# Send everything for context /examples to worker named worker1 (ajp13)
# /examples would most likely be the name of your WebApp (c:/tomcat/webapps/example)
JkMount  /MyMail/* worker1

</pre>

http://serverfault.com/questions/256195/apache-2-2-17-tomcat-7-on-windows-server
http://www.apachelounge.com/viewtopic.php?p=20085
http://apache.osuosl.org/httpd/binaries/win32/ >>  download httpd-2.0.65-win32-x86-openssl-0.9.8y.msi

http://www.premiumwebbloghosting.com/2012/03/how-to-install-apache-server-on-windows.html

http://www.serverwatch.com/tutorials/article.php/10825_2203891_1
less imp

http://www.apachelounge.com/download/win64/