How do I enable on-the-fly compilation of JSPs in Wildfly 9?

心已入冬 提交于 2021-02-19 01:15:24

问题


I’m using Wildfly 9.0.0.CR2. How do I enable on-the-fly compilation of JSPs? I found this configuration in another thread

    <subsystem xmlns="urn:jboss:domain:web:1.4" default-virtual-server="default-host" native="false">
        <configuration>
            <jsp-configuration development="true" check-interval="1" modification-test-interval="1" recompile-on-fail="true"/>
        </configuration>
    </subsystem>

but alas, it doesn’t work, result in gin the below exception when I restart my JBoss server …

    14:23:05,224 ERROR [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0055: Caught exception during boot: org.jboss.as.controller.persistence.ConfigurationPersistenceException: WFLYCTL0085: Failed to parse configuration
        at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:131)
        at org.jboss.as.server.ServerService.boot(ServerService.java:350)
        at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:271)
        at java.lang.Thread.run(Thread.java:745)
    Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[442,2]
Message: Unexpected element '{urn:jboss:domain:web:1.4}subsystem'
        at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:108)
        at org.jboss.staxmapper.XMLExtendedStreamReaderImpl.handleAny(XMLExtendedStreamReaderImpl.java:69)
        at org.jboss.as.server.parsing.StandaloneXml.parseServerProfile(StandaloneXml.java:1199)
        at org.jboss.as.server.parsing.StandaloneXml.readServerElement_1_4(StandaloneXml.java:457)
        at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:144)
        at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:106)
        at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110)
        at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:69)
        at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:123)
        ... 3 more

回答1:


This is a XML parsing issue as evident by this error message javax.xml.stream.XMLStreamException: ParseError. The parsing failed for this particular line Unexpected element{urn:jboss:domain:web:1.4}subsystem.

You can look at the XML schema documents to figure out these types of XML parsing issues. The schemas are located under the docs folder of WildFly.

By the way you should use WildFly-9.0.1.Final build version as that is the latest release candidate build.

You will most likely need to make the changes to the undertow subsystem. I have updated an example below:

 <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="/" handler="welcome-content"/>
                    <filter-ref name="server-header"/>
                    <filter-ref name="x-powered-by-header"/>
                </host>
            </server>
            <servlet-container name="default">
                <jsp-config development="true" check-interval="1" modification-test-interval="1" recompile-on-fail="true"/>
                <websockets/>
            </servlet-container>
            <handlers>
                <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
            </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>

I highly recommend using CLI to make such changes:

/subsystem=undertow/servlet-container=default/setting=jsp:write-attribute(name=development,value=true)
/subsystem=undertow/servlet-container=default/setting=jsp:write-attribute(name=recompile-on-fail,value=true)
/subsystem=undertow/servlet-container=default/setting=jsp:write-attribute(name=check-interval,value=1)
/subsystem=undertow/servlet-container=default/setting=jsp:write-attribute(name=modification-test-interval,value=1)

This way you can avoid these XML parsing errors without having to find the exact XML schemas.




回答2:


Search subsystem and add this on jsp config

<subsystem xmlns="urn:jboss:domain:undertow:1.1"><br>. . . .<br>   <servlet-container name="default" default-buffer-cache="default" stack-trace-on-error="local-only">
   <jsp-config development="true" check-interval="1" modification-test-interval="1" recompile-on-fail="true"/>





回答3:


Make sure you are loading the undertow extension. Otherwise the subsystem configuration can't load. Other than that your syntax is correct.

<extensions>
    <!-- other extensions here -->
    <extension module="org.wildfly.extension.undertow"/>
</extensions>


来源:https://stackoverflow.com/questions/31795274/how-do-i-enable-on-the-fly-compilation-of-jsps-in-wildfly-9

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