OpenAPITools/openapi-generator · error · IllegalArgumentException

Flag 'useJakartaSecurityAnnotations' requires 'useJakartaEe=

Error message

Flag 'useJakartaSecurityAnnotations' requires 'useJakartaEe=true'. The generated annotation '@jakarta.annotation.security.RolesAllowed' is incompatible with the javax.* namespace.

What it means

Thrown by JavaJAXRSSpecServerCodegen.processOpts when useJakartaSecurityAnnotations=true but useJakartaEe is false. The flag makes templates emit @jakarta.annotation.security.RolesAllowed on generated resources; that annotation only compiles when the project uses the jakarta.* namespace, which is selected by useJakartaEe=true. With the default javax.* namespace the generated code would not compile, so generation aborts up front. The option itself is only read when library=quarkus.

Source

Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaJAXRSSpecServerCodegen.java:239

            openApiSpecFileLocation = "src/main/webapp/META-INF/openapi.yaml";
        }

        additionalProperties.put(OPEN_API_SPEC_FILE_LOCATION, openApiSpecFileLocation);

        if (interfaceOnly) {
            // Change default artifactId if generating interfaces only, before command line options are applied in base class.
            artifactId = "openapi-jaxrs-client";
        }

        super.processOpts();

        // We need to call super.processOpts() before evaluating the `library`, otherwise `library` is null when set via `configOptions` instead of via `library.set("quarkus")` in Gradle
        if (QUARKUS_LIBRARY.equals(library)) {
            convertPropertyToBooleanAndWriteBack(USE_JAKARTA_SECURITY_ANNOTATIONS, value -> useJakartaSecurityAnnotations = value);
        }

        if (useJakartaSecurityAnnotations && !useJakartaEe) {
            throw new IllegalArgumentException(
                    "Flag '" + USE_JAKARTA_SECURITY_ANNOTATIONS + "' requires '" + USE_JAKARTA_EE
                            + "=true'. The generated annotation '@jakarta.annotation.security.RolesAllowed' "
                            + "is incompatible with the javax.* namespace.");
        }

        // expose flags to templates
        additionalProperties.put(USE_SWAGGER_ANNOTATIONS, useSwaggerAnnotations);
        additionalProperties.put(USE_SWAGGER_V3_ANNOTATIONS, useSwaggerV3Annotations);
        additionalProperties.put(USE_MICROPROFILE_OPENAPI_ANNOTATIONS, useMicroProfileOpenAPIAnnotations);

        supportingFiles.clear(); // Don't need extra files provided by AbstractJAX-RS & Java Codegen
        supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")
                .doNotOverwrite());

        if (!interfaceOnly) {
            supportingFiles.add(new SupportingFile("RestResourceRoot.mustache",
                    (sourceFolder + '/' + invokerPackage).replace(".", "/"), "RestResourceRoot.java")
                    .doNotOverwrite());

View on GitHub (pinned to fcec517be3)

Solutions

  1. Add useJakartaEe=true alongside the flag: --additional-properties useJakartaSecurityAnnotations=true,useJakartaEe=true
  2. Or drop useJakartaSecurityAnnotations and keep javax-era @RolesAllowed handling in handwritten code
  3. Verify your Quarkus major version: Quarkus 3+ implies jakarta namespace, so useJakartaEe=true is the correct pairing
  4. Centralize the namespace decision in one config variable applied to all related flags

Example fix

# before
openapi-generator-cli generate -g jaxrs-jersey -i api.yaml --library quarkus \
  --additional-properties useJakartaSecurityAnnotations=true

# after
openapi-generator-cli generate -g jaxrs-jersey -i api.yaml --library quarkus \
  --additional-properties useJakartaSecurityAnnotations=true,useJakartaEe=true
Defensive patterns

Strategy: validation

Validate before calling

boolean securityAnn = Boolean.parseBoolean(String.valueOf(opts.getOrDefault("useJakartaSecurityAnnotations", "false")));
boolean jakartaEe = Boolean.parseBoolean(String.valueOf(opts.getOrDefault("useJakartaEe", "false")));
if (securityAnn && !jakartaEe) {
    throw new IllegalArgumentException("useJakartaSecurityAnnotations requires useJakartaEe=true");
}

Try / catch

try {
    generator.generate();
} catch (IllegalArgumentException e) {
    if (e.getMessage() != null && e.getMessage().contains("useJakartaEe")) {
        opts.put("useJakartaEe", "true"); // safe auto-fix: jakarta namespace is required for the annotation
        generator.generate();
    } else throw e;
}

Prevention

When it happens

Trigger: Running -g jaxrs-jersey --library quarkus with --additional-properties useJakartaSecurityAnnotations=true while useJakartaEe is absent/false (e.g. pinned to Quarkus 2.x-era settings). Config files from pre-Jakarta Quarkus projects that later add the security-annotation flag. CI presets that enable the annotation flag globally without the namespace flag.

Common situations: Upgrading Quarkus services to 3.x (Jakarta-based): devs add the new security annotation option but the base config still sets useJakartaEe=false or nothing. Mixed fleets where one shared config serves both javax and jakarta targets.

Related errors


AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22). Data as JSON: /api/errors/fdc357cba03e0dc7. Report an issue: GitHub.