Jenkins尝试通过Java库连接时出现连接失败。

huangapple go评论77阅读模式
英文:

Jenkins connection failure when trying to connect via Java library

问题

我正在开发一个 Jenkins 插件,该插件将能够使用一个 Java 库和 WinRm 连接到远程 Windows 机器。我正在使用 JDK 11.0.8,这是库的链接:https://github.com/cloudsoft/winrm4j。每当我尝试连接时,我都会遇到以下错误:

找不到提供程序 com.sun.xml.internal.ws.spi.ProviderImpl。

我认为 Jenkins 更喜欢使用内置的解析器,而不是使用我在 pom.xml 中提供的解析器。我已经尝试过检查问题,有些人通过将 rtwoodstoxjaxws-rt 等库导入到 pom 文件中来解决问题,但在我的情况下,这个解决方案并没有成功。此外,我还尝试在 Eclipse 中手动导入了这个包 com.sun.xml.internal.ws,但没有成功。

我该如何解决这个问题?

这是完整的错误堆栈:

2020-10-15 14:37:50.553+0000 [id=75]	WARNING	i.c.winrm4j.client.WinRmFactory#createService: Error creating WinRm service with reflective delegate (trying other strategies): javax.xml.ws.WebServiceException: Provider com.sun.xml.internal.ws.spi.ProviderImpl not found
java.lang.ClassNotFoundException: com.sun.xml.internal.ws.spi.ProviderImpl
	...
	at javax.xml.ws.spi.ServiceLoaderUtil.newInstance(ServiceLoaderUtil.java:101)
Caused: javax.xml.ws.WebServiceException: Provider com.sun.xml.internal.ws.spi.ProviderImpl not found
	...
	at io.cloudsoft.winrm4j.client.WinRmFactory.newInstance(WinRmFactory.java:21)
	...
	at fr.edf.jenkins.plugins.windows.winrm.WinRMCommandLauncher.executeCommand(WinRMCommandLauncher.groovy:24)
	...
	at io.cloudsoft.winrm4j.winrm.WinRmTool$executePs.call(Unknown Source)
	...
	at fr.edf.jenkins.plugins.windows.winrm.WinRMCommand.checkConnection(WinRMCommand.groovy:21)
	...
	at fr.edf.jenkins.plugins.windows.WindowsHost$DescriptorImpl.doVerifyConnection(WindowsHost.groovy:226)
	...
英文:

I am developing a Jenkins plugin which will be able to connect to a remote Windows machine using a java library and WinRm. I am using JDK 11.0.8, here is the link to the library https://github.com/cloudsoft/winrm4j, anytime I try to connect I have the following error :

Provider com.sun.xml.internal.ws.spi.ProviderImpl not found.

I think Jenkins prefers to use a built-in parser instead of using the one provided in my pom.xml.
I have tried to check the problem, for some it has been solved by importing libraries like rt, woodstox or jaxws-rt to the pom file however in my case this solution has not been successful. Moreover I have tried to manually import this package com.sun.xml.internal.ws in eclipse but to no avail.

How can I solve this issue?

Here is the full error stack

