eclipse JAX-WS 和版本冲突

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7580803/
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-09-19 17:03:51  来源:igfitidea点击:

JAX-WS and version conflicts

javaeclipseweb-services

提问by strauberry

As test project I've create a very simple WebService using wsdl and jax-ws. The client runs very well if it is deployed as web application in GlassFish but if I start the same (WebService-)Code in Eclipse directly, I get the following error:

作为测试项目,我使用 wsdl 和 jax-ws 创建了一个非常简单的 WebService。如果客户端在 GlassFish 中部署为 Web 应用程序,则该客户端运行良好,但如果我直接在 Eclipse 中启动相同的 (WebService-)Code,则会出现以下错误:

WARNUNG: Input Action on WSDL operation AddNumbers and @Action on its associated Web Method addNumbers did not match and will cause problems in dispatching the requests
Exception in thread "main" java.lang.NoClassDefFoundError: org/glassfish/ha/store/api/BackingStoreException
    at com.sun.xml.ws.rx.mc.runtime.McConfigurationFactory.createInstance(McConfigurationFactory.java:66)
    at com.sun.xml.ws.rx.mc.runtime.McTubeFactory.createTube(McTubeFactory.java:68)
    at com.sun.xml.ws.assembler.TubeCreator.createTube(TubeCreator.java:84)
    at com.sun.xml.ws.assembler.TubelineAssemblerFactoryImpl$MetroTubelineAssembler.createClient(TubelineAssemblerFactoryImpl.java:130)
    at com.sun.xml.ws.client.Stub.createPipeline(Stub.java:228)
    at com.sun.xml.ws.client.Stub.<init>(Stub.java:205)
    at com.sun.xml.ws.client.Stub.<init>(Stub.java:178)
    at com.sun.xml.ws.client.sei.SEIStub.<init>(SEIStub.java:85)
    at com.sun.xml.ws.client.WSServiceDelegate.createEndpointIFBaseProxy(WSServiceDelegate.java:608)
    at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:348)
    at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:330)
    at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:312)
    at javax.xml.ws.Service.getPort(Service.java:134)
    at mnm.namedesdienstes.webservice.service.NameDesDienstesService.getNameDesDienstesPortTypePort(NameDesDienstesService.java:56)
    at webserviceClient.NameDesDienstesClient.myTest(NameDesDienstesClient.java:12)
    at webserviceClient.NameDesDienstesClient.main(NameDesDienstesClient.java:25)
Caused by: java.lang.ClassNotFoundException: org.glassfish.ha.store.api.BackingStoreException
    at java.net.URLClassLoader.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 16 more

After some research I found out that it must have something to do with different versions of some library files. So now my question is, how can I "fix" my eclipse java execution to run my webservice client correctly? I've found some tips to copy some jar to an endorsed-directory, but which jars into which directory :-)

经过一番研究,我发现它一定与某些库文件的不同版本有关。所以现在我的问题是,如何“修复”我的 eclipse java 执行以正确运行我的 webservice 客户端?我找到了一些将一些 jar 复制到认可目录的技巧,但是将哪些 jar 复制到哪个目录中:-)

I'm using Max OS 10.6.8, Eclipse Project uses JVM 1.6. My Mac Java Version is

我使用的是 Max OS 10.6.8,Eclipse 项目使用 JVM 1.6。我的 Mac Java 版本是

xmacbook:~ cstraube$ java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03-384-10M3425)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02-384, mixed mode)

UPDATE: My first try (thanks to the link from remipod) I performed the following steps:

更新:我的第一次尝试(感谢来自 remipod 的链接)我执行了以下步骤:

  1. Get the directory of endorsed lirbaries with System.out.println(System.getProperty("java.endorsed.dirs"));
  2. Next, I copied the two files JAXWS2.1.7-20090419.jar and JAXB2_20080513.jar (both Version 2.1.7) into this directory
  3. Unfortunately I get still the same error
  1. 获取认可图书馆的目录 System.out.println(System.getProperty("java.endorsed.dirs"));
  2. 接下来,我将 JAXWS2.1.7-20090419.jar 和 JAXB2_20080513.jar(均为 2.1.7 版)两个文件复制到此目录中
  3. 不幸的是,我仍然遇到同样的错误

采纳答案by strauberry

You have to copy the fittingversions of jaxws-api.jar and jaxb-api.jar into the directory /Library/Java/Home/lib/endorsed (Mac).

您必须将jaxws-api.jar 和 jaxb-api.jar的适配版本复制到目录 /Library/Java/Home/lib/endorsed (Mac) 中。

回答by indrap

I have similar problem with yours when deploying web service (JAX-WS) in tomcat 7. The missing class definition could be found in ha-api.jar.

org/glassfish/ha/store/api/BackingStoreException

在 tomcat 7 中部署 Web 服务 (JAX-WS) 时,我遇到了与您类似的问题。可以在 ha-api.jar 中找到缺少的类定义。

org/glassfish/ha/store/api/BackingStoreException

You should add the ha-api.jar (From JAX-WS distribution) into server lib. For my case, the eclipse run tomcat 7, so the location is (Tomcat 7.0\lib).

您应该将 ha-api.jar(来自 JAX-WS 发行版)添加到服务器库中。就我而言,eclipse运行的是tomcat 7,所以位置是(Tomcat 7.0\lib)。

回答by remipod

Have a look at this link JAX WS with WS 2.1.1. You will need to give precedence to your version of jaxws to the provided jaxws from the jre 1.6.

看看这个链接JAX WS with WS 2.1.1。您需要将您的 jaxws 版本优先于 jre 1.6 中提供的 jaxws。

Edit:Glassfish already includes some libraries, as well as java 6. I had to track down version conflicts with jaxws in glassfish 3.1 / 3.1.1 and java 6 / 7. You might check the exact java runtime eclipse uses to start the application and look for duplicate jars on the effective classpath.

编辑:Glassfish 已经包含一些库,以及 java 6。我必须在 glassfish 3.1/3.1.1 和 java 6/7 中跟踪与 jaxws 的版本冲突。您可以检查 eclipse 用于启动应用程序的确切 java 运行时和在有效的类路径上寻找重复的 jars。

The endorsed mechanism just provides an easy and error prone way to override the included jaxws distribution. Error prone, because your colleague will suffer from the same problem.

背书机制只是提供了一种简单且容易出错的方法来覆盖包含的 jaxws 分发。容易出错,因为你的同事也会遇到同样的问题。

I havn't seen the exception org.glassfish.ha.store.api.BackingStoreException in the context of jaxws. Your version conflict could be created by another library than jaxws...

我还没有在 jaxws 的上下文中看到异常 org.glassfish.ha.store.api.BackingStoreException。您的版本冲突可能是由 jaxws 以外的其他库创建的...

回答by Continuity8

I experienced the exact same exception

我经历了完全相同的异常

org.glassfish.ha.store.api.BackingStoreException

org.glassfish.ha.store.api.BackingStoreException

And after ensuring my JAX-WS and JAX-B jars were all the same version the issue was still occurring.

在确保我的 JAX-WS 和 JAX-B jar 都是相同的版本后,问题仍然存在。

THE FIX: I then added the ha-api.jarto the WEB-INF\lib directory and this solved the issue.

修复:然后我将它添加ha-api.jar到 WEB-INF\lib 目录,这解决了这个问题。

The clue here was the "ha" package in the exceptions class path as seen above. Hope this helps!

这里的线索是异常类路径中的“ha”包,如上所示。希望这可以帮助!