1 Reply Latest reply on Sep 21, 2011 8:57 AM by Max Rydahl Andersen

    Exporting using a different context-root

    Scott Stark Master

      Another issue related to http://community.jboss.org/thread/172586 is how to change the context-root of the exported war. Let's say I have the following two web projects that I run locally with war deployments sales.war and employee.war:

       

      http://localhost:8080/sales

      http://localhost:8080/employee

       

      Now when I export these wars for use in openshift, I have unique dns names for each one as each war is a unique openshift express application, so I would like to have the context root for each war be set to / so that I have the following wep app urls:

       

      http://employee-sstark.dev.rhcloud.com/

      http://sales-sstark.dev.rhcloud.com/

       

      rather than:

       

      http://employee-sstark.dev.rhcloud.com/employee

      http://sales-sstark.dev.rhcloud.com/sales

       

      I'm hacking this in after the fact with a little ant script right now. Is is possible to configure this differently for export?

       

      This is slightly related to the following issue I suppose:

      https://issues.jboss.org/browse/JBIDE-473

        • 1. Re: Exporting using a different context-root
          Max Rydahl Andersen Master

          Eclipse (and most other IDE's I know) doesn't handle having "multiple" context roots elegantly but here is what I do currently:

           

          You can simply just set the context root to "/" via the jboss specific descriptors and deploy it - then the only feature that gets funky is that "Run As..." no longer opens up your browser correctly. To fix that got to preferences of your project and see the "Web Project Settings" and set this to "./" and the url should be resolved correctly. (You can try with just "/" too but I've noticed there being problems with that and the path not being handled properly)

           

          If you use Maven you can have m2e/wtp maintain this by adding:

           

          <m2eclipse.wtp.contextRoot>/<m2eclipse.wtp.contextRoot>

           

          to maven <properties> section.

           

          This contextRoot you can of course control via profiles too if need be and thus you can avoid having your custom ant script do it.

           

          This of course makes it necessary to deploy each war to its own server.

           

           

          ...got any suggestions how we can do it differently ? What we would need is someway to tell AS7 when deploying that this

          war has a different context root without changing the war, but I don't know of a way to do this ?