wildflyjboss-web

WildFly: How to separate web applications?


I have 2 web interfaces of a JEE application on WildFly 15. Both have different SSL certificates. And they also have different REST methods / URLs. And client shouldn't be able to see / access the respective other methods.

Having different SSL certificates on different ports by adding additional HTTPS listener was no problem at all. But now I'm struggling with the separation of the web applications.

You can use different virtual hosts by defining them in the jboss-web.xml you ship with your web application. But you can't define HTTP and HTTPS listeners on a virtual host in the WildFly configuration (in my case specifically in the standalone-full.xml). You have to add another (web) server for being able to do so. That also works so far.

So I have defined the virtual host of my 2nd (web) server in the jboss-web.xml. But I can't deploy the web application as I always get an error that WildFly can't find the virtual server:

2019-02-12 15:06:07,930 ERROR [org.jboss.as.controller.management-operation] (External Management Request Threads -- 1) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "myapp-ear-1.0.4.ear")]) - failure description: {
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.undertow.server.default-server.myapp-host"],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => [
        "jboss.deployment.subunit.\"myapp-ear-1.0.4.ear\".\"myapp-web-1.0.4.war\".undertow-deployment.UndertowDeploymentInfoService is missing [jboss.undertow.server.default-server.myapp-host]",
        "jboss.deployment.subunit.\"myapp-ear-1.0.4.ear\".\"myapp-web-1.0.4.war\".undertow-deployment is missing [jboss.undertow.server.default-server.myapp-host]"
    ]
}
2019-02-12 15:06:07,931 ERROR [org.jboss.as.server] (External Management Request Threads -- 1) WFLYSRV0021: Deploy of deployment "myapp-ear-1.0.4.ear" was rolled back with the following failure message: 
{
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.undertow.server.default-server.myapp-host"],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => [
        "jboss.deployment.subunit.\"myapp-ear-1.0.4.ear\".\"myapp-web-1.0.4.war\".undertow-deployment.UndertowDeploymentInfoService is missing [jboss.undertow.server.default-server.myapp-host]",
        "jboss.deployment.subunit.\"myapp-ear-1.0.4.ear\".\"myapp-web-1.0.4.war\".undertow-deployment is missing [jboss.undertow.server.default-server.myapp-host]"
    ]
}

Of course there is no "myapp-host" in the "default-server" web server. It is in the "myapp-server". But I can't define that in the jboss-web.xml:

<jboss-web>
    <virtual-host>myapp-host</virtual-host>
</jboss-web>

Does anyone have any idea?

EDIT:

As NikosParaskevopoulos pointed out: There is an additional parameter . So the whole thing (jboss-web.xml) should look like this:

<jboss-web>
    <server-instance>myapp-server</server-instance>
    <virtual-host>myapp-host</virtual-host>
</jboss-web>

I've tested it and it works perfectly. Thanks NikosParaskevopoulos.


Solution

  • From the JBoss/WildFly documentation, there is the <server-instance> element that:

    [...] specifies which server instance configuration this application belongs to

    So, change the jboss-web.xml to:

    <jboss-web>
        <virtual-host>myapp-host</virtual-host>
        <server-instance>myapp-server</server-instance>
    </jboss-web>
    

    By the way, the XSDs and DTDs for ALL WildFly configuration XMLs can be found in the WildFly distribution under docs/schema. They contain enough documentation, I find them very helpful.