This discussion is archived
7 Replies Latest reply: Nov 5, 2013 3:57 AM by Jan Vervecken RSS

deploy given EAR file having application.xml and change context-root

Jan Vervecken Journeyer
Currently Being Moderated
hi

Please consider deploying a given EAR file on WebLogic Server 10.3.5 (part of JDeveloper 11.1.1.6.0) and changing the context-root for its web-module.

For example an EAR file with only a web-module (ReviewContextRootFirstApp.ear [1]) or an EAR file with a web-module and an ejb-module (ReviewContextRootSecondApp.ear [2]).

Given documentation appendix B section "context-root" [3] saying
"... A context-root setting in application.xml takes precedence over context-root setting in weblogic.xml. ..."

and documentation section "Typical Deployment Configuration Workflows" [4] saying
"Oracle does not support using a deployment plan to change the context-root in an application.xml file. However, if an application is deployed as a library, you can either change the context-root through an weblogic-application.xml file or use the deployment plan to change the context-root in an weblogic-application.xml file. "

Some observed behaviour:

- scenario (sc1) : deploy ReviewContextRootFirstApp.ear without deployment plan, results in context-root "/rcrfaweb" (as in application.xml)
- scenario (sc2) : deploy ReviewContextRootFirstApp.ear with deployment plan fa-plan.xml (tries to configure "/rcrfaweb11"), results in context-root "/rcrfaweb" (as in application.xml)

- scenario (sc3) : deploy ReviewContextRootSecondApp.ear without deployment plan, results in context-root "/rcrsaweb" (as in application.xml)
- scenario (sc4) : deploy ReviewContextRootSecondApp.ear with deployment plan sa-plan.xml (tries to configure "/rcrsaweb21"), results in context-root "/rcrsaweb" (as in application.xml)

The blog post "Defining the context root of a web application in Oracle WebLogic server" [5] by Silviu Leahu in its section "Defining the context root in deployment plan" suggests to
"Remove the META-INF/application.xml DD from the EAR"

- scenario (sc5) : remove application.xml from ReviewContextRootFirstApp.ear (e.g. using Ant target "remove.application.xml.from.ear") and deploy with deployment plan fa-plan.xml, results in context-root "/rcrfaweb11" (as in fa-plan.xml)
- scenario (sc6) : remove application.xml from ReviewContextRootSecondApp.ear (e.g. using Ant target "remove.application.xml.from.ear") and deploy with deployment plan sa-plan.xml, results in context-root "/rcrsaweb21" (as in sa-plan.xml)

