Skip to content

[#696] Fix embedded server setup failing with "Time service not started" - #687

Merged
vharseko merged 2 commits into
OpenIdentityPlatform:masterfrom
vharseko:features/embedded-setup-logging
Jul 8, 2026
Merged

[#696] Fix embedded server setup failing with "Time service not started"#687
vharseko merged 2 commits into
OpenIdentityPlatform:masterfrom
vharseko:features/embedded-setup-logging

Conversation

@vharseko

@vharsekovharseko commented Jul 4, 2026

Copy link
Copy Markdown
Member

Fixes#696

Problem

EmbeddedDirectoryServer.setup() fails 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)

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, and in a JVM where an in-process server was stopped the service has been shut down. The failure happens before the installer (InstallDS) is even launched.

Found by running the slow TestNG group (excluded from CI), where EmbeddedDirectoryServerTestCase.testSetupFromArchive fails.

Fix

Make TimeThread.getLocalTime() compute the timestamp on demand (same dd/MMM/yyyy:HH:mm:ss Z format) when the time service is not running, instead of throwing. It is the only TimeThread accessor used by the text log publishers (TextErrorLogPublisher, TextDebugLogPublisher); all other accessors keep their strict lifecycle check.

Enable EmbeddedDirectoryServerTestCase.testSetupFromArchive in the default build now that it passes.

Verification

EmbeddedDirectoryServerTestCase: 12/12 pass under the default CI group filter (~93s), including testSetupFromArchive for the first time.

Note: this branch is stacked on #685 (both change EmbeddedDirectoryServerTestCase); once #685 is merged only the single commit of this PR remains.

EmbeddedDirectoryServer.rebuildIndex() is an offline-only operation
(it requires the server to be stopped), but RebuildIndexParameters did
not pass the --offline flag to the rebuild-index tool. Since TaskTool
runs locally only when --offline is given, the tool went into task
scheduling mode instead: it prompted for the bind password and tried
to connect to the tasks backend of the stopped server, failing with
'Connect Error' and exit code 1.
Move EmbeddedDirectoryServerTestCase out of the "slow" group into the
default build (11 tests, ~1 minute). testSetupFromArchive stays in the
"slow" group for now: it fails with "Time service not started" because
the slf4j adapter still routes through the stopped main server's error
log publishers; it will be enabled together with the fix for that.
EmbeddedDirectoryServer.setup() failed with an IllegalStateException
before even launching the installer: TempLogFile registers a
TextErrorLogPublisher to capture setup messages and immediately logs
through it, and the publisher formats its timestamp with
TimeThread.getLocalTime(), which throws when the time service is not
running. That is the normal state in a fresh JVM (the main embedded
use case) or after an in-JVM server has been stopped.
Make TimeThread.getLocalTime() compute the timestamp on demand when
the time service is not running instead of throwing; it is the only
TimeThread accessor used by the text log publishers, and the other
accessors keep their strict lifecycle check.
Enable EmbeddedDirectoryServerTestCase.testSetupFromArchive in the
default build now that it passes.
@vharsekovharseko changed the title Fix embedded server setup failing with "Time service not started"[#696] Fix embedded server setup failing with "Time service not started"Jul 6, 2026
@vharseko
vharseko merged commit 452fd4f into OpenIdentityPlatform:masterJul 8, 2026
48 of 51 checks passed
@vharseko
vharseko deleted the features/embedded-setup-logging branch July 8, 2026 16:13
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants

@vharseko@maximthomas