pinpoint-apm/pinpoint · error · java.lang.IllegalStateException
duplicated ServiceType ${serviceType} / ${duplicated}
Error message
duplicated ServiceType ${serviceType} / ${duplicated} What it means
ServiceTypeRegistry.buildNameLookupTable builds a name-to-ServiceType map during registry construction. Since HashMap.put returns the previous value, any two ServiceTypes sharing the same name cause an immediate IllegalStateException — service type names must be unique identifiers in Pinpoint. This runs in the constructor, so the registry can never be created while a name collision exists.
Source
Thrown at commons-profiler/src/main/java/com/navercorp/pinpoint/common/profiler/trace/ServiceTypeRegistry.java:58
private final Map<String, ServiceType> nameLookupTable;
private final Map<String, List<ServiceType>> descLookupTable;
private ServiceTypeRegistry(Map<Integer, ServiceType> buildMap) {
Objects.requireNonNull(buildMap, "buildMap");
this.codeLookupTable = IntHashMapUtils.copy(buildMap);
this.nameLookupTable = buildNameLookupTable(buildMap.values());
this.descLookupTable = buildDescLookupTable(buildMap.values());
}
private Map<String, ServiceType> buildNameLookupTable(Collection<ServiceType> serviceTypes) {
final Map<String, ServiceType> copy = new HashMap<>();
for (ServiceType serviceType : serviceTypes) {
final ServiceType duplicated = copy.put(serviceType.getName(), serviceType);
if (duplicated != null) {
throw new IllegalStateException("duplicated ServiceType " + serviceType + " / " + duplicated);
}
}
return copy;
}
@Override
public ServiceType findServiceType(int code) {
final ServiceType serviceType = this.codeLookupTable.get(code);
if (serviceType == null) {
return ServiceType.UNDEFINED;
}
return serviceType;
}
@Override
public ServiceType findServiceTypeByName(String name) {
final ServiceType serviceType = this.nameLookupTable.get(name);
if (serviceType == null) {View on GitHub (pinned to 744c3d3075)
Solutions
- Rename one of the conflicting ServiceTypes so names are unique
- Check the message's 'duplicated' part to see which existing type owns the name
- Remove duplicate plugin registrations / duplicate type descriptor entries from the classpath
- Use a distinct, descriptive name in the custom plugin's ServiceTypeDescriptor
Example fix
// before ServiceType MY_APP = new ServiceType(1200, "TOMCAT"); // name collides // after ServiceType MY_APP = new ServiceType(1200, "MY_TOMCAT_APP");
Defensive patterns
Strategy: validation
Validate before calling
Set<String> seen = new HashSet<>();
for (ServiceType st : serviceTypes) {
if (!seen.add(st.getName())) {
throw new IllegalStateException("duplicate ServiceType name: " + st.getName());
}
}
ServiceTypeRegistry registry = new ServiceTypeRegistry(serviceTypes); Try / catch
try {
ServiceTypeRegistry registry = new ServiceTypeRegistry(serviceTypes);
} catch (IllegalStateException e) {
LOGGER.error("service type name collision: {}", e.getMessage());
} Prevention
- Give custom service types unique, prefixed names (e.g. MYCOMPANY_APP)
- Avoid loading the same plugin jar twice
- Compare against built-in ServiceType names before naming a custom type
When it happens
Trigger: Constructing a ServiceTypeRegistry (or its builder path via createServiceTypeRegistry) with a collection containing two ServiceTypes with identical getName() values — typically a custom service type reusing a built-in name like 'TOMCAT' or two custom types with the same name.
Common situations: Custom plugin type descriptor files (type-provider.yml / ServiceType descriptors) that copy a built-in name; loading the same plugin twice so its types are registered twice; merging plugin lists where names overlap across plugins.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- already exist. serviceType:${serviceType}, exist:${exist}
- already exist. annotationKey:${annotationKey}, exist:${exist
- NoSuchElementException
- Duplicate ColumnFamily name :
- Corrupted schema change logs. Duplicate order for change set
AI-assisted analysis of pinpoint-apm/pinpoint@744c3d3075 (2026-09-07).
Data as JSON: /api/errors/36ac63e9cb71b004.
Report an issue: GitHub.