Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
like image 471
Dave A Avatar asked Aug 03 '15 19:08

Dave A


1 Answers

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.

like image 119
CoolBeans Avatar answered Sep 18 '22 10:09

CoolBeans