今天试着写了个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
也找不到
希望各位高手支支招啊!!
分全给了!急啊!
但是一直报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
也找不到
希望各位高手支支招啊!!
分全给了!急啊!
解决方案 »
- 救命。。。SSH框架struts2默认theme成default了
- 上传文件到MySQL数据库Blob字段 内容多了两个字节
- 雯字 乱码
- MyEclipse+Tomcat工程项目复制之后不能重命名!WHY?
- 一个java技术网站[http://javalife.cn],欢迎大家来灌
- 问大家个问题 搭建Spring框架 如果没网络 是不是第一次还要配置DTD文件 需要配置哪些DTD文件啊
- 并发问题:多用户同时在线审核数据时,怎样处理?
- Struts下拉框的问题,在ActionForm错误返回的时候出错了
- 最简单的rmi程序都运行不了,请大家看看
- 高分求助:小弟刚学J2EE,老师要我们设计一个项目,作为期末考试。
- 求JBPM5.3整合spring 部署到tomcat6
- ireport 4.5.1 通过java生成pdf的问题
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
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/ProductService">/ProductService</prop>
</props>
</property>
</bean>