One could expect that using a deployment plan (like in scenario's (sc2) and (sc4)) would allow to configure/change the context-root, whithout having to make changes to the EAR file to make this possible. (Somewhat like "Figure 4-2 Single Deployment Plan Workflow")
Only in scenario's (sc5) and (sc6) I see something close to what I would like to achieve, but there the application.xml file has been removed from the EAR file.

So ...
- (q1) Is it impossible to change the context-root at deploy-time for a web-module in a given EAR file that includes an application.xml file, without changing the EAR file?
- (q2) Is working with EAR files that don't have an application.xml file a supported approach (to change the context-root at deploy-time)?

Seems like a simple goal, but I must be missing something that is required to achieve it.

- [1] ReviewContextRootFirstApp/deploy/ReviewContextRootFirstApp.ear in the ZIP file
at http://www.consideringred.com/files/oracle/2012/ReviewContextRootApps-v0.01.zip
- [2] ReviewContextRootSecondApp/deploy/ReviewContextRootSecondApp.ear in the (same) ZIP file
at http://www.consideringred.com/files/oracle/2012/ReviewContextRootApps-v0.01.zip
- [3] http://docs.oracle.com/cd/E21764_01/web.1111/e13712/weblogic_xml.htm#WBAPP623
- [4] http://docs.oracle.com/cd/E21764_01/web.1111/e13702/config.htm#DEPGD172
- [5] http://blog.leahu.net/it/2011/01/04/defining-the-context-root-of-a-web-application-in-oracle-weblogic-server/

many thanks
Jan Vervecken
  • 1. Re: deploy given EAR file having application.xml and change context-root
    Jan Vervecken Journeyer
    Currently Being Moderated
    fyi

    In the context of Oracle service request 3-6481085041 I got this feedback:

    - about (q2)
    -- I got confirmation that "... it is supported to deploy an ear without application.xml ...".

    - about (q1)
    -- I got this URL : https://blogs.oracle.com/jamesbayer/entry/11gr1_update_and_a_deployment
    Yes, that blog post seems to describe what I am looking for.
    The blog post seems to confirm that it sould be possible to change the context-root at deploy-time for a web-module in a given EAR file (that includes an application.xml file ??), without changing the EAR file.
    It seems to match what I tried in scenario's (sc2) and (sc4) but it does not work.

    regards
    Jan
  • 2. Re: deploy given EAR file having application.xml and change context-root
    RenévanWijk Oracle ACE
    Currently Being Moderated

    You can use deployment plans in order to change the context-root, for example,

    <application 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/application_6.xsd" version="6">     <module id="Model">         <ejb>Model.jar</ejb>     </module>     <module id="Web">         <web>             <web-uri>Web.war</web-uri>             <context-root>LoadTest6</context-root>         </web>     </module> </application>

    Now the application can be reached at http://hostname:port/LoadTest6/someservlet. In order to change the context-root we can use, for example

    <deployment-plan xmlns="http://xmlns.oracle.com/weblogic/deployment-plan" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/deployment-plan http://xmlns.oracle.com/weblogic/deployment-plan/1.0/deployment-plan.xsd" global-variables="false"> <application-name>LoadTest6</application-name> <variable-definition> <variable> <name>context-root-name</name> <value>test</value> </variable> </variable-definition> <module-override> <module-name>LoadTest6.ear</module-name> <module-type>ear</module-type> ... <module-descriptor external="false"> <root-element>application</root-element> <uri>META-INF/application.xml</uri> <variable-assignment> <name>context-root-name</name> <xpath>/application/module[id="Web"]/web/context-root</xpath> </variable-assignment> </module-descriptor> ... </module-override> <module-override> <module-name>Model.jar</module-name> <module-type>ejb</module-type> ... </module-override> <module-override> <module-name>Web.war</module-name> <module-type>war</module-type> ... </module-override> <config-root>...</config-root> </deployment-plan>

    First, you have to define a variable name (in the example above context-root-name, note that it can be anything you like) and assign a value to it. Next, you have to use a variable assignment in the right part of the deployment plan (in this case the application.xml). By using an xpath expression, you can define which part of the xml has to be changed.

    With everything in place, redeploy (or deploy the application).

    See also here - Middleware Snippets: Using Deployment Plans to Change Application Deployments

  • 3. Re: deploy given EAR file having application.xml and change context-root
    Jan Vervecken Journeyer
    Currently Being Moderated
    Thanks for your reply René van Wijk.
    René van Wijk wrote:
    You can use deployment plans in order to change the context-root ...
    That is what I tried and describe in scenario's (sc2), (sc4), (sc5) and (sc6) in this forum thread.

    Because the application.xml file (in the "given EAR file"), added by JDeveloper 11.1.1.6.0 when deploying to an EAR file, doesn't have id attributes on its application/module elements, I first tried a different XPath expression:
    "/application/module/web[web-uri/text()="WebProject.war"]/context-root"
    But, that didn't work.

    Although the "given EAR file" does not have the suggested id attributes, I tried adding a deployment descriptor application.xml file that does have such id attributes [2], allowing an XPath expression like the one suggested:
    "/application/module[id="WebProject"]/web/context-root"

    - scenario (sc7) : deploy ReviewContextRootFirstApp.ear (in ReviewContextRootApps-v0.02.zip) with deployment plan fa-plan-application-xml-with-id.xml (tries to configure "/rcrfaweb14"), results in context-root "/rcrfaweb" (as in application.xml)
    - scenario (sc8) : deploy ReviewContextRootSecondApp.ear (in ReviewContextRootApps-v0.02.zip) with deployment plan sa-plan-application-xml-with-id.xml (tries to configure "/rcrsaweb24"), results in context-root "/rcrsaweb" (as in application.xml)

    So, it does not seem to work.
    ... you have to use a variable assignment in the right part of the deployment plan (in this case the application.xml) ...
    My observations I describe above (that it does not seem to work) seem to confirm the Oracle documentation [1] I referred to in this forum thread before:
    "Oracle does not support using a deployment plan to change the context-root in an application.xml file. ... "
    ... By using an xpath expression, you can define which part of the xml has to be changed. ...
    The values for the deployment-plan xpath elements seem to be "peculiar".
    Although it should not be a problem in an XPath expression, using single quotes (like module[id='WebProject'] ) instead of double quotes (like module[id="WebProject"] ) results in:
    "java.lang.AssertionError: Attributes must be defined as name value pairs, eg, name="value" -- [id='WebProject']"
    Because an XPath predicate expression would use an "@" to refer to an attribute, I also tried to replace what you suggested module[id="Web"] with something like module[@id="Web"] but that also did not make a difference.

    - [1] http://docs.oracle.com/cd/E21764_01/web.1111/e13702/config.htm#DEPGD172
    - [2] http://www.consideringred.com/files/oracle/2012/ReviewContextRootApps-v0.02.zip

    regards
    Jan Vervecken
  • 4. Re: deploy given EAR file having application.xml and change context-root
    RenévanWijk Oracle ACE
    Currently Being Moderated
    https://www.dropbox.com/sh/f5orcs55g7j57oj/hkH-itMRLn/temp/loadtest.zip

    contains the zip of the example presented above in order to test the set-up (so yeah it works).

    The application is deployed by using the app/plan directory structure. In this manner the deployment plan is automatically picked-up when the application is deployed.
  • 5. Re: deploy given EAR file having application.xml and change context-root
    Jan Vervecken Journeyer
    Currently Being Moderated
    Thanks for your reply René van Wijk.

    Thank you for making your file "loadtest.zip" available.

    As I wrote in the initial post of this forum thread, I have been using WebLogic Server 10.3.5 (part of JDeveloper 11.1.1.6.0) for this.
    If I try to deploy your LoadTest6.ear on WLS 10.3.5 I get:
    "VALIDATION PROBLEMS WERE FOUND problem: cvc-attribute.4: The value '6' does not equal the fixed value '5' of attribute 'version':<null> "
    If I try to deploy your LoadTest6.ear file using your deployment-plan file Plan.xml on WLS 12.1.1.0 it succeeds and the application is available at context-root "test" as intended by the deployment plan.

    If I try my scenario's with the exact same files (EAR files, deployment-plan files, Ant targets) as before [1], but on WebLogic Server 12.1.1.0 I get:
    - (sc2) on WLS 12.1.1.0 : the same as on WLS 10.3.5, context-root still "/rcrfaweb" not modified by the deployment-plan
    - (sc4) on WLS 12.1.1.0 : the same as on WLS 10.3.5, context-root still "/rcrsaweb" not modified by the deployment-plan

    - (sc7) on WLS 12.1.1.0 : succeeds, available at context-root "/rcrfaweb14" as intended by the deployment-plan
    - (sc8) on WLS 12.1.1.0 : succeeds, available at context-root "/rcrsaweb24" as intended by the deployment-plan

    So, scenario's (sc7) and (sc8) work as expected on WLS 12.1.1.0 but not on WLS 10.3.5 .

    (Note again that (sc2) and (sc4) try to change the context-root via weblogic.xml while (sc7) and (sc8) try to change the context-root via application.xml .)

    Strange that the WebLogic Server 12.1.1 documentation also (like the WLS 10.3.5 documentation [2]) says [3]:
    "Oracle does not support using a deployment plan to change the context-root in an application.xml file."
    Given the above observations, I don't understand what that means.

    - [1] available in http://www.consideringred.com/files/oracle/2012/ReviewContextRootApps-v0.01.zip
    and http://www.consideringred.com/files/oracle/2012/ReviewContextRootApps-v0.02.zip
    - [2] http://docs.oracle.com/cd/E21764_01/web.1111/e13702/config.htm#DEPGD172
    - [3] http://docs.oracle.com/cd/E24329_01/web.1211/e24443/config.htm#DEPGD172

    regards
    Jan
  • 6. Re: deploy given EAR file having application.xml and change context-root
    Jan Vervecken Journeyer
    Currently Being Moderated
    fyi

    In Oracle service request 3-6481085041 I got feedback pointing to My Oracle Support note 1399326.1, "Change Context Root In Application.xml Using Plan.xml ", that suggests to use xpath element syntax like:
    <xpath>/application/module/web/[context-root="rcrfaweb"]/</xpath>
    The modified example application includes deployment-plans using the xpath element syntax suggested in note 1399326.1
    at http://www.consideringred.com/files/oracle/2012/ReviewContextRootApps-v0.03.zip
    (basically ReviewContextRootApps-v0.01.zip again with new deployment-plans)

    This allows for scenario's:
    - scenario (sc9) : on WLS 10.3.5, deploy ReviewContextRootFirstApp.ear (in ReviewContextRootApps-v0.03.zip) with deployment-plan fa-plan-application-xml-cr-xpath.xml, resulting in context-root "/rcrfaweb15" as intended by the deployment-plan
    - scenario (sc10) : on WLS 10.3.5, deploy ReviewContextRootSecondApp.ear (in ReviewContextRootApps-v0.03.zip) with deployment-plan sa-plan-application-xml-cr-xpath.xml, resulting in context-root "/rcrsaweb25" as intended by the deployment-plan
    - scenario (sc11) : same as scenario (sc9) but on on WLS 12.1.1.0
    - scenario (sc12) : same as scenario (sc10) but on on WLS 12.1.1.0

    About the documentation saying "Oracle does not support using a deployment plan to change the context-root in an application.xml file.", documentation bug 16010924, "[WLS10.3.6]DEPLOYMENT PLAN TO OVERRIDE CHANGE CONTEXT-ROOT", has been created.

    regards
    Jan Vervecken
  • 7. Re: deploy given EAR file having application.xml and change context-root
    Jan Vervecken Journeyer
    Currently Being Moderated

    fyi

     

    Please consider Oracle bug 16010924, "[WLS10.3.5]DEPLOYMENT PLAN TO OVERRIDE CHANGE CONTEXT-ROOT".

    Currently it has "Status 99 - Closed, Documentation Bug Fixed", but no value for "Fixed in Product Version".

     

    In Oracle service request 3-8051275921 I got this feeback :

    "... the doc is public and updated at:

    http://docs.oracle.com/middleware/1212/wls/DEPGD/config.htm#i1061239 "

     

    Where it now says :

    "... You can use a deployment plan to override the context-root element defined in the application.xml deployment descriptor. ..."

     

    regards

    Jan Vervecken

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points