最近使用cxf2.7.0做一个简单的restful例子,郁闷一直都在启动时出错,检查配置没发现有什么问题,大家帮忙看一下。
出现的错误如下:
2013-3-11 15:25:33 org.apache.catalina.core.AprLifecycleListener init 信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\Program Files\Java\jdk1.6.0_12\bin;D:\GXMCC\tools\tomcat7\bin 2013-3-11 15:25:33 org.apache.coyote.AbstractProtocolHandler init 信息: Initializing ProtocolHandler ["http-bio-9999"] 2013-3-11 15:25:33 org.apache.coyote.AbstractProtocolHandler init 信息: Initializing ProtocolHandler ["ajp-bio-8009"] 2013-3-11 15:25:33 org.apache.catalina.startup.Catalina load 信息: Initialization processed in 921 ms 2013-3-11 15:25:33 org.apache.catalina.core.StandardService startInternal 信息: Starting service Catalina 2013-3-11 15:25:33 org.apache.catalina.core.StandardEngine startInternal 信息: Starting Servlet Engine: Apache Tomcat/7.0.10 2013-3-11 15:25:33 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory cxf 2013-3-11 15:25:34 org.apache.catalina.loader.WebappClassLoader validateJarFile 信息: validateJarFile(D:\GXMCC\tools\tomcat7\webapps\cxf\WEB-INF\lib\geronimo-servlet_3.0_spec-1.0.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class 2013-3-11 15:25:36 org.apache.catalina.core.ApplicationContext log 信息: Initializing Spring root WebApplicationContext 2013-3-11 15:25:36 org.springframework.web.context.ContextLoader initWebApplicationContext 信息: Root WebApplicationContext: initialization started 2013-3-11 15:25:36 org.springframework.context.support.AbstractApplicationContext prepareRefresh 信息: Refreshing Root WebApplicationContext: startup date [Mon Mar 11 15:25:36 CST 2013]; root of context hierarchy 2013-3-11 15:25:37 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 信息: Loading XML bean definitions from class path resource [spring/applicationContext.xml] 2013-3-11 15:25:37 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 信息: Loading XML bean definitions from class path resource [spring/integrationContext.xml] 2013-3-11 15:25:37 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 信息: Loading XML bean definitions from class path resource [META-INF/cxf/cxf.xml] 2013-3-11 15:25:37 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 信息: Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-soap.xml] 2013-3-11 15:25:37 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 信息: Loading XML bean definitions from class path resource [META-INF/cxf/cxf-servlet.xml] 2013-3-11 15:25:38 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons 信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@17e9134: defining beans [cxf,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.binding.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,userRS,userRsImpl]; root of factory hierarchy 2013-3-11 15:25:39 org.apache.cxf.bus.spring.OldSpringSupport logWarning 警告: Import of META-INF/cxf/cxf-extension-soap.xml has been deprecated and is unnecessary. UserRS constructor 2013-3-11 15:25:40 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons 信息: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@17e9134: defining beans [cxf,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.binding.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,userRS,userRsImpl]; root of factory hierarchy 2013-3-11 15:25:40 org.springframework.web.context.ContextLoader initWebApplicationContext 严重: Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRS': Invocation of init method failed; nested exception is org.apache.cxf.service.factory.ServiceConstructionException at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1422) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:518) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4651) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5154) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5149) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) Caused by: org.apache.cxf.service.factory.ServiceConstructionException at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:201) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1546) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1487) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1419) ... 20 more Caused by: java.lang.RuntimeException: Resource class interface com.sky.oa.cxf.service.IUserRS has no valid constructor at org.apache.cxf.jaxrs.lifecycle.PerRequestResourceProvider.<init>(PerRequestResourceProvider.java:45) at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.updateClassResourceProviders(JAXRSServerFactoryBean.java:387) at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:151) ... 27 more 2013-3-11 15:25:40 org.apache.catalina.core.StandardContext listenerStart 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRS': Invocation of init method failed; nested exception is org.apache.cxf.service.factory.ServiceConstructionException at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1422) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:518) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4651) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5154) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5149) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) Caused by: org.apache.cxf.service.factory.ServiceConstructionException at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:201) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1546) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1487) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1419) ... 20 more Caused by: java.lang.RuntimeException: Resource class interface com.sky.oa.cxf.service.IUserRS has no valid constructor at org.apache.cxf.jaxrs.lifecycle.PerRequestResourceProvider.<init>(PerRequestResourceProvider.java:45) at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.updateClassResourceProviders(JAXRSServerFactoryBean.java:387) at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:151) ... 27 more 2013-3-11 15:25:40 org.apache.catalina.core.StandardContext startInternal 严重: Error listenerStart 2013-3-11 15:25:40 org.apache.catalina.core.StandardContext startInternal 严重: Context [/cxf] startup failed due to previous errors 2013-3-11 15:25:41 org.apache.catalina.core.ApplicationContext log 信息: Closing Spring root WebApplicationContext 2013-3-11 15:25:41 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory docs 2013-3-11 15:25:41 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory examples 2013-3-11 15:25:41 org.apache.catalina.core.ApplicationContext log 信息: ContextListener: contextInitialized() 2013-3-11 15:25:41 org.apache.catalina.core.ApplicationContext log 信息: SessionListener: contextInitialized() 2013-3-11 15:25:41 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory host-manager 2013-3-11 15:25:41 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory manager 2013-3-11 15:25:41 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory Root 2013-3-11 15:25:41 org.apache.coyote.AbstractProtocolHandler start 信息: Starting ProtocolHandler ["http-bio-9999"] 2013-3-11 15:25:41 org.apache.coyote.AbstractProtocolHandler start 信息: Starting ProtocolHandler ["ajp-bio-8009"] 2013-3-11 15:25:41 org.apache.catalina.startup.Catalina start 信息: Server startup in 8064 ms
配置文件如下:
Jar是从cxf2.7.0的lib中直接复制出来的,没有添加其他任何jar。
web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <servlet> <servlet-name>CXFServlet</servlet-name> <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>CXFServlet</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> <!-- 加载spring配置文件,文件路径设置在contextConfigLocation参数中 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:/spring/applicationContext.xml</param-value> </context-param> <!-- 字符过滤器 --> <filter> <filter-name>encoding</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>encoding</filter-name> <url-pattern>*.action</url-pattern> </filter-mapping> <filter-mapping> <filter-name>encoding</filter-name> <url-pattern>*.json</url-pattern> </filter-mapping> <filter-mapping> <filter-name>encoding</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> </web-app>
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd" default-autowire="byName"> <import resource="classpath:/spring/integrationContext.xml" ></import> </beans>
integrationContext.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd"> <description>Apache CXF的Web Service配置</description> <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" /> <jaxrs:server id="userRS" serviceClass="com.sky.oa.cxf.service.IUserRS" address="/userRSCXF"> <jaxrs:serviceBeans> <ref bean="userRsImpl"/> </jaxrs:serviceBeans> <jaxrs:extensionMappings> <entry key="json" value="application/json"></entry> <entry key="xml" value="application/xml" /> </jaxrs:extensionMappings> </jaxrs:server> <bean id="userRsImpl" class="com.sky.oa.cxf.service.UserRS"></bean> </beans>
IUserRS
package com.sky.oa.cxf.service; import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebService; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; @WebService @Path("/users/") @Produces(MediaType.APPLICATION_JSON) public interface IUserRS { @WebMethod @GET @Path("/user/{userId}") public String getUser(@WebParam(name = "userId")String userId); }
UserRS
package com.sky.oa.cxf.service; import javax.jws.WebService; @WebService public class UserRS implements IUserRS { public String getUser(String userId){ System.out.println("----------"); System.out.println(" return xixihaha"); return "xixihaha"; } }
相关推荐
"cxf-2.7.0-src" 标题表明这是一个包含Apache CXF 2.7.0版本源代码的压缩包。在描述中,"apache-cxf-2.7.0-src" 重申了这一信息,提示用户这是一份完整的源代码库,适合开发者深入理解CXF的工作原理或者进行定制化...
此为window下用CMD就可以把wsdl格式生成客户端代码的开具,解压后, 到bin目录下, 按‘shift’右键单击空白出, 出现在此处打开窗口,然后输入: wsdl2java -frontend jaxws21 -d (这里是你要生成代码的位置) ...
在这个“Spring CXF Restful实例”中,我们将深入探讨如何利用Spring CXF来创建RESTful API。REST(Representational State Transfer)是一种软件架构风格,常用于构建现代Web服务,强调简洁、无状态和基于标准的...
【CXF Restful服务简单例子】\n\n在IT行业中,Apache CXF是一个广泛使用的开源框架,它允许开发人员创建和消费Web服务。RESTful(Representational State Transfer)是一种网络应用程序的设计风格和开发方式,基于...
【标题】:CXF RESTful服务的实现与应用 【正文】: Apache CXF是一个流行的开源框架,用于构建和开发Web服务。它支持多种协议,包括RESTful(Representational State Transfer)风格的服务,使得开发者可以方便地...
SpringBoot+Mybatis+CXF框架,实现Restful api与 WebService api接口的大实验 本实验的主要目标是使用SpringBoot、Mybatis和CXF框架来实现Restful API和WebService API接口的大实验。下面是实验的详细介绍: 标题...
在创建CXF RESTful服务时,我们首先需要在项目中配置Maven。这通常涉及到在`pom.xml`文件中添加CXF和相关依赖。例如,你需要包含以下依赖: ```xml <groupId>org.apache.cxf <artifactId>cxf-rt-frontend-jax...
【标题】"使用CXF开发RESTFul服务"涉及到的核心技术是Apache CXF框架和RESTful API设计。Apache CXF是一个开源的Java框架,主要用于构建和消费Web服务,包括SOAP和RESTful服务。REST(Representational State ...
CXF,全称Apache CXF,是一个开源的Java框架,它提供了丰富的功能来帮助开发者创建和消费Web服务,包括RESTful服务。本资料主要讲解如何使用Spring与CXF集成,来发布RESTful服务,并提供了相关的项目案例和代码。 ...
本教程将深入探讨如何在Spring环境中集成CXF以实现RESTful WebService接口。 首先,我们需要理解REST(Representational State Transfer)的概念。REST是一种软件架构风格,用于设计网络应用程序。它的核心思想是...
本项目聚焦于利用CXF与Spring框架集成,实现RESTful风格的Web服务。REST(Representational State Transfer)是一种轻量级、基于HTTP协议的架构风格,适用于构建可伸缩的、高性能的Web应用。 首先,让我们深入理解...
Apache CXF是一个流行的开源框架,它提供了强大的支持来构建RESTful Web服务。下面将详细讲解如何使用CXF搭建RESTful风格的Web服务。 1. **CXF简介** Apache CXF是一个全面的服务开发框架,它允许开发者创建和部署...
在部署RESTful服务时,CXF提供了一个基于Servlet的部署模型,可以将服务绑定到Servlet容器,如Tomcat或Jetty。同时,CXF也支持Spring框架集成,可以利用Spring的依赖注入和管理特性。 除了服务端开发,CXF也提供了...
在IT行业中,CXF是一个广泛使用的开源框架,用于构建和开发Web服务,包括SOAP和RESTful接口。本篇文章将深入探讨如何使用CXF、Spring、Maven等技术栈来发布一个支持HTTP请求和SOAP调用的RestFul接口。 首先,我们...
用CXF开发RESTful风格WebService.doc
【CXF3.0+Spring3.2 RESTFul服务(下)】 在现代Web服务开发中,RESTful API已经成为主流,它通过HTTP协议提供简洁、无状态的接口,易于客户端调用。CXF,一个强大的开源服务框架,支持SOAP和RESTful服务,而Spring...
5. **启动服务**:在Spring的主入口类中加载配置文件,启动CXF服务: ```java public class App { public static void main(String[] args) { ClassPathXmlApplicationContext context = new ...
使用cxf、spring构建的rest风格webservice,其他相关技术springmvc、mybatis、druid等。代码中使用的数据库为sybase,请根据实际环境更改,需修改pom中引用的数据库驱动,依照entity类的属性建对应表,并修改config....
【标题】"CXF RESTful Web服务" 在Java开发领域,Apache CXF是一个广泛使用的开源框架,用于构建和实现Web服务。本项目“cxf_restful_webservice”着重于使用CXF来创建RESTful风格的Web服务。REST...
在提供的压缩包文件“cxf-ws-restful-spring-server”中,包含了使用CXF、SOAP和RESTful的示例项目。通过访问“http://localhost:8080/cxf-ws-restful-spring-server/ws63”,我们可以看到这些服务的实际运行效果。...