WebSphere Application Server doesn't start up with Contrast Java Agent or fails to use configured settings

  • Updated

Issue

  • The WebSphere Application Service (WAS) does not start up after adding the Contrast Java Agent and associated configuration properties under Application servers > serverName > Process definition > Java Virtual Machine > Generic JVM arguments and an error like the following appears in the WAS native_stderr.log:
Error: Could not find or load main class Server

Or

  • Contrast settings under Application servers > serverName > Process definition > Java Virtual Machine > Generic JVM arguments are ignored or truncated.

Cause

The WAS Integrated Services Console escapes quote characters in JVM properties. For example, WAS parses the value of -Dcontrast.application.session_metadata="buildNumber=4" as "buildNumber=4" instead of buildNumber=4. The quoted metadata value is invalid, so Contrast will ignore it.

In addition, if the quoted property value contains a space, the JVM will fail to start.  Because quote characters are escaped, the JVM interprets a property containing a space character as two distinct arguments.  For example, -Dcontrast.server.name="My Server" would be interpreted as two arguments: -Dcontrast.server.name="My and Server". The second argument is not a valid property and is expected to be the main class, so the WAS JVM fails to start.

Resolution

The WebSphere documentation recommends quoting the entire property instead of quoting the property value when specifying properties in the WAS Console.

For example, to fix both the above issues, specify "-Dcontrast.server.name=My Server" and "-Dcontrast.application.session_metadata=buildNumber=4" as JVM arguments.

Alternatively, you can avoid WAS Console issues entirely by specifying the configuration via environment variables:

export CONTRAST__SERVER__NAME="My Server"
export CONTRAST__APPLICATION__SESSION_METADATA="buildNumber=4"

Or via a YAML configuration file:

server:   
name: "My Server"
application:
session_metadata: buildNumber=4

You can direct the agent to the appropriate configuration file by including the single argument -Dcontrast.config.path=/path/to/contrast_security.yaml in the WAS Console.

For full documentation on configuring the Java agent, please see Java - Configuration

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request