0

My need is to publish two services with same path on mule, but different URL's. Like this

https://localhost:8443/etc/app/version1/Service

https://localhost:8443/etc/app/version2/Service

Im using servlet mapping on web.xml

<servlet-mapping>
        <servlet-name>muleServlet</servlet-name>
    <url-pattern>/app/*</url-pattern>
</servlet-mapping>

And tried to use two different connectors since the path attribute doesn't allow me to use "version1/Service" or "version2/Service"

<servlet:connector
    name="conectorVersion1"
    servletUrl="https://localhost:8443/etc/app/version1/">
</servlet:connector>

<servlet:connector
    name="conectorVersion2"
    servletUrl="https://localhost:8443/etc/app/version2/">
</servlet:connector>

And finally, the endpoints

   <flow
    name="FlowVersion1"
    processingStrategy="synchronous">

       <servlet:inbound-endpoint
        connector-ref="conectorVersion1"
        path="Service">
        <-- processors, jaxws-service, interceptors etc.. -->
       </servlet:inbound-endpoint>
    </flow>

   <flow
    name="FlowVersion2"
    processingStrategy="synchronous">

       <servlet:inbound-endpoint
        connector-ref="conectorVersion2"
        path="Service">
        <-- processors, jaxws-service, interceptors etc.. -->
       </servlet:inbound-endpoint>
    </flow>

But i got this exception:

 [[/etc]] StandardWrapper.Throwable: java.lang.IllegalStateException: 
 There are at least 2 connectors matching protocol "servlet", so the connector to use must be 
 specified on the endpoint using the 'connector' property/attribute. 
 Connectors in your configuration that support "servlet" are: conectorVersion1, conectorVersion2, 

Thanks in advance.

jonfornari
  • 530
  • 1
  • 4
  • 20

1 Answers1

1

I don't think it's valid to declare two servlet connectors: there's only one servlet context so a single connector is enough. Actually, I never declare the Servlet connector, as the default configuration works just fine.

So with only the following configuration:

<flow name="FlowVersion1" processingStrategy="synchronous">
    <servlet:inbound-endpoint
        path="version1/Service" />
    <set-payload value="version 1" />
</flow>

<flow name="FlowVersion2" processingStrategy="synchronous">
    <servlet:inbound-endpoint
        path="version2/Service" />
    <set-payload value="version 2" />
</flow>

I'm able to deploy in a servlet container (Jetty) and I can hit /{context}/app/version1/Service and /{context}/app/version2/Service without problem.

David Dossot
  • 33,403
  • 4
  • 38
  • 72
  • Thanks David, i already have discovered this and it worked, i was about to post my awnser but now i'll just accept yours. I'm just curious about something: do you know why paths that contain underscore only works with a slash as the first character? e.g this doesnt work but this works just fine – jonfornari Feb 08 '13 at 18:27
  • It looks like a bug to me: behind the scene Mule represent endpoints as URI and seems to consider `servlet://service_v1_01_01/Hello` and `servlet://service_v2_01_01/Hello` as conflicting, while `servlet:///service_v1_01_01/Hello` and `servlet:///service_v2_01_01/Hello` not... open a JIRA :D – David Dossot Feb 08 '13 at 18:53
  • Here it is: http://www.mulesoft.org/jira/browse/MULE-6638 And thanks again David. – jonfornari Feb 08 '13 at 19:47