gradle/gradle · error · UnknownServiceException
No service of type %s available.
Error message
No service of type %s available.
What it means
DefaultTransform wraps a service registry scoped to the transform; its get(Type) throws UnknownServiceException 'No service of type ... available.' when no service of the requested type is registered in the transform's isolated scope or its delegate. Artifact transforms run in isolation and only see services explicitly provided to them, so lookups of application/project services fail.
Source
Thrown at platforms/software/dependency-management/src/main/java/org/gradle/api/internal/artifacts/transform/DefaultTransform.java:482
}
return null;
}
@Nullable
@Override
public Object find(Type serviceType) throws ServiceLookupException {
Object result = find(serviceType, null);
if (result != null) {
return result;
}
return delegate.find(serviceType);
}
@Override
public Object get(Type serviceType) throws UnknownServiceException, ServiceLookupException {
Object result = find(serviceType);
if (result == null) {
throw new UnknownServiceException(serviceType, "No service of type " + serviceType + " available.");
}
return result;
}
@Override
public Object get(Type serviceType, Class<? extends Annotation> annotatedWith) throws UnknownServiceException, ServiceLookupException {
Object result = find(serviceType, annotatedWith);
if (result != null) {
return result;
}
return delegate.get(serviceType, annotatedWith);
}
private static class InjectionPoint {
private final Class<? extends Annotation> annotation;
private final Type injectedType;
private final Supplier<Object> valueToInject;
View on GitHub (pinned to 534f27719b)
Solutions
- Move the service-dependent work outside the transform and pass its results in through transform parameters.
- Use only services documented for transforms (e.g. ObjectFactory via getParameters() patterns) and express configuration through parameters.
- If a service genuinely belongs to the transform, register it as part of the transform's registration/parameters rather than looking it up at runtime.
Example fix
// before: transform looks up an application-scoped service
class MyTransform extends ArtifactTransform {
void transform(File input) {
def svc = registry.get(CustomIndexer) // UnknownServiceException in transform scope
}
}
// after: do the work outside, pass data via parameters
abstract class MyParams implements TransformParameters {
abstract Property<String> getIndexLocation()
}
// compute index location before registration, set it in parameters { } Defensive patterns
Strategy: try-catch
Try / catch
try {
def svc = registry.get(MyService)
} catch (org.gradle.internal.service.UnknownServiceException e) {
// service not available in transform scope: pass its data via transform parameters instead
throw e
} Prevention
- Do not look up application/project services inside artifact transforms.
- Pass all transform inputs through parameters.
- Run transforms with only the documented transform-scope services.
When it happens
Trigger: Code executing inside an ArtifactTransform calling a service locator get() for a type not registered in the transform scope — e.g. project-level singletons, custom application services, or services never passed into the transform registration.
Common situations: Porting code that used build services or application services into an artifact transform; custom transforms trying to reach internal APIs; worker isolation surfacing previously hidden coupling.
Related errors
- Inheriting from %s is not allowed. Use ServiceRegistryBuilde
- Service registry %s cannot be used as a parent for another s
- Cannot use decorator method %s.%s() when no parent registry
- Cannot configure services using %s.%s() as required service
- Could not configure services using %s.%s().
AI-assisted analysis of gradle/gradle@534f27719b (2026-08-22).
Data as JSON: /api/errors/d0a7ec8676d5333a.
Report an issue: GitHub.