Skip to Content

 

Before we start looking at on how to debug on SAP Portals PDK Application      with Tomcat using Eclipse, let me introduce you to JPDA Server and its options.   

 

JPDA – a Brief Intro

 

The Java Platform Debugger Architecture (JPDA) provides support and infrastructure      needed to remotely debug Web/Servlet Application in Java 2 Platform, Standard      Edition since version 1.3. To Debug a Java Application remotely Tomcat and      JVM has to communicate with each other along with Eclipse. The Java Virtual      Machine needed to be started with JPDA Server listening for Connections. In      the reference implementation the JVM can listen from different sources.

 

       

  1. Socket Connection to JVM. Using a socket is perhaps the best method of        remotely debugging the Java Application.
  2.    

  3. Shared Memory (Only in Windows OS). Using Shared memory on windows platform        JPDA Server can remotely debug the applications. I have tested this with        a simple Servlet Web Application, but experienced very slow response times        in processing debugging instructions from/to JPDA Server. And I could not        make it work in ECLIPSE/PDK/TOMCAT Environment.
  4.  

 

I recommend using Socket Connection to the JVM. Generally ‘X Flags’ are      used to pass the JVM about debugging information with various options. -XDebug      (notice the case) flag is the one which enables Debugging on JVM. The -Xrunjdwp      flag is to set the type of transport (like dt_socket or dt_shmem) and its      address. This parameter can be specified as below.

 

java appName -Xdebug -Xrunjdwp:server=y,transport=dt_shmem,address=jdbconn

 

server=y              - Start the JPDA Server

 

transport=dt_shmem    - Under Windows - Shared Memory

 

address=jdbconn       - Name of the shared memory

 

to Use Socket Connection to the JPDA Server use the following parameter      statement

 

java appName -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=5000   

 

Problem. “Cannot Start Remote Debugging using Eclipse      IDE on Tomcat 4.x?”

 

Generally Eclipse throws “Remote connection refused…..” etc      messages while trying to connect to JVM using dt_shmem debug option. I have      faced the similar problem while trying to start the remote debugging in Eclipse.      I then started looking deeper into the CATALINA.bat script. I found out that      out-of-box CATALINA script is trying to start the debugger with the Shared      Memory option (transport=dt_shmem and address=jdbconn). This is the actual      problem in not able to connect to the Virtual machine when you click on start      debug button in Eclipse. To avoid this problem we can simply use the other      JPDA Server option Socket.

 

Solution. There are two ways to resolve this problem.

 

2. By changing the catalina script – Search and replace the following variables   

 

transport=dt_socket and address=5000 (Make sure the port is available      by typing netstat -a in the dos window)

 

1. The simplest way is to set two environmental variables in windows system      as follows. This is good becoz it works even if you reinstall/upgrade your      tomcat to next version.

 

   a. Right click on 'My Computer' and select properties

 

   b. Click on 'Advanced' Tab and Select 'Environment Variables'

 

   c. Click on 'New' button in the Second window (which is for all the users using the system)

 

   d. Type 'JPDA_TRANSPORT' in Variable Name

 

   e. Type 'dt_socket' in Variable Value

 

   f. Click OK.

 

   g. Repeat step C.

 

   h. Type 'JPDA_ADDRESS' in Variable Name

 

   i. Type '5000' in Variable Value. (Remember to type the same value you set in your Eclipse debug options)

 

   j. Click OK.

 

   k. Close all the windows by clicking OK.

 

Before you start the debuggin in Eclipse, Start your Tomcat server in Debug      mode by typing

 

catalina jpda start

 

In ECLIPSE, after the tomcat started, now you are ready to start the remote      debugger in Eclipse. Goto Run->Debug->Remote Application and click DEBUG      button. You will see that DEBUG perspective shows messages that it has connected.      Set some break points in your Application and run your iView from ECLIPSE      by switching to Java perspective and deploying to the local portals. Vol la      you are all set to debug your application.

 

Finally a note on the above instructions, the above procedure tested only      with Tomcat 4.x. If you are running Tomcat 3.3 please make sure that it supports      JPDA_TRANSPORT and JPDA_ADDRESS environment variables by looking at tomcat.bat      script.

 

Happy debugging….!!!

To report this post you need to login first.

5 Comments

You must be Logged on to comment or reply to a post.

      1. Girish Ogirala Post author
        Srikant,

        send me an the copy of startup.bat or wherever you have made the changes to the Tomcat batch file along with Tomcat version u are using so that we can debug the problem u are facing.

        Sorry for the delayed reply.

        Thanks
        Girish.

        (0) 
    1. Nobody Noname
      Hi Girish,

      Could you please tell me how to debug using tomcat pluging for eclipse. I tried giving the debug parameter as JVM option in tomcat, however tomcat never started nor gave any error.

      Any help is really appreciated.

      Thanks
      -Srikant
      UBS-IB
      Stamford, CT, USA

      (0) 
      1. Girish Ogirala Post author
        Srikant,

        send me an the copy of startup.bat or wherever you have made the changes to the Tomcat batch file along with Tomcat version u are using so that we can debug the problem u are facing.

        Sorry for the delayed reply.

        Thanks
        Girish.

        (0) 

Leave a Reply