灰熊 - java.lang.NoSuchMethodError: javax.xml.ws.WebFault.messageName

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13356479/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 12:24:22  来源:igfitidea点击:

Grizzly - java.lang.NoSuchMethodError: javax.xml.ws.WebFault.messageName

javaweb-servicessoapgrizzly

提问by Anton Tsivarev

I have a wsdl file for the Web service. I want to test the interaction between the client and the server. To do this, I run the mock server with embedded grizzly.

我有一个用于 Web 服务的 wsdl 文件。我想测试客户端和服务器之间的交互。为此,我使用嵌入式灰熊运行模拟服务器。

The question about of implementing mock server. I generated an interface from wsdl (and xsd) using the wsimport and wrote implementation. When run on the grizzly, I get the following error:

关于实现模拟服务器的问题。我使用 wsimport 从 wsdl(和 xsd)生成了一个接口并编写了实现。在灰熊上运行时,出现以下错误:

com.sun.xml.ws.server.ServerRtException: [failed to localize] cannot.load.wsdl(META-INF/wsdl/test.wsdl)

I run a web service with this code:

我使用以下代码运行 Web 服务:

 HttpHandler httpHandler = new JaxwsHandler(new TestImpl());
 server.getServerConfiguration().addHttpHandler(httpHandler, "/test");

The problem is that Grizzly can not find wsdl and xsd files. In embedded glassfish its work.

问题是 Grizzly 找不到 wsdl 和 xsd 文件。在嵌入式 glassfish 中它的工作。

EDIT1

编辑1

I change wsdlLocation to "test.wsdl" and its work. But now grizzly say:

我将 wsdlLocation 更改为“test.wsdl”及其工作。但现在灰熊说:

java.lang.NoSuchMethodError: javax.xml.ws.WebFault.messageName()Ljava/lang/String;

EDIT2

编辑2

If use JDK1.7 it works. But I need a JDK 1.6

如果使用 JDK1.7 它可以工作。但我需要一个 JDK 1.6

采纳答案by Anton Tsivarev

As a result, we had to use endorsed mechanism. Documentation

因此,我们不得不使用背书机制。文档

回答by rlubke

I'm not sure why you're seeing that error. I can run the Grizzly jaxws example and obtain the wsdl using either 1.6 or 1.7.

我不确定您为什么会看到该错误。我可以运行 Grizzly jaxws 示例并使用 1.6 或 1.7 获取 wsdl。

I would recommend reviewing the source1of the example and compare to what you have.

我建议您查看示例的源代码1并与您拥有的内容进行比较。

回答by dellasavia

I'm change the jdk6 to jdk7 and works fine! Don't forget to change the JAVA_HOME and the default JDK of Netbeans as related here: How to set the JDK Netbeans runs on?

我正在将 jdk6 更改为 jdk7 并且工作正常!不要忘记在此处更改 JAVA_HOME 和 Netbeans 的默认 JDK:How to set the JDK Netbeans running on?

回答by Fabian Ritzmann

Your version of Grizzly expects a JAX-WS 2.2 API while JDK 1.6 ships with JAX-WS 2.1. As others mentioned, some of these files need to be installed into an endorsed directory. You can download the required files hereor take them from your Grizzly installation. The download includes an Ant build file that provides a build target to install the files into the JDK endorsed directory. You can run it with ant install-api. If you cannot run Ant, you may install them manually:

您的 Grizzly 版本需要 JAX-WS 2.2 API,而 JDK 1.6 附带 JAX-WS 2.1。正如其他人提到的,其中一些文件需要安装到认可的目录中。您可以在此处下载所需的文件或从您的 Grizzly 安装中获取它们。下载包括一个 Ant 构建文件,该文件提供了一个构建目标,用于将文件安装到 JDK 认可的目录中。你可以用ant install-api. 如果您无法运行 Ant,您可以手动安装它们:

cp lib/jaxb-api.jar $JAVA_HOME/lib/endorsed
cp lib/jaxws-api.jar $JAVA_HOME/lib/endorsed

Do not install other files from the JAX-WS distribution into the endorsed directory unless you want to create some really difficult to debug bugs for yourself.

不要将 JAX-WS 发行版中的其他文件安装到认可目录中,除非您想为自己创建一些非常难以调试的错误。

I am suggesting to use the endorsed directory in $JAVA_HOME/lib/endorsed because that will work with most tools and applications without any additional changes. Others already suggested more targeted changes, such as setting an endorsed directory during a Maven build or copying the files into a Tomcat endorsed directory. All these approaches are fine as long as you can make sure that your code is picking up the right endorsed directory.

我建议使用 $JAVA_HOME/lib/endorsed 中的认可目录,因为它适用于大多数工具和应用程序,无需任何额外更改。其他人已经建议进行更有针对性的更改,例如在 Maven 构建期间设置认可目录或将文件复制到 Tomcat 认可目录中。只要您能确保您的代码选择正确的认可目录,所有这些方法都可以。

回答by Vikky

Changing JDK from 1.6 to 1.7 worked for me.

将 JDK 从 1.6 更改为 1.7 对我有用。

回答by user3172374

create a folder called endorsed and put these jar files in it 1.jaxb-api-2.2.jar 2.jaxws-api.jar put the folder in tomcat server as C:\tomcat-7.50\< created folder> and run it will works

创建一个名为endorsed的文件夹并将这些jar文件放入其中 1.jaxb-api-2.2.jar 2.jaxws-api.jar 将文件夹放入tomcat服务器中为C:\tomcat-7.50\<已创建文件夹>并运行它将作品