cloudsoft / winrm4j

Apache License 2.0
93 stars 53 forks source link

NullPointerException During executeCommand #145

Open jrsmiley opened 3 years ago

jrsmiley commented 3 years ago

I'm getting the following error while executing a simple command with executeCommand:

Source code:

  1 package com.citadel.bootcamp;
  2
  3 import io.cloudsoft.winrm4j.client.WinRmClientContext;
  4 import io.cloudsoft.winrm4j.winrm.WinRmTool;
  5 import io.cloudsoft.winrm4j.winrm.WinRmToolResponse;
  6 import org.apache.http.client.config.AuthSchemes;
  7
  8 public class HelloMSW {
  9   public static void main(String[] args) {
 10     WinRmClientContext context = WinRmClientContext.newInstance();
 11
 12     WinRmTool tool = WinRmTool.Builder.builder("wd-qts-gidb197", "", "")
 13         .authenticationScheme(AuthSchemes.KERBEROS)
 14         .port(5985)
 15         .useHttps(false)
 16         .disableCertificateChecks(true)
 17         .context(context)
 18         .build();
 19
 20     if (tool == null) {
 21         System.out.println("Failed to build WinRM tool\n");
 22     } else {
 23         WinRmToolResponse resp = tool.executeCommand("echo hi");
 24     }
 25
 26
 27     context.shutdown();
 28   }
 29 }

Error:

Oct 05, 2021 11:53:21 AM io.cloudsoft.winrm4j.client.WinRmFactory createService
WARNING: Error creating WinRm service with mbean strategy (trying other strategies): java.lang.NullPointerException
java.lang.NullPointerException
        at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:85)
        at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:393)
        at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:527)
        at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:262)
        at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:199)
        at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:103)
        at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:91)
        at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:159)
        at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:142)
        at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:95)
        at io.cloudsoft.winrm4j.client.WinRmFactory.doCreateServiceWithBean(WinRmFactory.java:140)
        at io.cloudsoft.winrm4j.client.WinRmFactory.createService(WinRmFactory.java:44)
        at io.cloudsoft.winrm4j.client.WinRmFactory.newInstance(WinRmFactory.java:32)
        at io.cloudsoft.winrm4j.client.WinRmClient.getService(WinRmClient.java:244)
        at io.cloudsoft.winrm4j.client.WinRmClient.<init>(WinRmClient.java:220)
        at io.cloudsoft.winrm4j.client.WinRmClientBuilder.build(WinRmClientBuilder.java:285)
        at io.cloudsoft.winrm4j.winrm.WinRmTool.executeCommand(WinRmTool.java:396)
        at io.cloudsoft.winrm4j.winrm.WinRmTool.executeCommand(WinRmTool.java:341)
        at com.citadel.bootcamp.HelloMSW.main(HelloMSW.java:23)

Oct 05, 2021 11:53:21 AM io.cloudsoft.winrm4j.client.WinRmFactory createService
WARNING: Error creating WinRm service with reflective delegate (trying other strategies): java.lang.NullPointerException
java.lang.NullPointerException
        at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:85)
        at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:217)
        at org.apache.cxf.jaxws.ServiceImpl.initialize(ServiceImpl.java:160)
        at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:128)
        at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:82)
        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:144)
        at io.cloudsoft.winrm4j.client.WinRmFactory.doCreateServiceWithReflectivelySetDelegate(WinRmFactory.java:86)
        at io.cloudsoft.winrm4j.client.WinRmFactory.createService(WinRmFactory.java:61)
        at io.cloudsoft.winrm4j.client.WinRmFactory.newInstance(WinRmFactory.java:32)
        at io.cloudsoft.winrm4j.client.WinRmClient.getService(WinRmClient.java:244)
        at io.cloudsoft.winrm4j.client.WinRmClient.<init>(WinRmClient.java:220)
        at io.cloudsoft.winrm4j.client.WinRmClientBuilder.build(WinRmClientBuilder.java:285)
        at io.cloudsoft.winrm4j.winrm.WinRmTool.executeCommand(WinRmTool.java:396)
        at io.cloudsoft.winrm4j.winrm.WinRmTool.executeCommand(WinRmTool.java:341)
        at com.citadel.bootcamp.HelloMSW.main(HelloMSW.java:23)

Oct 05, 2021 11:53:21 AM io.cloudsoft.winrm4j.client.WinRmFactory createService
WARNING: Error creating WinRm service with many strategies (giving up): java.lang.NullPointerException
java.lang.NullPointerException
        at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:85)
        at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:217)
        at org.apache.cxf.jaxws.ServiceImpl.initialize(ServiceImpl.java:160)
        at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:128)
        at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:82)
        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:144)
        at io.cloudsoft.winrm4j.client.WinRmFactory.doCreateServiceNormal(WinRmFactory.java:79)
        at io.cloudsoft.winrm4j.client.WinRmFactory.createService(WinRmFactory.java:68)
        at io.cloudsoft.winrm4j.client.WinRmFactory.newInstance(WinRmFactory.java:32)
        at io.cloudsoft.winrm4j.client.WinRmClient.getService(WinRmClient.java:244)
        at io.cloudsoft.winrm4j.client.WinRmClient.<init>(WinRmClient.java:220)
        at io.cloudsoft.winrm4j.client.WinRmClientBuilder.build(WinRmClientBuilder.java:285)
        at io.cloudsoft.winrm4j.winrm.WinRmTool.executeCommand(WinRmTool.java:396)
        at io.cloudsoft.winrm4j.winrm.WinRmTool.executeCommand(WinRmTool.java:341)
        at com.citadel.bootcamp.HelloMSW.main(HelloMSW.java:23)

Exception in thread "main" java.lang.NullPointerException
        at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:85)
        at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:217)
        at org.apache.cxf.jaxws.ServiceImpl.initialize(ServiceImpl.java:160)
        at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:128)
        at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:82)
        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:144)
        at io.cloudsoft.winrm4j.client.WinRmFactory.doCreateServiceNormal(WinRmFactory.java:79)
        at io.cloudsoft.winrm4j.client.WinRmFactory.createService(WinRmFactory.java:68)
        at io.cloudsoft.winrm4j.client.WinRmFactory.newInstance(WinRmFactory.java:32)
        at io.cloudsoft.winrm4j.client.WinRmClient.getService(WinRmClient.java:244)
        at io.cloudsoft.winrm4j.client.WinRmClient.<init>(WinRmClient.java:220)
        at io.cloudsoft.winrm4j.client.WinRmClientBuilder.build(WinRmClientBuilder.java:285)
        at io.cloudsoft.winrm4j.winrm.WinRmTool.executeCommand(WinRmTool.java:396)
        at io.cloudsoft.winrm4j.winrm.WinRmTool.executeCommand(WinRmTool.java:341)
        at com.citadel.bootcamp.HelloMSW.main(HelloMSW.java:23)