{"record":{"id":"fdc357cba03e0dc7","repo":"OpenAPITools/openapi-generator","slug":"flag-usejakartasecurityannotations-requires-use","errorCode":null,"errorMessage":"Flag 'useJakartaSecurityAnnotations' requires 'useJakartaEe=true'. The generated annotation '@jakarta.annotation.security.RolesAllowed' is incompatible with the javax.* namespace.","messagePattern":"Flag 'useJakartaSecurityAnnotations' requires 'useJakartaEe=true'\\. The generated annotation '@jakarta\\.annotation\\.security\\.RolesAllowed' is incompatible with the javax\\.\\* namespace\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaJAXRSSpecServerCodegen.java","lineNumber":239,"sourceCode":"            openApiSpecFileLocation = \"src/main/webapp/META-INF/openapi.yaml\";\n        }\n\n        additionalProperties.put(OPEN_API_SPEC_FILE_LOCATION, openApiSpecFileLocation);\n\n        if (interfaceOnly) {\n            // Change default artifactId if generating interfaces only, before command line options are applied in base class.\n            artifactId = \"openapi-jaxrs-client\";\n        }\n\n        super.processOpts();\n\n        // 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\n        if (QUARKUS_LIBRARY.equals(library)) {\n            convertPropertyToBooleanAndWriteBack(USE_JAKARTA_SECURITY_ANNOTATIONS, value -> useJakartaSecurityAnnotations = value);\n        }\n\n        if (useJakartaSecurityAnnotations && !useJakartaEe) {\n            throw new IllegalArgumentException(\n                    \"Flag '\" + USE_JAKARTA_SECURITY_ANNOTATIONS + \"' requires '\" + USE_JAKARTA_EE\n                            + \"=true'. The generated annotation '@jakarta.annotation.security.RolesAllowed' \"\n                            + \"is incompatible with the javax.* namespace.\");\n        }\n\n        // expose flags to templates\n        additionalProperties.put(USE_SWAGGER_ANNOTATIONS, useSwaggerAnnotations);\n        additionalProperties.put(USE_SWAGGER_V3_ANNOTATIONS, useSwaggerV3Annotations);\n        additionalProperties.put(USE_MICROPROFILE_OPENAPI_ANNOTATIONS, useMicroProfileOpenAPIAnnotations);\n\n        supportingFiles.clear(); // Don't need extra files provided by AbstractJAX-RS & Java Codegen\n        supportingFiles.add(new SupportingFile(\"README.mustache\", \"\", \"README.md\")\n                .doNotOverwrite());\n\n        if (!interfaceOnly) {\n            supportingFiles.add(new SupportingFile(\"RestResourceRoot.mustache\",\n                    (sourceFolder + '/' + invokerPackage).replace(\".\", \"/\"), \"RestResourceRoot.java\")\n                    .doNotOverwrite());","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaJAXRSSpecServerCodegen.java#L221-L257","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add useJakartaEe=true alongside the flag: --additional-properties useJakartaSecurityAnnotations=true,useJakartaEe=true","Or drop useJakartaSecurityAnnotations and keep javax-era @RolesAllowed handling in handwritten code","Verify your Quarkus major version: Quarkus 3+ implies jakarta namespace, so useJakartaEe=true is the correct pairing","Centralize the namespace decision in one config variable applied to all related flags"],"exampleFix":"# before\nopenapi-generator-cli generate -g jaxrs-jersey -i api.yaml --library quarkus \\\n  --additional-properties useJakartaSecurityAnnotations=true\n\n# after\nopenapi-generator-cli generate -g jaxrs-jersey -i api.yaml --library quarkus \\\n  --additional-properties useJakartaSecurityAnnotations=true,useJakartaEe=true","handlingStrategy":"validation","validationCode":"boolean securityAnn = Boolean.parseBoolean(String.valueOf(opts.getOrDefault(\"useJakartaSecurityAnnotations\", \"false\")));\nboolean jakartaEe = Boolean.parseBoolean(String.valueOf(opts.getOrDefault(\"useJakartaEe\", \"false\")));\nif (securityAnn && !jakartaEe) {\n    throw new IllegalArgumentException(\"useJakartaSecurityAnnotations requires useJakartaEe=true\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    generator.generate();\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"useJakartaEe\")) {\n        opts.put(\"useJakartaEe\", \"true\"); // safe auto-fix: jakarta namespace is required for the annotation\n        generator.generate();\n    } else throw e;\n}","preventionTips":["Treat useJakartaEe as the master switch: any jakarta-* option must assert it is true first","Keep Quarkus 3 / jakarta migrations as atomic config updates (namespace + annotations together)","Add unit tests over your option map asserting invariants like useJakartaSecurityAnnotations => useJakartaEe"],"tags":["java","jaxrs","quarkus","openapi-generator","jakarta-ee","security","annotations","configuration"],"backgroundTag":"requires-prerequisite-option","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}