类javax.xml.ws.Service中的构造方法服务不能应用于给定类型 [英] constructor Service in class javax.xml.ws.Service cannot be applied to given types

查看:102
本文介绍了类javax.xml.ws.Service中的构造方法服务不能应用于给定类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用apache-cxf-2.7.4创建了一个Web服务. 我进入了在项目中制作的课程. 我在项目中拥有的库是:

I have created a web service with apache-cxf-2.7.4. I entered the classes produced in my project. the libraries I have in my project are:

  • math3-commons-3.2.jar
  • XStream-1.4.4.jar
  • jaxws-api-2.2.5.jar

我遇到以下错误:

  constructor Service in class javax.xml.ws.Service cannot be applied to given types;
  required: java.net.URL,javax.xml.namespace.QName
  found: java.net.URL,javax.xml.namespace.QName,javax.xml.ws.WebServiceFeature[]
  reason: actual and formal argument lists differ in length

推荐答案

问题是JAX-WS API的版本.应用程序的类加载器首先加载Java SE或Java EE中包含的版本.

The problem is the version of JAX-WS API. The classloader for your application first loaded the version included in Java SE or Java EE.

对于Java SE 6或Java EE 5,JAX-WS API 2.1. javax.xml.ws.Service 中的构造函数:

For Java SE 6 or Java EE 5, JAX-WS API 2.1. The constructors in javax.xml.ws.Service:

javax.xml.ws.Service.Service(URL, QName)

对于Java SE 7或Java EE 6,JAX-WS API 2.2. javax.xml.ws.Service 中的构造函数:

For Java SE 7 or Java EE 6, JAX-WS API 2.2. The constructors in javax.xml.ws.Service:

javax.xml.ws.Service.Service(URL, QName)
javax.xml.ws.Service.Service(URL, QName, WebServiceFeature...)  // You need this!

有三种可能的解决方案(取决于它是Web应用程序还是独立应用程序):

There are three possible solutions (depends on whether it is a web application or standalone application):

  1. 使用Java SE 7或Java EE 6.

  1. Use Java SE 7 or Java EE 6.

使用参数-frontend jaxws21重新运行wsdl2java以生成兼容JAX-WS 2.1的代码.

Re-run wsdl2java with argument -frontend jaxws21 to generate JAX-WS 2.1 compliant code instead.

更改类加载器以首先加载应用程序中包含的类.

Change the classloader for load first the classes included in the application.

这篇关于类javax.xml.ws.Service中的构造方法服务不能应用于给定类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