NullPointerException occurs when using vSphere Management WebServices SDK with Java 11
search cancel

NullPointerException occurs when using vSphere Management WebServices SDK with Java 11


Article ID: 311939


Updated On:


VMware vCenter Server


Using vSphere Management SDK with Java 11 may result in NullPointerException. The exception is seen when com.vmware.vim25#VimService() attempts to call constructor.

[29193] 2022-07-29 02:01:44.323 [ERROR] [Collector worker thread 18] com.emc.vcops.collectors.vmware.VmwareCollector [collect] [214] - error collecting vcenter ip=
[29194] java.lang.NullPointerException: null
[29195] at<init>( ~[jaxws-api-2.3.1.jar:?]
[29196] at com.vmware.vim25.VimService.<init>( ~[vim25-7.0.3-20034407.jar:?]
[29197] at<init>( ~[vsphere-adapter-java-1.9.0-SNAPSHOT.jar:?]
[29198] at com.emc.vcops.collectors.vmware.VmwareCollector.collect
( ~[emc-vcops-adapter-collectors-vmware-7.1.0-SNAPSHOT.jar:?]
[29199] at com.emc.vcops.moxy.EmcAdapterInstance.collect
( ~[emc-vcops-adapter.jar:?]
[29200] at com.emc.vcops.moxy.EmcAdapterInstance.onCollect
( ~[emc-vcops-adapter.jar:?]
[29201] at com.integrien.alive.common.adapter3.AdapterBase.collectBase
( ~[vrops-adapters-sdk.jar:?]
[29202] at com.integrien.alive.common.adapter3.AdapterBase.collect
( ~[vrops-adapters-sdk.jar:?]
[29203] at com.emc.vcops.EmcAdapter.collect( ~[emc-vcops-adapter.jar:?]
[29204] at
( ~[vcops-collector-1.0-SNAPSHOT.jar:?]
[29205] at com.integrien.alive.common.util.ThreadPool$
( ~[vrops-adapters-sdk.jar:?]
[29206] at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[?:?]
[29207] at java.util.concurrent.ThreadPoolExecutor$ Source) ~[?:?]


VMware vCenter Server 7.0.3


This is a known bug in jaxws-ri (verion < 3.0.1) The issue happens if osgi-resource-locator is in Java 11 classpath, as explained in the below link :
Call to Provider.provider() from constructors returns null in Java 11 if osgi-resource-locator is in the classpath. This jar can be in the classpath as a result of a transitive dependency. The cause of the NullPointerException is the call to isOSGi() from can return true in Java 11 even if the application is not OSGi; whereas in Java 8, the call would return false under the same circumstance.


This issue was fixed in jaxws-ri version 3.0.1: .

Updating the jaxws-ri library version to 3.0.1 would have solved the issue. However, vSphere Management SDK Java bundles and uses jaxws-ri version 2.3.3, stubs generated with this jaxws-ri version has "" in service stubs. Since, jaxws-ri changed their package namespace from  javax.* to jakarta.*. 

After updating the library, Stubs need to be re-generated and compiled. Follow the below steps.

Re-generate stubs using higher version of jaxws-ri.

1. Download jaxws-ri version 3.0.1 or higher and replace it with existing jaxws-ri under the SDK/libs directory.
    a. Link to JAX WS RI Standalone Zipped Bundle via various repositories:                                              

2. Re-generate client bindings(ssoclient.jar/vim25.jar) using WSDL files from SDK. Since vsphere-ws
    has a dependency on sso client, the sso client library and samples (sso.jar) need to be built first.

    a. Existing samples across SDK's sub-directries, viz. ssoclient, vsphere-ws, eam, sms-sdk, spbm and vslm
        must be updated. i.e. Following import statements should be changed from 
       "*", "javax.xml.bind.*" and "javax.xml.soap.*"
    to "*", "jakarta.xml.bind.*" and "jakarta.xml.soap.*"

    b. ssoclient : Scripts to build the sso jar and the samples are present under (SDK/ssoclient/java/JAXWS)
         1. Run the command "build_ssoclient.bat" to compile and generate stubs
         2. Run "build.bat" to compile sample programs

    c. vsphere-ws : Re-generate vim25 jar using the build scripts under (SDK/vsphere-ws/java/JAXWS)
         1. build_vim25.bat compile and generate stubs
         2. build_samples.bat Compiles sample programs (before compiling samples update the import
    d. For rest of the libraries repeat the steps under each sub directories, i.e. eam, sms-sdk, spbm and

Note : build-*.sh scripts can also be used for re-generating and compiling client stubs.

For detailed steps follow README under each of the SDK component. 
E.g for ssoclient "SDK/ssoclient/java/JAXWS/readme_java.html#stub_generation" and for vsphere-ws "SDK/vsphere-ws/java/JAXWS/readme_java.html"

No workaround available.