问题
I have following configuration for the web application.
web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:mail-application-context.xml
....
</context-param>
....
<servlet>
<servlet-name>mailbox</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mailbox</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
mailbox-servlet.xml
<bean name="remoteProvisioningServiceImpl" class="pw.domain.service.RemoteProvisioningServiceImpl"/>
<bean name="/remote/domain/provision.htm" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
<property name="service" ref="remoteProvisioningServiceImpl" />
<property name="serviceInterface" value="pw.domain.service.RemoteProvisioningService" />
</bean>
I have the clients configured properly, like following, in mail-application-context.xml
<bean id="remoteProvisioningService1" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
<property name="serviceUrl" value="http://${mailapp.dc.host.1.url}/remote/domain/provision.htm" />
<property name="serviceInterface" value="pw.domain.service.RemoteProvisioningService" />
</bean>
<bean id="remoteProvisioningService2" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
<property name="serviceUrl" value="http://${mailapp.dc.host.2.url}/remote/domain/provision.htm" />
<property name="serviceInterface" value="pw.domain.service.RemoteProvisioningService" />
</bean>
And now... the problem. On an appropriate event, the clients rightly call service through httpinvoker facility but the response is http-404. In nginx logs, i trace that spring makes a POST call to http://{host}/remote/domain/provision.htm.
Questions :
Do i need to create a separate app-context for httpInvoker bit? i mean, i already have one web context to deal with normal web operations. Do i need to declare {another-context} in web.xml for httpInvoker facility and having the service config. defined in {another-context}-servlet.xml?
If not 1, what is wrong in my configuration?
回答1:
Got it.. Question 1 above has the answer attached to it. I need to create a separate web context for http-invoking facility to work.
This is because, in my normal webapp context (mailbox), i already have defined SimpleUrlHandlerMapping which maps appropriate urls to controllers. There it doesnt find place for http-invoker-serivce i want to define. When i separated web contexts, it worked like a charm! :D
Happy coding! :)
来源:https://stackoverflow.com/questions/7095514/spring-httpinvoker-client-can-not-find-the-service-url