java - CXF - 无法添加特征

标签 java eclipse cxf

我使用 Apache CXF 2.7.0 已经有一段时间了,但最近我不得不在 Eclipse 中重构我的项目。在我这样做之后,出于某种原因,我无法向端点添加“WSAddressingFeature”功能。

我错过了什么??

    endpoint.getFeatures().add(new org.apache.cxf.ws.addressing.WSAddressingFeature());

Eclipse 报告:

"The method add(Feature) in the type List<Feature> is not applicable for the arguments (WSAddressingFeature)"

这是我的完整实现:​​

    String url = "http://localhost:" + m_Port + "/infoburst/handler";
    Object implementor = new HandlerImpl();
    org.apache.cxf.jaxws.EndpointImpl endpoint = new org.apache.cxf.jaxws.EndpointImpl(implementor);
    endpoint.getFeatures().add(new org.apache.cxf.ws.addressing.WSAddressingFeature());
    endpoint.publish(url);

    org.apache.cxf.endpoint.Server server = endpoint.getServer();
    org.apache.cxf.jaxws.JaxWsServerFactoryBean serverFB = endpoint.getServerFactory();

如果我删除添加该功能的代码行,则会出现以下错误:

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.cxf.common.util.ReflectionUtil.getDeclaredMethod(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.bindOperation(JaxWsServiceFactoryBean.java:276)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.createOperation(ReflectionServiceFactoryBean.java:1045)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.createOperation(JaxWsServiceFactoryBean.java:642)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.createInterface(ReflectionServiceFactoryBean.java:990)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:481)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:704)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:550)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:265)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:215)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102)
at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:159)
at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211)
at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:456)
at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:334)
at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:251)
at org.apache.cxf.jaxws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:155)
at javax.xml.ws.Endpoint.publish(Unknown Source)
at com.infosol.infoburst.XI4Service.HandlerService.publish(HandlerService.java:106)
at com.infosol.infoburst.XI4Service.HandlerService.main(HandlerService.java:42)

最佳答案

这就是为什么我真的不喜欢在 Java 环境中工作...

要修复“”类型列表中的方法 add(Feature) 不适用于参数 (WSAddressingFeature)” 错误:

  1. 进入“配置构建路径”
  2. 转到“订购和导出”
  3. 将“cfx-2.7.0.jar”文件移到更高的优先级,这可能需要反复试验。

一旦 CFX 文件的优先级上移,错误就会消失。

关于java - CXF - 无法添加特征,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26595224/

相关文章:

java - 简单的Java多线程socket应用程序

java - Maven版本插件,限制版本:update-properties damage

java - SAXParserFactory.newInstance() 无法解析为类型

cxf - CXF 的 WS-security(用户名 token )- 可以加密密码吗?

java - 将 Iterator 类与 HashSet 一起使用时出现 NoSuchElementException

java - 如何使用 StandfordNLP 解决共同引用后获得最终文本

php - 使用 PHP 的内置服务器设置 Eclipse PDT

java - Eclipse, ImageView 上的 View 布局

java - WSDL 定位器中的异常

jax-ws - CXF - Jboss AS 7 : org. apache.cxf.staxutils.DepthExceededStaxException 中的 Jaxws 问题:达到 innerElementCountThreshold:50000