Skip to content
Skip to breadcrumbs
Skip to header menu
Skip to action menu
Skip to quick search
Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Dashboard
Cargo
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<h3>Definition</h3><p><table class="wysiwyg-macro" data-macro-name="excerpt" data-macro-parameters="atlassian-macro-output-type=INLINE" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2V4Y2VycHQ6YXRsYXNzaWFuLW1hY3JvLW91dHB1dC10eXBlPUlOTElORX0&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="RICH_TEXT"><tr><td class="wysiwyg-macro-body"><p>Explain how to perform debugging when something doesn't work in Cargo</p></td></tr></table> </p><p>Sometimes, it can happen that the container does not start or stop as expected or you might have reasons to believe that CARGO is "acting weird". Here is a short list of things you can do to try debugging the problem.</p><h3>Debugging the container</h3><p>Most Java Virtual Machine implementations support remote debugging. Once started in debug mode, you can then remotely connect to your container using any IDE and debug your container and/or application.</p><p>In order to do so, add the following arguments to the JVM arguments configuration:</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=<suspend>,address=<port> -Xnoagent -Djava.compiler=NONE </pre></td></tr></table><p>where:</p><ul><li><strong>suspend</strong> is whether the launch of the container should first wait for a remote debugger to connect. If <code>y</code>, the container will wait for you to connect with your remote debugger before starting; if <code>n</code> the container will start immediately and at the same time listen on the remote debugging port.</li><li><strong>port</strong> is the port number to use for remote debugging.</li></ul><p>Here is an example for starting a JOnAS 5.x container in Remote Debug on port 8000 without suspend mode using the Maven2 plugin:</p><table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><plugin> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <version>${cargo.version}</version> <configuration> <container> <containerId>jonas5x</containerId> <type>installed</type> <home>${jonas.root}</home> </container> <configuration> <type>existing</type> <home>${jonas.base}</home> <properties> <cargo.servlet.port>${http.port}</cargo.servlet.port> <cargo.jvmargs> -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000 -Xnoagent -Djava.compiler=NONE </cargo.jvmargs> </properties> </configuration> </configuration> </plugin> </pre></td></tr></table><p>Once the server is started, follow these steps to remotely debug your server and/or application:</p><ol><li>Click <strong>Debug</strong> - <strong>Attach Debugger...</strong></li><li>In the window that appears, type in the remote host name and the port number then click OK</li></ol><p><img class="confluence-embedded-image" src="/download/attachments/230400726/NetBeans+remote+debugger.png?version=1&modificationDate=1369033122642" data-image-src="/download/attachments/230400726/NetBeans+remote+debugger.png?version=1&modificationDate=1369033122642" data-linked-resource-id="230565294" data-linked-resource-type="attachment" data-linked-resource-default-alias="NetBeans remote debugger.png" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="230400726" title="null > NetBeans remote debugger.png"></p><p>Steps for achieving the same in Eclipse IDE are similar.</p><h3>Redirecting container output to a file</h3><h4>Example using the Java API</h4><p>The <code>Container.setOutput(File)</code> API allows you to redirect the container console (<code>stdout</code>) to a file. This is the first file you should check in case of problem.</p><p>Cargo is able to configure containers to generate various levels logs. There are 3 levels defined in <a href="http://cargo.codehaus.org/maven-site/cargo-core/apidocs/org/codehaus/cargo/container/property/LoggingLevel.html"><code>o.c.c.container.property.LoggingLevel</code></a>: <code>LoggingLevel.LOW</code>, <code>LoggingLevel.MEDIUM</code> and <code>LoggingLevel.HIGH</code> (<code>LoggingLevel.MEDIUM</code> is the default value). They represent the quantity of information you wish to have in the generated log file. You can tune container logging by using the following API:</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>configuration.setProperty(GeneralPropertySet.LOGGING, LoggingLevel.HIGH.getLevel()); </pre></td></tr></table><p>The generated log files will then be found in the working directory you have specified on the container (through the <code>container.setWorkingDir()</code> call).</p><p>Starting Tomcat 4.x specifying an output console log file:</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>LocalContainer container = new Tomcat4xLocalContainer( new CatalinaStandaloneLocalConfiguration("target/tomcat4x")); container.setHome("c:/apps/jakarta-tomcat-4.1.30"); container.setOutput("target/output.log"); container.start(); </pre></td></tr></table><p>Use the <code>container.setAppend(true|false)</code> method to decide whether the log file is recreated or whether it is appended to, keeping the previous execution logs (by default, the file is recreated at every container start or stop).</p><h4>Example using the Ant API</h4><p>Starting Tomcat 4.x specifying an output console log file with the highest possible level of logs:</p><table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><cargo containerId="tomcat4x" home="c:/apps/jakarta-tomcat-4.1.30" action="start" output="target/output.log" append="false"> <configuration home="target/tomcat-home"> <property name="cargo.logging" value="high"/> </configuration> </cargo></pre></td></tr></table><p>Use the <code>append="true|false"</code> attribute for controlling the log file creation behavior.</p><h4>Example using the Maven2/Maven3 plugin</h4><p>Starting Tomcat 4.x specifying an output console log file with the highest possible level of logs:</p><table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><container> <containerId>tomcat4x</containerId> <home>c:/apps/jakarta-tomcat-4.1.30</home> <output>target/output.log</output> <append>false</append> </container> <configuration> <properties> <cargo.logging>high</cargo.logging> </properties> </configuration> </pre></td></tr></table><p>Use the <code>append="true|false"</code> attribute for controlling the log file creation behavior.</p><h3>Debugging CARGO itself</h3><p>To enable the Java debugger on ANT, export the <code>ANT_OPTS</code> system property using the parameters specified above. For example:</p><table class="wysiwyg-macro" data-macro-name="code" data-macro-parameters="language=bash" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6bGFuZ3VhZ2U9YmFzaH0&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>export ANT_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"</pre></td></tr></table><p>On Maven2/Maven3, enabling Java debugger is done using the <code>mvnDebug</code> executable instead of <code>mvn</code>.</p><table class="wysiwyg-macro" data-macro-name="info" data-macro-parameters="title=mvnDebug command on MacOS X" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2luZm86dGl0bGU9bXZuRGVidWcgY29tbWFuZCBvbiBNYWNPUyBYfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="RICH_TEXT"><tr><td class="wysiwyg-macro-body"><p> Note that on MacOS X, <code>mvnDebug</code> is not on the default path. To run it, execute the command: <code>/usr/share/maven/bin/mvnDebug</code></p></td></tr></table><h3>Redirecting CARGO logs to a file</h3><h4>Example using the Java API</h4><p>Some Cargo classes support generation of logs. This is implemented through the notion of <a href="http://cargo.codehaus.org/maven-site/cargo-core/apidocs/org/codehaus/cargo/util/log/Logger.html"><code>Logger</code></a> and levels are managed using <a href="http://cargo.codehaus.org/maven-site/cargo-core/apidocs/org/codehaus/cargo/util/log/LogLevel.html"><code>LogLevel</code></a>. There are 3 levels defined in <a href="http://cargo.codehaus.org/maven-site/cargo-core/apidocs/org/codehaus/cargo/util/log/LogLevel.html"><code>o.c.c.util.log.LogLevel</code></a>: <code>LogLevel.DEBUG</code>, <code>LogLevel.INFO</code> and <code>LogLevel.WARN</code> (<code>LogLevel.INFO</code> is the default value).</p><p>For example to turn on logging monitoring on a <code>Container</code> class, you can use:</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>Logger fileLogger = new FileLogger(new File("c:/tmp/cargo.log"), true); fileLogger.setLevel(LogLevel.DEBUG); container.setLogger(fileLogger); </pre></td></tr></table><p>There are several Loggers that are readily available in the Cargo distribution:</p><ul><li><a href="http://cargo.codehaus.org/maven-site/cargo-core/apidocs/org/codehaus/cargo/util/log/FileLogger.html">FileLogger</a>: logs messages to a file</li><li><a href="http://cargo.codehaus.org/maven-site/cargo-core/apidocs/org/codehaus/cargo/util/log/SimpleLogger.html">SimpleLogger</a>: logs messages to the console (stdout)</li><li><a href="http://cargo.codehaus.org/maven-site/cargo-core/apidocs/org/codehaus/cargo/util/log/AntLogger.html">AntLogger</a>: logs messages using Ant's logging mechanism</li></ul><h4>Example using the Ant API</h4><p>When using the Ant tasks, CARGO will by default use the <a href="http://cargo.codehaus.org/maven-site/cargo-core/apidocs/org/codehaus/cargo/util/log/AntLogger.html">AntLogger</a>. You can specify the log level using the <code>logLevel</code> attribute, and the log file by using the <code>log</code> attribute. For example:</p><table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><cargo containerId="tomcat4x" home="c:/apps/jakarta-tomcat-4.1.30" action="start" logLevel="debug" log="target/cargo.log"/> </pre></td></tr></table><h4>Example using the Maven2/Maven3 plugin</h4><p>When using the Maven2/Maven3 plugin, CARGO will by default use the <a href="http://cargo.codehaus.org/maven-site/cargo-extensions/apidocs/org/codehaus/cargo/maven2/log/MavenLogger.html">MavenLogger</a>.</p><p>When you use <code>mvn</code> with the <code>-e</code> option, both Maven itself and the CARGO plugin will log everything in debug mode.</p><p>If you want to use the plugin in debug mode without having Maven itself in debug mode, you can specify the log level using the <code>logLevel</code> attribute, and the log file by using the <code>log</code> attribute. For example:</p><table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><container> <containerId>tomcat4x</containerId> <home>c:/apps/jakarta-tomcat-4.1.30</home> <log>target/cargo.log</log> <logLevel>debug</logLevel> </container></pre></td></tr></table>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced