cxf与spring整合问题

断水为桥 发布于 2014/03/14 17:51
阅读 784
收藏 0

最近练习cxf与spring遇到的问题。利用cxf写了一个最简单的webservice程序。只有一个接口HelloWorld和一个实现类HelloWorldWs。但是整合到spring发布时就遇到了问题。tomcat浏览器显示No services have been found。控制台输出的错误是

SEVERE: Servlet.service() for servlet [cxf] in context with path [/cxf_spring] threw exception
java.lang.IllegalStateException: getWriter() has already been called for this response

附上web.xml文档

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xmlns="http://java.sun.com/xml/ns/j2ee" 
         xmlns:javaee="http://java.sun.com/xml/ns/javaee" 
         xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" 
         id="WebApp_9" version="2.4">
	
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/applicationContext.xml</param-value>	
	</context-param>
	
    <listener>
            <!-- 该listener保证在web应用启动时,加载spring容器 -->
        	<listener-class>org.springframework.web.context.ContextLoader</listener-class>
    </listener>

    <servlet>
    	<servlet-name>cxf</servlet-name>
    	<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
    </servlet>
    
    <servlet-mapping>
    	<servlet-name>cxf</servlet-name>
    	<url-pattern>/fkservice/*</url-pattern>
    </servlet-mapping>
</web-app>



和applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>  
<beans xmlns="http://www.springframework.org/schema/beans" 
	xmlns:jaxws="http://cxf.apache.org/jaxws" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
    xmlns:p="http://www.springframework.org/schema/p"   
    xsi:schemaLocation="http://www.springframework.org/schema/beans   
    http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
    http://cxf.apache.org/jaxws         
    http://cxf.apache.org/schemas/jaxws.xsd"> 
    
	<import resource="classpath:META-INF/cxf/cxf.xml"/>
	<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
	<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
	
	<bean id="hello" class="org.fkjava.cxf.ws.impl.HelloWorldWs"></bean>
	
	<jaxws:endpoint
          id="helloworld"  implementor="#hello" address="/HelloWorld">
	</jaxws:endpoint>	

</beans>



webapp名字是cxf_spring。求教哪位大神指导是怎么回事。不胜感激。

加载中
返回顶部
顶部