home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / faq-debugging.xml < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  5.1 KB  |  124 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.   Copyright 1999-2004 The Apache Software Foundation
  4.  
  5.   Licensed under the Apache License, Version 2.0 (the "License");
  6.   you may not use this file except in compliance with the License.
  7.   You may obtain a copy of the License at
  8.  
  9.       http://www.apache.org/licenses/LICENSE-2.0
  10.  
  11.   Unless required by applicable law or agreed to in writing, software
  12.   distributed under the License is distributed on an "AS IS" BASIS,
  13.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.   See the License for the specific language governing permissions and
  15.   limitations under the License.
  16. -->
  17. <!DOCTYPE faqs PUBLIC "-//APACHE//DTD FAQ V1.0//EN" "faq-v10.dtd">
  18. <faqs title="Debugging FAQs">
  19.  
  20.   <faq>
  21.     <question>How do I debug Cocoon using JDK1.3+?</question>
  22.     <answer>
  23.       <p>
  24.         With JDK1.3 or above, first set the <code>CATALINA_OPTS</code> (for
  25.         Tomcat 4.x as shown below (on Win2K).
  26.       </p>
  27.       <source><![CDATA[
  28. set CATALINA_OPTS=-server -Xdebug -Xnoagent -Djava.compiler=NONE
  29.     -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
  30. ]]></source>
  31.       <note>
  32.         For Tomcat 3.x the param is TOMCAT_OPTS and the first value is
  33.         <code>-classic</code> instead of <code>-server</code>.
  34.       </note>
  35.       <p>
  36.         Add it to the <code>catalina.bat</code>, that can be found in
  37.         <code>%TOMCAT_HOME%\bin\</code>, right after the first <code>rem</code>
  38.         section.
  39.         <br/>
  40.         The same information in more detail can be found at
  41.         <link href="http://jakarta.apache.org/site/idedev-rdtomcat.html">Setting
  42.         up Tomcat for Remote Debugging</link>.
  43.       </p>
  44.       <p>
  45.         The problem of this approach is the blocking of using Tomcat in another
  46.         mode. You always have to touch <code>catalina.bat</code> again when
  47.         changing the mode and this file is really a batch beast, isn't it?
  48.         Furthermore <code>catalina.bat</code> is only a starting mode library
  49.         and should not be touched by hand IMO.<br/>
  50.         Let me propose my approach: Go to the last line of
  51.         <code>startup.bat</code> where <code>catalina.bat</code> is called.
  52.         Replace
  53.       </p>
  54.       <source>call "%EXECUTABLE%" start %CMD_LINE_ARGS%</source>
  55.       <p>with</p>
  56.       <source>
  57. set JPDA_TRANSPORT=dt_socket
  58. set JPDA_ADDRESS=8000
  59. call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%
  60.       </source>
  61.       <p>
  62.         A switch can now be done by adding and removing <code>jpda</code>. You
  63.         can also place the old line in comments and switch between them. Or you
  64.         copy <code>startup.bat</code> to <code>debug.bat</code> and do the
  65.         changes there.
  66.       </p>
  67.       <note>
  68.         Note that Tomcat must be started using <code>startup.bat</code> in order
  69.         to set these values; if you are using
  70.         "<code>java.exe -jar ...bootstrap.jar start</code>" or anything similar to
  71.         start Tomcat, you have to set the <code>CATALINA_OPTS</code> on the
  72.         commandline or for Windows in general.
  73.       </note>
  74.       <note>
  75.         If you use Jetty included with Cocoon 2.1 it's much easier. Instead of
  76.         doing "<code>cocoon.bat servlet</code>" you simply call
  77.         "<code>cocoon.bat servlet-debug</code>".
  78.       </note>
  79.       <p>
  80.         After having started Tomcat or the servlet container of your choice in
  81.         remote debugging mode, attach the debugger to localhost:8000 using
  82.         "<code>jdb -attach myhost:8000</code>". If you get an error
  83.         "<code>Error accessing shared memory, rc = -1</code>", try
  84.         "<code>jdb -connect com.sun.jdi.SocketAttach:port=8000</code>" instead.
  85.         <br/>
  86.         More information on this can be found in the
  87.         <link href="http://java.sun.com/j2se/1.4.2/docs/guide/jpda/conninv.html">
  88.         JPDA documentation</link>.
  89.       </p>
  90.       <note>
  91.         The attaching of the debugger to that port can be done very easily in
  92.         almost all modern IDEs as Eclipse, IDEA, NetBeans or JBuilder. Mostly
  93.         port <code>8000</code> and <code>dt_socket</code> are preselected.
  94.       </note>
  95.     </answer>
  96.   </faq>
  97.   <faq>
  98.     <question>
  99.       Now that I have prepared Tomcat and my IDE for debugging: How do I debug?
  100.     </question>
  101.     <answer>
  102.       <p>
  103.         Of course we can not give to many details here as it might be different
  104.         for all the possible IDEs out there, but the general proceeding should
  105.         be the same. The following steps are for jdb, it should be much easier
  106.         for the IDEs.<br/>
  107.         1. Set a breakpoint in a class via
  108.            "<code>stop in org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.checkPipeline</code>".
  109.         <br/>
  110.         2. Enter a URL in your browser to get Cocoon to do the stuff that needs
  111.            debugging. When your breakpoint is hit, you'll get the message in jdb:
  112.            <br/>
  113.            <code>Breakpoint hit: "thread=Thread-11",
  114.            org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.checkPipeline(),
  115.            line=363 bci=0</code>.
  116.         <br/>
  117.         3. Use the debugger commands "print", "next", and "cont" to examine the
  118.            data and step through the code.
  119.       </p>
  120.     </answer>
  121.   </faq>
  122. </faqs>
  123.  
  124.