4 Replies Latest reply on Jul 12, 2013 1:14 PM by Keith Babo

    Is it possible to have 2 different components with rest bindings using the exact same root context path?

    Susana Cabaco Newbie

      I have component A promoting some interface to which I create a rest binding.

      The same for component B.

      Both components are packed as ears and deployed as such.

       

      The problem is, when deploying both, given they both have contextPath defined with the same value (lets say <rest:contextPath>rest-binding</rest:contextPath>), what I get is an error mentionting that B cannot be deployed because the context path is already in use.

       

      As such, my alternative was to actually create an application class (subclassing javax.ws.rs.core.Application)  where I could define the context path globally to the component, then I could avoid having to specify it per rest binding in the switchyard.xml file. This way it would be different on a component basis and I would not have a problem.

       

      Seems like it was being ignored for whatever reason, so then I tried something like this instead:

       

      Component A switchyard.xml

      {code:xml}

      ...

              <sca:service name="serviceARESTBinding" promote="serviceA/serviceA">

                  <sca:interface.java interface="com.blah.service.serviceAInterface"/>

                  <rest:binding.rest>

                      <rest:interfaces>com.blah.service.rest.serviceAResource</rest:interfaces>

                      <rest:contextPath>systemRoot/serviceA</rest:contextPath>

                  </rest:binding.rest>

              </sca:service>

       

              <sca:service name="serviceA" promote="serviceA/serviceA">

                  <sca:interface.java interface="com.blah.service.serviceAInterface"/>

                  <sca:binding.sca/>

              </sca:service>

      ...

      {code}

       

      Component B switchyard.xml

      {code:xml}

      ...

              <sca:service name="serviceBRESTBinding" promote="serviceB/serviceB">

                  <sca:interface.java interface="com.blah.service.serviceBInterface"/>

                  <rest:binding.rest>

                      <rest:interfaces>com.blah.service.rest.serviceBResource</rest:interfaces>

                      <rest:contextPath>systemRoot/serviceB</rest:contextPath>

                  </rest:binding.rest>

              </sca:service>

       

              <sca:service name="serviceB" promote="serviceB/serviceB">

                  <sca:interface.java interface="com.blah.service.serviceBInterface"/>

                  <sca:binding.sca/>

              </sca:service>

      ...

      {code}

       

      It will work, but the questions then are:

      • Can I avoid having this differentiation done?
      • How?

       

      Thanks!