Skip to content

EmbeddedDirectoryServer.setup() fails with "Time service not started" in a fresh JVM #696

Description

@vharseko

Summary

EmbeddedDirectoryServer.setup() always fails in a fresh JVM with:

java.lang.IllegalStateException: Time service not started
	at org.opends.server.util.TimeThread.checkState(TimeThread.java:410)
	at org.opends.server.util.TimeThread.getLocalTime(TimeThread.java:275)
	at org.opends.server.loggers.TextErrorLogPublisher.log(TextErrorLogPublisher.java:458)
	at org.opends.server.loggers.ErrorLogger.log(ErrorLogger.java:101)
	...
	at org.opends.quicksetup.TempLogFile.<init>(TempLogFile.java:88)
	at org.forgerock.opendj.server.embedded.EmbeddedDirectoryServer.setup(EmbeddedDirectoryServer.java:423)

The failure happens before the installer (InstallDS) is even launched.

Root cause

TempLogFile registers a TextErrorLogPublisher to capture setup messages into the temporary log file and immediately logs through it. The publisher formats its timestamp with TimeThread.getLocalTime(), which throws when the time service is not running — and that is the normal state at setup() time:

  • in a fresh JVM (the main embedded use case) nothing has started the time service yet;
  • in a JVM where an in-process server was stopped, the service has been shut down.

How it was found

Running the slow TestNG group (excluded from CI): EmbeddedDirectoryServerTestCase.testSetupFromArchive fails with the exception above.

Expected behaviour

EmbeddedDirectoryServer.setup() works in a fresh JVM without requiring the caller to start any server-internal services first; log publishers used during setup must not depend on the running time service.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugembeddedEmbedded directory server (EmbeddedDirectoryServer)

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions