How to add an external resources directory with jboss-cli?

跟風遠走 提交于 2019-12-23 04:10:14

问题


I would like to add ${jboss.server.temp.dir}/foo_server/images_svg directory as external resources directory.

For this I need to add the following line code into /subsystem/handlers

<location name="/images_svg" handler="images"/>

And into /subsystem/server name="default-server"/host name="default-host"

<file name="images" path="${jboss.server.temp.dir}/foos_server/images_svg" directory-listing="true"/>

I expect something like this:

<subsystem xmlns="urn:jboss:domain:undertow:2.0">
            <buffer-cache name="default"/>
            <server name="default-server">
                <http-listener name="default" socket-binding="http" redirect-socket="https"/>
                <host name="default-host" alias="localhost">
                    <location name="/images_svg" handler="images"/>
                    <filter-ref name="server-header"/>
                    <filter-ref name="x-powered-by-header"/>
                </host>
            </server>
            <servlet-container name="default">
                <jsp-config/>
                <websockets/>
            </servlet-container>
            <handlers>
                <file name="images" path="${jboss.server.temp.dir}/foo_server/images_svg" directory-listing="true"/>
            </handlers>
            <filters>
                <response-header name="server-header" header-name="Server" header-value="WildFly/9"/>
                <response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
            </filters>
    </subsystem>

How to do it from jboss-cli command line ?

I tried:

/subsystem=undertow/server=default-server/host=default-host/location="/images_svg":write-attribute(name="handler",value="images")
{
    "outcome" => "failed",
    "failure-description" => "WFLYCTL0216: Management resource '[
    (\"subsystem\" => \"undertow\"),
    (\"server\" => \"default-server\"),
    (\"host\" => \"default-host\"),
    (\"location\" => \"/images_svg\")
]' not found",
    "rolled-back" => true
}

And

/subsystem=undertow/server=default-server/host=default-host/location="/images_svg":add(handler="images")
16:02:43,851 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 27) WFLYCTL0013: Operation ("add") failed - address: ([
    ("subsystem" => "undertow"),
    ("server" => "default-server"),
    ("host" => "default-host"),
    ("location" => "/images_svg")
]) - failure description: {"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.undertow.server.default-server.default-host.location./images_svg is missing [jboss.undertow.handler.images]"]}
{
    "outcome" => "failed",
    "failure-description" => {"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.undertow.server.default-server.default-host.location./images_svg is missing [jboss.undertow.handler.images]"]},
    "rolled-back" => true
}

regards


回答1:


Try the following

Handler images:

/subsystem=undertow/configuration=handler/file=images:add(path="${jboss.server.temp.dir}/images_svg", directory-listing="true")

Location /images_svg

/subsystem=undertow/server=default-server/host=default-host/location="/images_svg":add(handler="images")


来源:https://stackoverflow.com/questions/31678560/how-to-add-an-external-resources-directory-with-jboss-cli

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!