Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Definition

Excerpt

Explain 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.

...

Code Block
xml
xml
<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>
      </properties>
    </configuration>
  </configuration>
  <executions>
    <execution>
      <id>run</id>
      <configuration>
        <configuration>
          <properties>
            <cargo.jvmargs>
              -Xdebug
              -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
              -Xnoagent
              -Djava.compiler=NONE
            </cargo.jvmargs>
          </properties>
        </configuration>
      </configuration>
      <goals>
        <goal>run</goal>
      </goals>
    </execution>
  </executions>
</plugin>
Note
titleMake sure the Debug arguments are only on one goal

Please remember to map the Debug arguments to only one goal; else you will get exceptions such as the below when you try to stop your container:


[INFO] [talledLocalContainer] FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
[WARNING] [talledLocalContainer] ERROR: transport error 202: bind failed: Address already in use
[WARNING] [talledLocalContainer] ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
[WARNING] [talledLocalContainer] JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [../../../src/share/back/debugInit.c:741]

 

Once the server is started, follow these steps to remotely debug your server and/or application:

...

Starting Tomcat 4.x specifying an output console log file with the highest possible level of logs:

Code Block
xml
xml
<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 append="true|false" attribute for controlling the log file creation behavior.

...

Starting Tomcat 4.x specifying an output console log file with the highest possible level of logs:

Code Block
xml
xml
<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 append="true|false" attribute for controlling the log file creation behavior.

...

Some Cargo classes support generation of logs. This is implemented through the notion of Logger and levels are managed using LogLevel. There are 3 levels defined in o.c.c.util.log.LogLevel: LogLevel.DEBUG, LogLevel.INFO and LogLevel.WARN (LogLevel.INFO is the default value).

For example to turn on logging monitoring on a Container class, you can use:

Code Block
Logger fileLogger = new FileLogger(new File("c:/tmp/cargo.log"), true);
fileLogger.setLevel(LoggingLevelLogLevel.HIGHDEBUG);
container.setLogger(fileLogger);

...

When using the Ant tasks, you CARGO will by default use the AntLogger. You can specify the log level using the logLevel attribute, and the log file by using the log and logLevel attributes attribute. For example:

Code Block
xml
xml
<cargo containerId="resin3xtomcat4x" [...] home="c:/apps/jakarta-tomcat-4.1.30" 
    action="start"
    logLevel="debug"
    log="target/cargo.log"/>

Use the append="true|false" attribute for controlling the log file creation behavior.

Example Example using the Maven2/Maven3 plugin

When using the Maven2/Maven3 plugin, CARGO will by default use the MavenLogger.

When you use mvn with the -e option, both Maven itself and the CARGO plugin will log everything in debug mode.

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 logLevel attribute, and the log file by using the log attribute. For example:

Code Block
xml
xml
<container>
  <containerId>tomcat4x</containerId>
  <home>c:/apps/jakarta-tomcat-4.1.30</home>
  <log>target/cargo.log</log>
  <logLevel>debug</logLevel>
</container>