VMware {code} Community
mohgeis
Contributor
Contributor

Java Error while creating the virtual machine

Hi,

I am trying to create a VirtualMachine with vim25.jar, when i got below error

Exception in thread "main" javax.xml.ws.soap.SOAPFaultException:

Required property device is missing from data object of type VirtualDeviceConfigSpec

while parsing serialized DataObject of type vim.vm.device.VirtualDeviceSpec

at line 1, column 1659

while parsing property "deviceChange" of static type ArrayOfVirtualDeviceConfigSpec

while parsing serialized DataObject of type vim.vm.ConfigSpec

at line 1, column 164

while parsing call information for method CreateVM_Task

at line 1, column 94

while parsing SOAP body

at line 1, column 86

while parsing SOAP envelope

at line 1, column 22

while parsing HTTP request for method createVm

on object of type vim.Folder

at line 1, column 0

  at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)

  at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:119)

  at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)

  at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)

  at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:129)

  at $Proxy35.createVMTask(Unknown Source)

  at com.ericsson.jcat.rdav.vmware.objectTypes.VirtualMachine.createVirtualMachine(VirtualMachine.java:308)

  at com.ericsson.jcat.rdav.vmware.objectTypes.VirtualMachine.main(VirtualMachine.java:634)

Above error is coming after the connection has been established successfully. excactly in this command.

ManagedObjectReference taskmor = vimPort.createVMTask(vmFolderMor, vmConfigSpec, resourcepoolmor, hostmor);

I was running the VMcreate.java sample file. below part is the vm create method:

void createVirtualMachine() throws RemoteException, RuntimeFaultFaultMsg, InvalidPropertyFaultMsg,

            InvalidCollectorVersionFaultMsg, OutOfBoundsFaultMsg, DuplicateNameFaultMsg, VmConfigFaultFaultMsg,

            InsufficientResourcesFaultFaultMsg, AlreadyExistsFaultMsg, InvalidDatastoreFaultMsg, FileFaultFaultMsg,

            InvalidStateFaultMsg, InvalidNameFaultMsg, TaskInProgressFaultMsg {

        ManagedObjectReference dcmor = getMOREFsInContainerByType(serviceContent.getRootFolder(), "Datacenter").get(dataCenterName);

        if (dcmor == null) {

            System.out.println("Datacenter " + dataCenterName + " not found.");

            return;

        }

        ManagedObjectReference hostmor = getMOREFsInContainerByType(dcmor, "HostSystem").get(hostname);

        if (hostmor == null) {

            System.out.println("Host " + hostname + " not found");

            return;

        }

        ManagedObjectReference crmor = (ManagedObjectReference) getMOREFs.entityProps(hostmor,

                                                                                      new String[] { "parent" }).get("parent");

        if (crmor == null) {

            System.out.println("No Compute Resource Found On Specified Host");

            return;

        }

        ManagedObjectReference resourcepoolmor = (ManagedObjectReference) getMOREFs.entityProps(crmor,

                                                                                                new String[] { "resourcePool" }).get("resourcePool");

        ManagedObjectReference vmFolderMor = (ManagedObjectReference) getMOREFs.entityProps(dcmor,

                                                                                            new String[] { "vmFolder" }).get("vmFolder");

        VirtualMachineConfigSpec vmConfigSpec = createVmConfigSpec(virtualMachineName, dataStore, diskSize, crmor,

                                                                   hostmor);

        vmConfigSpec.setName(virtualMachineName);

        vmConfigSpec.setAnnotation("VirtualMachine Annotation");

        vmConfigSpec.setMemoryMB(new Long(vmMemory));

        vmConfigSpec.setNumCPUs(numCpus);

        vmConfigSpec.setGuestId(guestOsId);

        ManagedObjectReference taskmor = vimPort.createVMTask(vmFolderMor, vmConfigSpec, resourcepoolmor, hostmor);

        if (getTaskResultAfterDone(taskmor)) {

            System.out.printf("Success: Creating VM  - [ %s ] %n", virtualMachineName);

        } else {

            String msg = "Failure: Creating [ " + virtualMachineName + "] VM";

            throw new RuntimeException(msg);

        }

        ManagedObjectReference vmMor = (ManagedObjectReference) getMOREFs.entityProps(taskmor,

                                                                                      new String[] { "info.result" }).get("info.result");

        System.out.println("Powering on the newly created VM " + virtualMachineName);

        // Start the Newly Created VM.

        powerOnVM(vmMor);

    }

any suggestions or ideas?

0 Kudos
1 Reply
sumandodla
Contributor
Contributor

I am also facing the same issue , Can any one help us .

Thanks

Suman D.

0 Kudos