quarkusio/quarkus · error · RuntimeException

More than one Application class: ${applications}

Error message

More than one Application class: ${applications}

What it means

During RESTEasy Reactive scanning, more than one class extending jakarta.ws.rs.core.Application was found in the application index. The JAX-RS spec allows only a single Application subclass per deployment, so the scanner aborts the build. The message lists all Application classes found.

Source

Thrown at independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/scanning/ResteasyReactiveScanner.java:92

    public static ApplicationScanningResult scanForApplicationClass(IndexView index, Set<String> excludedClasses) {
        Collection<ClassInfo> applications = index
                .getAllKnownSubclasses(ResteasyReactiveDotNames.APPLICATION);
        Set<String> allowedClasses = new HashSet<>();
        Set<String> singletonClasses = new HashSet<>();
        Set<String> globalNameBindings = new HashSet<>();
        boolean filterClasses = !excludedClasses.isEmpty();
        Application application = null;
        ClassInfo selectedAppClass = null;
        BlockingDefault blocking = BlockingDefault.AUTOMATIC;
        for (ClassInfo applicationClassInfo : applications) {
            if (Modifier.isAbstract(applicationClassInfo.flags())) {
                continue;
            }
            if (excludedClasses.contains(applicationClassInfo.name().toString())) {
                continue;
            }
            if (selectedAppClass != null) {
                throw new RuntimeException("More than one Application class: " + applications);
            }
            selectedAppClass = applicationClassInfo;
            if (appClassHasInject(selectedAppClass)) {
                throw new RuntimeException("'@Inject' cannot be used with a '" + ResteasyReactiveDotNames.APPLICATION
                        + "' class. Offending class is: '" + selectedAppClass.name() + "'");
            }
            String applicationClass = applicationClassInfo.name().toString();
            try {
                Class<?> appClass = Thread.currentThread().getContextClassLoader().loadClass(applicationClass);
                application = (Application) appClass.getConstructor().newInstance();
                Set<Class<?>> classes = application.getClasses();
                if (!classes.isEmpty()) {
                    for (Class<?> klass : classes) {
                        allowedClasses.add(klass.getName());
                    }
                    filterClasses = true;
                }
                classes = application.getSingletons().stream().map(Object::getClass).collect(Collectors.toSet());

View on GitHub (pinned to e1c734241f)

Solutions

  1. Delete or rename one of the Application subclasses so exactly one remains in the deployment.
  2. If one of the Applications comes from a dependency, exclude that dependency or add the unwanted class to the excluded classes set passed to scanForApplicationClass.
  3. Consolidate the two Application classes' registration logic (classes, singletons) into a single @ApplicationPath class.

Example fix

// before
class AppOne extends Application { ... }
class AppTwo extends Application { ... }
// after
class AppOne extends Application {
    @Override
    public Set<Class<?>> getClasses() {
        // merge resources previously in AppTwo here
    }
}
Defensive patterns

Strategy: validation

Validate before calling

// build-time check
List<String> apps = classIndex.getAllKnownSubclasses(Application.class)
        .stream().map(ci -> ci.name().toString()).collect(Collectors.toList());
if (apps.size() > 1)
    throw new IllegalStateException("Only one JAX-RS Application class allowed, found: " + apps);

Prevention

When it happens

Trigger: Calling ResteasyReactiveScanner.scanForApplicationClass when the indexed classes contain two or more subclasses of jakarta.ws.rs.core.Application (and neither is excluded).

Common situations: Copying an existing RestApplication class into a new package and forgetting to delete the original; adding a third-party JAX-RS module that ships its own Application subclass; code-generation leaving a stale generated Application class.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/713b6c2367f92ba5. Report an issue: GitHub.