简体   繁体   中英

Override context-param in web.xml in Jboss EAP 6.4 at deployment time

Goal - deploy project war on Jboss EAP 6.4 with new values provided for context-param parameters in web.xml without editing existing war.
Current status -

  • war works if i put required web.xml values at the time of build itself. But it fails when I use default web.xml.
  • default war works fine on Tomcat 9 as it has "XML Configuration file path" option available on manager console gui to override values of default web.xml.

My default web.xml -

<?xml version="1.0" encoding="utf-8"?><web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>Myproject Web Service</display-name>

<context-param>
    <param-name>myproject.appserver</param-name>
    <param-value>jbosseap</param-value>
</context-param>
<context-param>
    <param-name>myproject.logpath</param-name>
    <param-value></param-value>
</context-param>
<context-param>
    <param-name>myproject.dbtype</param-name>
    <param-value></param-value>
</context-param>

<listener>
    <listener-class>com.myproject.ApplicationStartListener</listener-class>
</listener>

<error-page>
    <error-code>404</error-code>
    <location>/pages//404ErrorView.html</location>
</error-page></web-app>

Required values as -

<context-param>
    <param-name>myproject.logpath</param-name>
    <param-value>D:\myproject\vXX\workspace</param-value>
</context-param>
<context-param>
    <param-name>myproject.dbtype</param-name>
    <param-value>MSSQL</param-value>
</context-param>

Troubleshoot -

  • no such way mentioned in Jboss EAP 6.4 official documentation.
  • no such option is available in Jboss EAP Admin Console ( http://localhost:9990/console/App.html#home ) like tomcat for deployment.
  • none of the SO answers for posts with similar issue helpful in my case.

Since we are shipping same war to customers so it is decided not to let customers edit the war and deploy.

If overriding at deployment time isnt at all possible then any official doc reference for such limitation would be helpful. Thank you.

Jboss EAP does not support context-param replacement like tomcat. But it does support content replacement for deployed WAR.
Solution - Replace web.xml using deployment-overlay command.
Official documentation
Hence at user end, web.xml template is required and user will have to put values for context-param as per their environment and re-deploy war.
war and web.xml must be inside \\bin. Else deployment-overlay command fails to recognize path.
Command sequence - Using jboss-cli.bat -

[standalone@localhost:9990 /] deploy s1temp/myproj.war
[standalone@localhost:9990 /] deployment-overlay add --name=s1overlay --content=WEB-INF/web.xml=s1temp/web.xml
[standalone@localhost:9990 /] deployment-overlay link --name=s1overlay --deployments=myproj.war --redeploy-affected

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM