Search code examples
jakarta-eewildflyweb.xmljaas

Cannot resolve security role


IntelliJ is telling me that it

Cannot resolve security role

I'm pretty sure I had to put the roles in another file as well as in web.xml but I can't find much info on that. maybe hboss-web.xml ?

<security-constraint>
    <web-resource-collection>
        <web-resource-name>Secure Pages</web-resource-name>
        <description/>
        <url-pattern>/u/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>USER</role-name>
        <role-name>ADMIN</role-name>
    </auth-constraint>
</security-constraint>

I'm new on intelliJ so maybe I'm misunderstanding something.


Solution

  • You need to declare the security roles that you reference in your web.xml (or application.xml if using an EAR based deployment):

    <web-app ...>
       ...   
       <security-role>
         <role-name>USER</role-name>
       </security-role>
       <security-role>
         <role-name>ADMIN</role-name>
       </security-role>
       ...
    </web-app>