Search code examples
intellij-ideawildflyjava-ee-7wildfly-18

Java EE 7 EJB Authentication using WildFly - security annotations don't work


I am trying to establish a security domain using wildfly 18.0.1. These are the settings I use:

standalone.xml:

<security-domain name="my-security-domain" cache-type="default">
    <authentication>
        <login-module code="UsersRoles" flag="required">
            <module-option name="usersProperties" value="users.properties"/>
            <module-option name="rolesProperties" value="roles.properties"/>
        </login-module>
    </authentication>
</security-domain>

I created user with add-user.bat and created files: users.properties and roles.properties filled with created user data.

IntelliJ doesnt's seem to recognize security annotations and I can't import them:

@Stateless
@WebService(name = "HelloWorldType", portName = "HelloWorldPort", targetNamespace = "https://soap.soa.pl/lab1/ws")
@SecurityDomain("my-security-domain") // in standalone.xml
@DeclareRoles({"MyRole"}) 
@WebContext(contextRoot="lab1", urlPattern="/HelloWorld", authMethod="BASIC", transportGuarantee="NONE")
@SOAPBinding(style=SOAPBinding.Style.DOCUMENT, use=SOAPBinding.Use.LITERAL)
public class HelloWorld {

    @WebMethod()
    @RolesAllowed("MyRole")
    public String sayHello(@WebParam(name = "message") String message) {
        return "Here is the message: '" + message + "'";
    }
}

Also, now I'm not able to start wildfly serwer:

18:49:25,854 INFO  [org.jboss.as] (MSC service thread 1-2) WFLYSRV0049: WildFly Full 18.0.1.Final (WildFly Core 10.0.3.Final) starting
18:49:26,643 INFO  [org.wildfly.security] (ServerService Thread Pool -- 25) ELY00001: WildFly Elytron version 1.10.4.Final
18:49:27,227 INFO  [org.jboss.as.controller.management-deprecated] (Controller Boot Thread) WFLYCTL0028: Attribute 'security-realm' in the resource at address '/core-service=management/management-interface=http-interface' is deprecated, and may be removed in a future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
18:49:27,256 INFO  [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 13) WFLYCTL0028: Attribute 'security-realm' in the resource at address '/subsystem=undertow/server=default-server/https-listener=https' is deprecated, and may be removed in a future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
18:49:27,321 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([("deployment" => "lab1-ear.ear")]) - failure description: "WFLYSRV0137: No deployment content with hash 5cddb572897ba715135a11fe8d8c7c56f30099b5 is available in the deployment content repository for deployment 'lab1-ear.ear'. This is a fatal boot error. To correct the problem, either restart with the --admin-only switch set and use the CLI to install the missing content or remove it from the configuration, or remove the deployment from the xml configuration file and restart."
18:49:27,326 FATAL [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0056: Server boot has failed in an unrecoverable manner; exiting. See previous messages for details.
18:49:27,337 INFO  [org.jboss.as] (MSC service thread 1-7) WFLYSRV0050: WildFly Full 18.0.1.Final (WildFly Core 10.0.3.Final) stopped in 7ms

I have no idea why, especially the annotations, don't work.. please help.


Solution

  • You need to locate the jar file providing these annotation classes and add it to the Module Dependencies.

    If your project is Gradle or Maven managed, add the dependency to build.gradle/pom.xml instead.