|
|||||||
|
|||||||
DocumentationContainers
Get InvolvedFeeds
|
DefinitionExplain how to perform debugging when something doesn't work in Cargo 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. Debugging the containerMost 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. In order to do so, add the following arguments to the JVM arguments configuration: -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=<suspend>,address=<port> -Xnoagent -Djava.compiler=NONE where:
Here is an example for starting a JOnAS 5.x container in Remote Debug on port 8000 without suspend mode using the Maven2 plugin: <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>
Once the server is started, follow these steps to remotely debug your server and/or application:
![]() Steps for achieving the same in Eclipse IDE are similar. Redirecting container output to a fileExample using the Java APIThe Cargo is able to configure containers to generate various levels logs. There are 3 levels defined in configuration.setProperty(GeneralPropertySet.LOGGING, LoggingLevel.HIGH.getLevel()); The generated log files will then be found in the working directory you have specified on the container (through the Starting Tomcat 4.x specifying an output console log file: LocalContainer container = new Tomcat4xLocalContainer(
new CatalinaStandaloneLocalConfiguration("target/tomcat4x"));
container.setHome("c:/apps/jakarta-tomcat-4.1.30");
container.setOutput("target/output.log");
container.start();
Use the Example using the Ant APIStarting Tomcat 4.x specifying an output console log file with the highest possible level of logs: <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>
Use the Example using the Maven2/Maven3 pluginStarting Tomcat 4.x specifying an output console log file with the highest possible level of logs: <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>??
Use the Debugging CARGO itselfTo enable the Java debugger on ANT, export the export ANT_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000" On Maven2/Maven3, enabling Java debugger is done using the
Redirecting CARGO logs to a fileExample using the Java APISome Cargo classes support generation of logs. This is implemented through the notion of For example to turn on logging monitoring on a Logger fileLogger = new FileLogger(new File("c:/tmp/cargo.log"), true);
fileLogger.setLevel(LogLevel.DEBUG);
container.setLogger(fileLogger);
There are several Loggers that are readily available in the Cargo distribution:
Example using the Ant APIWhen using the Ant tasks, CARGO will by default use the AntLogger. You can specify the log level using the <cargo containerId="tomcat4x" home="c:/apps/jakarta-tomcat-4.1.30"
action="start"
logLevel="debug"
log="target/cargo.log"/>
Example using the Maven2/Maven3 pluginWhen using the Maven2/Maven3 plugin, CARGO will by default use the MavenLogger. When you use 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 <container> <containerId>tomcat4x</containerId> <home>c:/apps/jakarta-tomcat-4.1.30</home> <log>target/cargo.log</log> <logLevel>debug</logLevel> </container> |
||||||
| |||||||