Metro 的 Eclipse RCP 类加载问题
我正在尝试使用 Eclipse RCP 应用程序中的 Metro 库 调用 Web 服务。我将相关的 Metro jar(webservices-tools.jar
、webservices-rt.jar
和 webservices-api.jar
)捆绑到一个插件中并使我的主要应用程序插件依赖于这个新的 Metro 插件。
我还将 webservices-api.jar
添加到我的 $JAVA_HOME/jre/lib/endorsed
目录中。根据 Metro 网站,这是在 Java 1.6 中使用 Metro 时所必需的。
现在,当我调用任何 Web 服务时,都会收到以下错误:
javax.xml.ws.WebServiceException: Provider com.sun.xml.ws.spi.ProviderImpl not found
at javax.xml.ws.spi.FactoryFinder.newInstance(FactoryFinder.jav a:38)
at javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:133)
at javax.xml.ws.spi.Provider.provider(Provider.java:83)
at javax.xml.ws.Service.<init>(Service.java:56)
...
Caused by: java.lang.ClassNotFoundException: com.sun.xml.ws.spi.ProviderImpl
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301 )
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at org.eclipse.core.runtime.internal.adaptor.ContextFinder.load Class(ContextFinder.java:129)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at javax.xml.ws.spi.FactoryFinder.newInstance(FactoryFinder.jav a:34)
... 43 more
com.sun.xml.ws.spi.ProviderImpl
类驻留在 webservices-rt.jar
中,其中是我的 Metro 插件的一部分。此外,我已经验证我的应用程序插件代码可以成功加载此类,所以我不确定为什么 javax.xml.ws.spi.FactoryFinder
不能。
由于 javax.xml.ws.spi.FactoryFinder
驻留在 webservices-api.jar
(我必须将其放入 jre 认可的目录中的 jar)中,我怀疑这已经与无法从 Eclipse 插件加载类的认可代码有关。
JVM 从认可目录加载的代码是否无法从插件加载类?有什么方法可以启用此功能吗?
Java 版本:1.6.0_16
Eclipse 版本:面向 Web 开发人员的 Eclipse Java EE IDE 版本 ID:20090920-1017(不显示超出该版本的版本)
Metro 版本:与 Glassfish 2.1 捆绑在一起
非常感谢任何帮助。谢谢。
I am attempting to invoke a web service using the Metro library from within an Eclipse RCP application. I bundled the relevant Metro jars (webservices-tools.jar
, webservices-rt.jar
, and webservices-api.jar
) into a plugin and made my main application plugin depend on this new Metro plugin.
I also added the webservices-api.jar
to my $JAVA_HOME/jre/lib/endorsed
directory. According to the Metro website, this is required when using Metro with Java 1.6.
Now when I invoke any web service, I get the following error:
javax.xml.ws.WebServiceException: Provider com.sun.xml.ws.spi.ProviderImpl not found
at javax.xml.ws.spi.FactoryFinder.newInstance(FactoryFinder.jav a:38)
at javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:133)
at javax.xml.ws.spi.Provider.provider(Provider.java:83)
at javax.xml.ws.Service.<init>(Service.java:56)
...
Caused by: java.lang.ClassNotFoundException: com.sun.xml.ws.spi.ProviderImpl
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301 )
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at org.eclipse.core.runtime.internal.adaptor.ContextFinder.load Class(ContextFinder.java:129)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at javax.xml.ws.spi.FactoryFinder.newInstance(FactoryFinder.jav a:34)
... 43 more
The class com.sun.xml.ws.spi.ProviderImpl
resides in webservices-rt.jar
, which is a part of my Metro plugin. Furthermore, I have verified that my application plugin code can successfully load this class, so I'm not sure why javax.xml.ws.spi.FactoryFinder
can't.
Since javax.xml.ws.spi.FactoryFinder
resides in webservices-api.jar
(the jar I had to put in the jre's endorsed directory), I suspect that this has something to do with endorsed code not being able to load classes from an Eclipse plugin.
Is it the case that code loaded by the JVM from the endorsed directory cannot load classes from plugins? Is there any way to enable this?
Java version: 1.6.0_16
Eclipse version: Eclipse Java EE IDE for Web Developers Build id: 20090920-1017 (it doesn't display a version beyond that)
Metro version: Bundled with Glassfish 2.1
Any help is greatly appreciated. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于遇到这个问题的其他人,我能够找到解决方案。我使用这些 JVM 选项将 Metro jar 以及包含 wsit 配置文件的 config 目录添加到 JVM 的启动类路径中:
webservices-api.jar
不再需要位于$ 中JAVA_HOME/jre/lib/endorsed
才能正常工作。它当然不是正常的 Eclipse 模型,但这是我发现在具有 Java 1.6 的 Eclipse RCP 应用程序中使用 Metro 的唯一方法。For anyone else who runs into this problem, I was able to find a solution. I added the metro jars, along with the config directory containing my wsit configuration files, to the JVM's boot classpath using these JVM options:
The
webservices-api.jar
no longer needs to be in$JAVA_HOME/jre/lib/endorsed
for this to work. It is certainly not the normal Eclipse model, but this is the only way I have found to use Metro within an Eclipse RCP application with Java 1.6.Java SE 6 已经包含了 Metro。它包含 jax-ws 2.0,因此您可以完全删除这些 jar。
仅当您有特定需要将 jax-ws 2.1 与 java SE 6 一起使用时,您可以按照此处的说明进行操作 -> https://jax-ws.dev.java.net/faq/index.html html
编辑:您最后的评论是正确的。放置在认可文件夹中的代码是使用认可类加载器加载的,因此它无法找到位于插件中的类。我建议您将所有 Metro jar 放在认可的目录中。这样它们不仅可用于您的插件,还可用于整个虚拟机。
Java SE 6 already includes metro. It includes jax-ws 2.0, so you can remove those jars completely.
Only if you have specific need to use jax-ws 2.1 together with java SE 6, you can follow the instructions here -> https://jax-ws.dev.java.net/faq/index.html
EDIT: You are right about your last comment. Code placed in the endorsed folder is loaded with the endorsed class loader, so it can't find classes that are located in the plugins. I suggest that you put the all the metro jars in the endorsed dir. This way they'll be available not only for your plug-in, but for the entire VM.