Spring用httpInvoker问题

fifanrg8699 2011-11-02 08:44:21
今天试着写了个httpInvoker做远程调用,以便项目以后要扩展成分布式开发的。
但是一直报404找不到错误,我试着查了一下,确定自己配置文件都没有写错。

把代码贴出来 希望各位高手解答疑惑 谢谢

server端web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext*.xml,
/WEB-INF/remoting-servlet.xml</param-value>
</context-param>


<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<!-- Test httpInvoker configuration -->
<servlet>
<servlet-name>remoting</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>remoting</servlet-name>
<url-pattern>/remoting/*</url-pattern>
</servlet-mapping>

<!-- Test httpInvoker configuration end **********-->



remoting-servlet.xml:

<bean id="productService" class="com.fifanrg.services.ProductServiceImpl">
<property name="productDao" ref="productDao"></property>
</bean>

<!--httpinvoker config -->
<bean name="/ProductService" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
<property name="service" ref="productService"/>
<property name="serviceInterface" value="com.fifanrg.services.ProductService"/>
</bean>




客户端BeanHttpInvoker.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean class="com.fifanrg.actions.ProductAction">
<property name="productService" ref="httpInvokerProxy"/>
</bean>
<bean id="httpInvokerProxy" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
<property name="serviceUrl" value="http://localhost:7001/AssiTwo/remoting/ProductService"/>
<property name="serviceInterface" value="com.fifanrg.services.ProductService"/>
</bean>
</beans>


测试代码:

public class TestHttpInvoker {

public static void main(String[] args) {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
"BeanHttpInvoker.xml");
ProductAction productAction = (ProductAction) applicationContext
.getBean("com.fifanrg.actions.ProductAction");
Catalog catalog = productAction.getProductService().findCatalogById(11078);
System.out.println(catalog.getC_title());
}


[color=#FF0000]错误信息:
Exception in thread "main" org.springframework.remoting.RemoteAccessException: Could not access HTTP invoker remote service at [http://localhost:7001/AssiTwo/remoting/ProductService]; nested exception is java.io.IOException: Did not receive successful HTTP response: status code = 404, status message = [Not Found]
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.convertHttpInvokerAccessException(HttpInvokerClientInterceptor.java:211)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:160)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy0.findCatalogById(Unknown Source)
at com.fifanrg.test.TestHttpInvoker.main(TestHttpInvoker.java:16)
Caused by: java.io.IOException: Did not receive successful HTTP response: status code = 404, status message = [Not Found]
at org.springframework.remoting.httpinvoker.SimpleHttpInvokerRequestExecutor.validateResponse(SimpleHttpInvokerRequestExecutor.java:139)
at org.springframework.remoting.httpinvoker.SimpleHttpInvokerRequestExecutor.doExecuteRequest(SimpleHttpInvokerRequestExecutor.java:62)
at org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor.executeRequest(AbstractHttpInvokerRequestExecutor.java:134)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:191)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:157)
... 4 more
[/color]


就是会报404错误,但我实在看不出来哪里配置有错。
我直接在url里面输入http://localhost:7001/AssiTwo/remoting/ProductService
也找不到
希望各位高手支支招啊!!
分全给了!急啊!


...全文
990 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
q200737056 2012-10-10
  • 打赏
  • 举报
回复
怎么没人回答啊,我也遇到这问题了,怎么搞啊
huimiezu 2012-10-10
  • 打赏
  • 举报
回复
remoting-servlet.xml加上:
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/ProductService">/ProductService</prop>

</props>
</property>
</bean>
showphee 2012-04-11
  • 打赏
  • 举报
回复
Exception in thread "main" org.springframework.remoting.RemoteAccessException: Could not access HTTP invoker remote service at [http://localhost:8099/remoteServer]; nested exception is java.io.IOException: Did not receive successful HTTP response: status code = 404, status message = [/remoteServer/]
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.convertHttpInvokerAccessException(HttpInvokerClientInterceptor.java:211)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:144)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy0.getString(Unknown Source)
at test.TestRemote.main(TestRemote.java:16)
Caused by: java.io.IOException: Did not receive successful HTTP response: status code = 404, status message = [/remoteServer/]
at org.springframework.remoting.httpinvoker.SimpleHttpInvokerRequestExecutor.validateResponse(SimpleHttpInvokerRequestExecutor.java:146)
at org.springframework.remoting.httpinvoker.SimpleHttpInvokerRequestExecutor.doExecuteRequest(SimpleHttpInvokerRequestExecutor.java:65)
at org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor.executeRequest(AbstractHttpInvokerRequestExecutor.java:136)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:191)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:173)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:141)
... 4 more
dragonsky_w 2011-11-02
  • 打赏
  • 举报
回复
不懂,顶起,……

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