3 Replies Latest reply on Mar 14, 2018 12:09 PM by honza889

    How to configure a web service with two context roots

    hvu63

      We are in the process to change the url for a webservice. In the mean time we want to keep the old url in waiting for our partner to adapt.
      Thanks for helping.

        • 1. Re: How to configure a web service with two context roots
          honza889

          If you are changing context-root of your web service, I think best practice would be have deployed old service and new service as two independent deployments in parallel.

          Java EE spec allows only one context-root per web module.

          • 2. Re: How to configure a web service with two context roots
            hvu63

            I have only one service but we want to change the end point. By keeping the old end point (which can be forwarded to the new end point) we can let the consumer of the webservice the time to update the end point.

            • 3. Re: How to configure a web service with two context roots
              honza889

              If you really need two different context-roots, you will need two web deployments.

               

              On the other hand, if you actually need to have two different rest application paths in one context-root, you can define multiple rest Application:

              @ApplicationPath("/old-rest")
              public class OldRestApplication extends Application {
              }
              @ApplicationPath("/new-rest")
              public class NewRestApplication extends Application {
              }

               

              Only one rest service class will be sufficient for both prefixes in such case:

              @Path("/myRestService")
              public class MyRestService {
                  @GET
                  public String doSomething() {
                      ...
                  }
              }