cloudsoft / winrm4j

Apache License 2.0
93 stars 53 forks source link

Error creating WinRm service with mbean strategy (trying other strategies): java.lang.NullPointerException #75

Open sagalaprasad opened 7 years ago

sagalaprasad commented 7 years ago

Hi All,

I am trying to run the below code using groovy file, it works fine. But same code i integrated with groovy standalone project using gradle, i am getting below error. Can any one help to solve the issue.

Below code i am trying to connect with window box and run the power shell command and print the output in console.

@Grapes([ @Grab(group='commons-codec', module='commons-codec', version='1.10'), @Grab(group='io.cloudsoft.windows', module='winrm4j', version='0.5.0') ]) import io.cloudsoft.winrm4j.client.WinRmClientContext; import io.cloudsoft.winrm4j.winrm.WinRmTool; import org.apache.http.client.config.AuthSchemes;

WinRmClientContext context = WinRmClientContext.newInstance(); WinRmTool.Builder builder = WinRmTool.Builder.builder("192.168.13.27", "administrator", "xyz"); builder.setAuthenticationScheme(AuthSchemes.NTLM); builder.port(5985); builder.useHttps(false); builder.context(context); builder.environment(map); WinRmTool tool = builder.build(); def winToolResp = tool.executePs("echo hi;") println "${winToolResp.statusCode} ::: Output ::: ${winToolResp.getStdOut()}"

ERROR::::

winrm4j.client.WinRmClient - Error creating WinRm service with mbean strategy (trying other strategies): java.lang.NullPointerException java.lang.NullPointerException: null at org.apache.cxf.wsdl11.WSDLServiceFactory.(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:102) at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:91) at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:157) at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:142) at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:93) at io.cloudsoft.winrm4j.client.WinRmClient.doCreateServiceWithBean_Part1(WinRmClient.java:622) at io.cloudsoft.winrm4j.client.WinRmClient.doCreateServiceWithBean(WinRmClient.java:611) at io.cloudsoft.winrm4j.client.WinRmClient.createService(WinRmClient.java:518) at io.cloudsoft.winrm4j.client.WinRmClient.getService(WinRmClient.java:502) at io.cloudsoft.winrm4j.client.WinRmClient.command(WinRmClient.java:316) at io.cloudsoft.winrm4j.winrm.WinRmTool.executeCommand(WinRmTool.java:243) at io.cloudsoft.winrm4j.winrm.WinRmTool.executePs(WinRmTool.java:258)

Thanks, Prasad

guianchen commented 5 years ago

also met this issue while trying to jar-with-dependencies

jrsmiley commented 3 years ago

I also have this issue.

josephmate commented 7 months ago

My workaround was to avoid jar-with-dependencies like @guianchen notes is the root cause.