2020-10-15 14:37:50.553+0000 [id=75]	WARNING	i.c.winrm4j.client.WinRmFactory#createService: Error creating WinRm service with reflective delegate (trying other strategies): javax.xml.ws.WebServiceException: Provider com.sun.xml.internal.ws.spi.ProviderImpl not found
java.lang.ClassNotFoundException: com.sun.xml.internal.ws.spi.ProviderImpl
at org.jenkinsci.maven.plugins.hpi.JettyAndServletApiOnlyClassLoader.findClass(JettyAndServletApiOnlyClassLoader.java:38)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:543)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at javax.xml.ws.spi.ServiceLoaderUtil.nullSafeLoadClass(ServiceLoaderUtil.java:90)
at javax.xml.ws.spi.ServiceLoaderUtil.safeLoadClass(ServiceLoaderUtil.java:123)
at javax.xml.ws.spi.ServiceLoaderUtil.newInstance(ServiceLoaderUtil.java:101)
Caused: javax.xml.ws.WebServiceException: Provider com.sun.xml.internal.ws.spi.ProviderImpl not found
at javax.xml.ws.spi.FactoryFinder$1.createException(FactoryFinder.java:61)
at javax.xml.ws.spi.FactoryFinder$1.createException(FactoryFinder.java:58)
at javax.xml.ws.spi.ServiceLoaderUtil.newInstance(ServiceLoaderUtil.java:103)
at javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:112)
at javax.xml.ws.spi.Provider.provider(Provider.java:96)
at javax.xml.ws.Service.<init>(Service.java:112)
at io.cloudsoft.winrm4j.client.WinRmService.<init>(WinRmService.java:44)
at io.cloudsoft.winrm4j.client.WinRmFactory.doCreateService_1_CreateMinimalServiceInstance(WinRmFactory.java:101)
at io.cloudsoft.winrm4j.client.WinRmFactory.doCreateServiceWithReflectivelySetDelegate(WinRmFactory.java:72)
at io.cloudsoft.winrm4j.client.WinRmFactory.createService(WinRmFactory.java:47)
at io.cloudsoft.winrm4j.client.WinRmFactory.newInstance(WinRmFactory.java:21)
at io.cloudsoft.winrm4j.client.WinRmClient.getService(WinRmClient.java:224)
at io.cloudsoft.winrm4j.client.WinRmClient.<init>(WinRmClient.java:205)
at io.cloudsoft.winrm4j.client.WinRmClientBuilder.build(WinRmClientBuilder.java:278)
at io.cloudsoft.winrm4j.winrm.WinRmTool.executeCommand(WinRmTool.java:347)
at io.cloudsoft.winrm4j.winrm.WinRmTool.executePs(WinRmTool.java:364)
at io.cloudsoft.winrm4j.winrm.WinRmTool$executePs.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at fr.edf.jenkins.plugins.windows.winrm.WinRMCommandLauncher.executeCommand(WinRMCommandLauncher.groovy:24)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite$StaticMetaMethodSiteNoUnwrapNoCoerce.invoke(StaticMetaMethodSite.java:151)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:91)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
at fr.edf.jenkins.plugins.windows.winrm.WinRMCommand.checkConnection(WinRMCommand.groovy:21)
at fr.edf.jenkins.plugins.windows.winrm.WinRMCommand$checkConnection.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at fr.edf.jenkins.plugins.windows.WindowsHost$DescriptorImpl.doVerifyConnection(WindowsHost.groovy:226)
at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:710)
at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:396)
at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:408)
at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:212)
at org.kohsuke.stapler.SelectionInterceptedFunction$Adapter.invoke(SelectionInterceptedFunction.java:36)
at org.kohsuke.stapler.verb.HttpVerbInterceptor.invoke(HttpVerbInterceptor.java:48)
at org.kohsuke.stapler.SelectionInterceptedFunction.bindAndInvoke(SelectionInterceptedFunction.java:26)
at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:145)
at org.kohsuke.stapler.MetaClass$11.doDispatch(MetaClass.java:536)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:766)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:898)
at org.kohsuke.stapler.MetaClass$4.doDispatch(MetaClass.java:281)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:766)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:898)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:694)
at org.kohsuke.stapler.Stapler.service(Stapler.java:240)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:763)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1631)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:154)
at jenkins.telemetry.impl.UserLanguages$AcceptLanguageFilter.doFilter(UserLanguages.java:129)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
at jenkins.security.ResourceDomainFilter.doFilter(ResourceDomainFilter.java:76)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:157)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:153)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:90)
at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:51)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
at jenkins.security.SuspiciousRequestFilter.doFilter(SuspiciousRequestFilter.java:36)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:549)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:578)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1610)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1369)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:489)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1580)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1284)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:221)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:146)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
at org.eclipse.jetty.server.Server.handle(Server.java:501)
at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:383)
at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:556)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:375)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:273)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:375)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:806)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:938)
at java.base/java.lang.Thread.run(Thread.java:834)
2020-10-15 14:37:50.562+0000 [id=75]	WARNING	i.c.winrm4j.client.WinRmFactory#createService: Error creating WinRm service with many strategies (giving up): javax.xml.ws.WebServiceException: Provider com.sun.xml.internal.ws.spi.ProviderImpl not found

答案1

得分: 2

根据您的堆栈跟踪,Java类加载器正在委派给:

org.jenkinsci.maven.plugins.hpi.JettyAndServletApiOnlyClassLoader.findClass()

这个类没有机会加载以“com.sun.xml.”开头的类:

protected Class<?> findClass(String name) throws ClassNotFoundException {
if (name.startsWith("javax.")
|| name.startsWith("org.eclipse.jetty."))
return jettyClassLoader.loadClass(name);
else
throw new ClassNotFoundException(name);
}

来源:https://github.com/jenkinsci/maven-hpi-plugin/blob/master/src/main/java/org/jenkinsci/maven/plugins/hpi/JettyAndServletApiOnlyClassLoader.java

英文:

According to your stacktrace, Java class loader is delegating to :

org.jenkinsci.maven.plugins.hpi.JettyAndServletApiOnlyClassLoader.findClass()

which has no chance to load a class beginning with "com.sun.xml." :

protected Class<?> findClass(String name) throws ClassNotFoundException {
if (name.startsWith("javax.")
|| name.startsWith("org.eclipse.jetty."))
return jettyClassLoader.loadClass(name);
else
throw new ClassNotFoundException(name);
}

source : https://github.com/jenkinsci/maven-hpi-plugin/blob/master/src/main/java/org/jenkinsci/maven/plugins/hpi/JettyAndServletApiOnlyClassLoader.java

huangapple
  • 本文由 发表于 2020年10月15日 22:49:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/64374224.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定