请教高手一个spring3.1下httpinvoker的配置问题

已经习惯了 发布于 2013/03/10 14:43
阅读 1K+
收藏 0
想做一个模拟webservice,http两种接口类型的WEB服务,axis2+spring3+mybatis的没问题,但
想使用spring自带的httpinvoker模拟http接口,始终配置不成功,求高手帮看看错误在哪里,
以下是我的配置情况:

applicationContext.xml
< ?xml version="1.0" encoding="UTF-8"?>
< beans xmlns="http://www.springframework.org/schema/beans" xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:context="http://www.springframework.org/schema/context" xmlns:cache="http://www.springframework.org/schema/cache"
xsi:schemaLocation="         
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd         
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd         
      http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd         
      http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd         
      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
      http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.1.xsd">

<!-- 扫描指定package下所有带有如@controller, @services , @resource ,并把所注释的注册为Spring Beans,其他路径可以加,号分隔 -->
<context:component-scan
base-package="xxx.yyy.axis2.bean,xxx.yyy.axis2.dao,xxx.yyy.axis2.service" />

<!-- 激活annotation功能 -->
<context:annotation-config />
<!-- 激活annotation功能 -->
<context:spring-configured />
<!-- 缓存注解驱动 -->
<cache:annotation-driven cache-manager="ehCacheManager" />
<!-- 启动aop切面编程注解 -->
<aop:aspectj-autoproxy />

<!-- 属性文件读入 -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:spring/jdbc_oracle.properties</value>
</list>
</property>
</bean>

<!-- 数据库连接池 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<!-- Connection Pooling Info -->
<property name="initialSize" value="30" />
<property name="maxActive" value="200" />
<property name="maxIdle" value="10" />
<property name="minIdle" value="3" />
<property name="maxWait" value="500" />
<property name="poolPreparedStatements" value="false" />
<property name="defaultAutoCommit" value="false" />
</bean>

<!-- Mybatis's sqlSessionFactory config -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="configLocation" value="classpath:mybatis/mybatis-config.xml" />
<!-- <property name="mapperLocations" value="classpath*:mybatis/mapper/*.xml" /> -->
</bean>

<!-- enable the configuration of transactional behavior based on annotations -->
<tx:annotation-driven transaction-manager="transactionManager" />

<bean name="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>

<!-- 启用事务 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="select*" read-only="true" />
<tx:method name="load*" read-only="true" />
<tx:method name="list*" read-only="true" />
<tx:method name="query*" read-only="true" />
<tx:method name="get*" read-only="true" />
<tx:method name="insert*" read-only="false" propagation="REQUIRED" rollback-for="Exception" />
<tx:method name="update*" read-only="false" propagation="REQUIRED" rollback-for="Exception" />
<tx:method name="delete*" read-only="false" propagation="REQUIRED" rollback-for="Exception" />
<tx:method name="save*" read-only="false" propagation="REQUIRED" rollback-for="Exception" />
<tx:method name="*" timeout="10" />
</tx:attributes>
</tx:advice>

<!-- scan mappers and let them be autowired -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="xxx.yyy.axis2.mapper" />
</bean>

<!-- 声明ehCacheManager -->
<bean id="ehCacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager" p:cache-manager-ref="ehcache" />

<!-- ehCacheManager工厂类 -->
<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" p:config-location="classpath:ehcache.xml" />
    <bean id="applicationContext" class="org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder" />

< bean id = "helloService" class = "org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
< property name = "service">
< ref bean = "simpleHelloWorld"/>
< /property>
< property name = "serviceInterface" value = "xxx.yyy.axis2.service.HelloWorld">
< /property>
< /bean>
< bean id = "simpleHelloWorld" class = "xxx.yyy.axis2.service.SimpleHelloWorld"/>
< /beans>

httpServ-servlet.xml
< ?xml version="1.0" encoding="UTF-8"?> 
< beans>
< bean class = "org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
< property name = "mappings">
< props>
< prop key = "/hello">helloService</prop>
< /props>
< /property>
< /bean>
< /beans>

web.xml
< ?xml version="1.0" encoding="UTF-8"?>
< web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>SimulateBSS</display-name>
<!-- 载入spring上下文 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/spring/applicationContext.xml,classpath:/spring/httpServ-servlet.xml</param-value>
</context-param>

<!-- Spring 刷新Introspector防止内存泄露 -->
<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener>
  <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>AxisServlet</servlet-name>
        <servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>AxisServlet</servlet-name>
        <url-pattern>/services/*</url-pattern>
    </servlet-mapping>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
 
  <servlet> 
    <servlet-name>httpServ</servlet-name> 
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
     <init-param> 
        <param-name>contextConfigLocation</param-name> 
        <param-value>classpath:/spring/httpServ-servlet.xml</param-value> 
    </init-param>
    <load-on-startup>2</load-on-startup>
< /servlet> 
< servlet-mapping> 
    <servlet-name>httpServ</servlet-name> 
    <url-pattern>/httpserv/*</url-pattern> 
< /servlet-mapping>
< /web-app>

java类:
package xxx.yyy.axis2.service;

public interface HelloWorld
{
    public String getMessage();
}


package xxx.yyy.axis2.service;

public class SimpleHelloWorld implements HelloWorld
{
    public String getMessage() {
        return "hello world secure http";
    }
}


输入http://localhost:8080/Simulate/httpserv/hello
异常:
java.io.EOFException
java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2281)
java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2750)
java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:780)
java.io.ObjectInputStream.<init>(ObjectInputStream.java:280)
org.springframework.core.ConfigurableObjectInputStream.<init>(ConfigurableObjectInputStream.java:64)
org.springframework.remoting.rmi.CodebaseAwareObjectInputStream.<init>(CodebaseAwareObjectInputStream.java:97)
org.springframework.remoting.rmi.RemoteInvocationSerializingExporter.createObjectInputStream(RemoteInvocationSerializingExporter.java:122)
org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter.readRemoteInvocation(HttpInvokerServiceExporter.java:114)
org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter.readRemoteInvocation(HttpInvokerServiceExporter.java:95)
org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter.handleRequest(HttpInvokerServiceExporter.java:72)
org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:49)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
加载中
0
JavaOlder
JavaOlder
应该是事务执行完,没有正常的结束,你打一个断点是一下~
0
已经习惯了

引用来自“JavaNewPer”的答案

应该是事务执行完,没有正常的结束,你打一个断点是一下~
思路错了,已经解决,谢谢
返回顶部
顶部