apereo/cas · warning

Found a service definition

Error message

Found a service definition [{}] with a duplicate id [{}]. This will overwrite previous service definitions and is likely a configuration problem. Make sure all services have a unique id and try again.

What it means

BaseResourceBasedRegisteredServiceWatcher.LOG_SERVICE_DUPLICATE warns when two service definition files in the registry directory resolve to the same service id. The later-loaded definition overwrites the earlier one, which is almost always a misconfiguration; the consumer is used during load to flag duplicates.

Solutions

  1. List all service files and grep their ids; delete or correct the file containing the duplicate id.
  2. Give each service definition a unique numeric id (both in the filename and the JSON 'id' field).
  3. Reload the registry and confirm each service loads exactly once.

Example fix

// before: two files both with id 1001
1001-App.json {"id": 1001, ...}
1001-AppCopy.json {"id": 1001, ...}
// after
1001-App.json {"id": 1001, ...}
1002-AppCopy.json {"id": 1002, ...}
Defensive patterns

Strategy: validation

Validate before calling

# Shell: detect duplicate ids across service files before startup
grep -h '"id"' /etc/cas/config/services/*.json \
  | sort | uniq -d && echo 'DUPLICATE IDS FOUND' && exit 1

Prevention

When it happens

Trigger: Two JSON files in the services directory both containing "id": 1001 (e.g. an old file plus a renamed copy) while the registry loads and deduplicates; load() detects the same id twice and applies LOG_SERVICE_DUPLICATE.

Common situations: Copying a service file to make a variant but forgetting to change its internal id; leftover files from upgrades/migrations; filename id and internal JSON id disagreeing.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


AI-assisted analysis of apereo/cas@e7288fc434 (2026-09-08). Data as JSON: /api/errors/e7eb976260cd3926. Report an issue: GitHub.

Appendix: source

Thrown at core/cas-server-core-services-registry/src/main/java/org/apereo/cas/services/resource/BaseResourceBasedRegisteredServiceWatcher.java:23

import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jooq.lambda.fi.util.function.CheckedConsumer;

/**
 * This is {@link BaseResourceBasedRegisteredServiceWatcher}.
 *
 * @author Misagh Moayyed
 * @since 5.2.0
 */
@Slf4j
@RequiredArgsConstructor(access = AccessLevel.PROTECTED)
public abstract class BaseResourceBasedRegisteredServiceWatcher implements CheckedConsumer<File> {
    /**
     * Consumer to log warnings for duplicate service defns.
     */
    static final Consumer<RegisteredService> LOG_SERVICE_DUPLICATE =
        service -> LOGGER.warn("Found a service definition [{}] with a duplicate id [{}]. "
                               + "This will overwrite previous service definitions and is likely a configuration problem. "
                               + "Make sure all services have a unique id and try again.", service.getServiceId(), service.getId());

    /**
     * Service registry instance.
     */
    protected final AbstractResourceBasedServiceRegistry serviceRegistryDao;

    @Override
    public void accept(final File file) {
    }
}

View on GitHub (pinned to e7288fc434)