quarkusio/quarkus · error · IllegalArgumentException
Unknown resource type ${resource.getType()}
Error message
Unknown resource type ${resource.getType()} What it means
During code generation, the Deployer iterates generated resources and writes each based on its ResourceType (class vs service provider). An unknown enum value hits the default branch and throws IllegalArgumentException. This should be impossible with standard enum values and indicates an unexpected/evolved ResourceType.
Source
Thrown at independent-projects/arc/tcks/arquillian/src/main/java/io/quarkus/arc/arquillian/Deployer.java:161
// make the test class a bean
ctx.transform().add(ExtraBean.class).done();
}
if (additionalClasses.contains(ctx.getTarget().asClass().name().toString())) {
// make all the `@Discovery`-registered classes beans
ctx.transform().add(ExtraBean.class).done();
}
}
})
.setOutput(resource -> {
switch (resource.getType()) {
case JAVA_CLASS:
resource.writeTo(deploymentDir.generatedClasses.toFile());
break;
case SERVICE_PROVIDER:
resource.writeTo(deploymentDir.generatedServices.toFile());
break;
default:
throw new IllegalArgumentException("Unknown resource type " + resource.getType());
}
})
.build();
beanProcessor.process();
}
}
private Index buildApplicationIndex() throws IOException {
Indexer indexer = new Indexer();
try (Stream<Path> appClasses = Files.walk(deploymentDir.appClasses)) {
List<Path> classFiles = appClasses.filter(it -> it.toString().endsWith(".class")).collect(Collectors.toList());
for (Path classFile : classFiles) {
try (InputStream in = Files.newInputStream(classFile)) {
indexer.index(in);
}
}
}
try (Stream<Path> appLibraries = Files.walk(deploymentDir.appLibraries)) {View on GitHub (pinned to e1c734241f)
Solutions
- Use matching versions of the ArC processor and the arquillian TCK support so enum constants line up.
- Add a case for the new ResourceType (e.g. generated sources) in Deployer.generate().
- Check for a dependency mismatch (older/newer quarkus-arc jar on the classpath).
Example fix
// before case SERVICE_PROVIDER: resource.writeTo(deploymentDir.generatedServices.toFile()); break; default: throw new IllegalArgumentException(...); // after case SERVICE_PROVIDER: resource.writeTo(deploymentDir.generatedServices.toFile()); break; case SOURCE: resource.writeTo(deploymentDir.generatedSources.toFile()); break; // new type handled default: throw new IllegalArgumentException(...);
Defensive patterns
Strategy: type-guard
Validate before calling
ResourceType type = resource.getType();
if (type != ResourceType.CLASS && type != ResourceType.SERVICE_PROVIDER) {
throw new IllegalStateException("Unexpected resource type: " + type);
} Type guard
static boolean isKnownResourceType(GeneratedResource r) {
return r.getType() == ResourceType.CLASS || r.getType() == ResourceType.SERVICE_PROVIDER;
} Try / catch
try {
generate();
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Unknown resource type")) {
throw new IllegalStateException("ArC version mismatch: unknown ResourceType", e);
}
throw e;
} Prevention
- Keep quarkus-arc processor and arquillian support versions aligned.
- Handle new ResourceType constants when upgrading ArC.
When it happens
Trigger: generate() (invoked from deploy) switches over resource.getType() and encounters a ResourceType value other than CLASS or SERVICE_PROVIDER.
Common situations: A newly added enum constant in a newer version of the ArC processor not matched by the TCK deployer's switch, or a custom/foreign resource type injected into the generation pipeline.
Related errors
- Converting to ${toFormat} is not supported
- Could not find registered EnumDefinition for ${name}
- Quarkus code generation phase has failed
- Failed to generate sources in the QuarkusGenerateCode task f
- Unexpected value: <arcConfig.optimizeContexts()>
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/a50a0bb2e8ae73cc.
Report an issue: GitHub.