Search code examples
javaweb-servicesejbwildflyundertow

How to configure EJB WebServices in WildFly (in ear)


I have an EAR project, deployed on WildFly 10.1.0.Final This EAR consist of some jars and wars. I have a WebService in my jar file.

I can't understand clearly how to configurate my project. I spend a lot of time in google and debugger... so i need help )

My AIM: Set default AuthType/Security-domain for my EJB WebService in JAR on ear/server level.

For Security-domain i found configuration in:

  • Standalone.xml -> subsystem xmlns="urn:jboss:domain:ejb3:4.0 (server level, HIGHT priority) tag: subsystem xmlns="urn:jboss:domain:ejb3:4.0 scope: All EJB

  • Standalone.xml -> subsystem xmlns="urn:jboss:domain:undertow:3.0" (server level, Only for Undertow, HIGHT priority) attribute: default-security-domain (server level, medium priority) scope: All WebServices

  • In jboss-app.xml (Medium priority!) in EAR META-INF Example: https://developer.jboss.org/thread/177666 Scope: All EJB

  • XML file jboss-ejb3.xml in EAR child jar project (low priority) http://wildscribe.github.io/Wildfly/8.1.0.Final/subsystem/ejb3/index.html Scope: All EJB

  • Security domain annotation on WebService Class: Annotation: org.jboss.security.SecurityDomain Scope: Single WebService

Also, how can i understand - ejb properties more priority for ejb beans webservices than webservices properties

But how can i set default auth metod BASIC? Without annotation on the class. I cant find ( WEB-INF/web.xml and jboss-web.xml don't affect on my webservice.


Solution

  • Properties from web.xml work only for war deployments. I found only one way to configure ejb jar deployments with webservices (in one place for all endopoints and deployments).

    As we know, WildFly uses Undertow. We can define Servlet Extension: http://undertow.io/undertow-docs/undertow-docs-1.2.0/#servlet-extensions

    Add src/main/resources/META-INF/services/io.undertow.servlet.ServletExtension. Then, add in this file our UndertowDeploymentExtension (which implements ServletExtension).

    Then, add in the handleDeployment method something like: deploymentInfo.setLoginConfig( new LoginConfig( javax.servlet.http.HttpServletRequest.BASIC_AUTH, REALM_NAME) );

    Now, our jar deployments without LoginConfig will be initialized with our custom LoginConfig (and we can ommit @WebContext). For more information you can debug at WebMetaDataCreator.createLoginConfig (wildfly-webservices-server-integration-10.1.0.Final.jar)

    For quick preview: https://github.com/wildfly/wildfly/blob/master/webservices/server-integration/src/main/java/org/jboss/as/webservices/tomcat/WebMetaDataCreator.java#L276

    Also, you can read this suggestion from: http://lists.jboss.org/pipermail/undertow-dev/2016-December/001801.html