Export task failing with the error java.lang.NoClassDefFoundError

Export task failing with the error java.lang.NoClassDefFoundError

Introduction

This article explains how to resolve export task failures related to Universes or Connections when Tomcat runs in an environment without a graphical subsystem.

Environment

  • Product: 360Suite Web Platform
  • Product version: all versions
  • Operating systems: Windows or Linux

Symptoms

  • Export tasks involving Universes or Connections fail.
  • The error appears in the task logs.

Error Message

WarningFatal error stopped the task execution: java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment

Cause

This error occurs when the Java Virtual Machine used by Tomcat does not have access to a graphical environment.

Resolution

Add the following Java option to the Tomcat configuration:

Quote
-Djava.awt.headless=true

This forces Java to run in headless mode, which avoids initialization of graphical components not available on the server.

Windows

  1. Open the Tomcat Configuration application.
  2. Go to the Java tab.
  3. Add -Djava.awt.headless=true to the existing Java options.
  4. Save the configuration and restart Tomcat.

Linux

  1. Go to <CATALINA_HOME>/bin.
  2. Create a setenv.sh file if it does not already exist.
  3. Add or update the following lines:
Quote
JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true"
export JAVA_OPTS
  1. Save the file and restart Tomcat.

Additional Information

After applying the change, rerun the export task and verify in the task logs that the error no longer occurs.

Technical Resources