Error on line 1 of document : Content is not allowed in prolog. Nested exception: Content is not allowed in prolog.

created at 10-25-2021 views: 2

background
The project uses VMware vSphere to take a snapshot before the software upgrade.

java

problem

problem

java.rmi.RemoteException: VI SDK invoke exception:org.dom4j.DocumentException: Error on line 1 of document : Content is not allowed in prolog. Nested exception: Content is not allowed in prolog.

Research

Based on my instinct, I believe that the other party upgraded the VM Server. (Don’t ask why not notify)
Then look for the current version and how to check the version

Starting with vSphere 4.0, information about the supported API versions is contained in an XML file, vimServiceVersions.xml, located on the server (see Service-Versions File (vimServiceVersions.xml)). You can access this file with the URL https://server_hostname/sdk/vimServiceVersions.xml.
ref: https://vdc-repo.vmware.com/vmwb-repository/dcr-public/5c1c7b8c-0d1b-4037-af84-5f43787eb378/fab98b61-56a7-4608-992f-818d3b40e4ae/GUID-75B9897E-551B-4C08-B382-A616A007A07D.html

Service-Versions File (vimServiceVersions.xml)
<?xml version="1.0" encoding="UTF-8" ?>
- <!--    Copyright 2008-2010 VMware, Inc.  All rights reserved. -->
- <namespaces version="1.0">
     - <namespace>
            <name>urn:vim25</name>
            <version>5.0</version>
     - <priorVersions>
          <version>2.5u2</version>
          <version>2.5</version>
       </priorVersions>
     </namespace>
     - <namespace>
          <name>urn:vim2</name>
          <version>2.0</version>
       </namespace>
  </namespaces>

Check it, 7.0.2.0

Will the version of vijava used by the client be updated?
When I found the Maven repository, good guys, only this version is the version currently in use.

https://mvnrepository.com/artifact/com.vmware/vijava

Could it be that this 7.x version is newly upgraded, causing vijava.jar to not support it?
The key word is determined as: vijava vsphere 7

Sure enough there is a problem

The official notice 

The HTTP reverse proxy in vSphere 7.0 enforces stricter standard compliance than previous versions. This may cause pre-existing issues in certain third-party libraries that applications use to make SOAP calls to vSphere.
If you develop vSphere applications that use such libraries, or include applications that rely on such libraries in the vSphere stack, you may encounter connection problems when these libraries send HTTP requests to VMOMI. For example, an HTTP request from the vijava library may take the following form:
POST /sdk HTTP/1.1
SOAPAction
Content-Type: text/xml; charset=utf-8
User-Agent: Java/1.8.0_221
The syntax in this example violates the HTTP protocol header field requirement that a colon must be used after SOAPAction. Therefore, the request was rejected at the time of execution.
Solution: Developers who use non-compliant libraries in their applications can consider using libraries that follow the HTTP standard instead. For example, developers who use the vijava library can consider using the latest version of the yavijava library instead.
ref: https://docs.vmware.com/cn/VMware-vSphere/7.0/rn/vsphere-esxi-vcenter-server-70-release-notes.html

solution

Replace vijava.jar with yavijava.jar.

https://github.com/yavijava/yavijava

Download jar

https://mvnrepository.com/artifact/com.toastcoders/yavijava

Install jar

mvn install:install-file -Dfile=PATH/yavijava-6.0.05.jar -DgroupId=com.toastcoders -DartifactId=yavijava -Dversion=6.0.05 -Dpackaging=jar

Reference jar

<dependency>
    <groupId>com.toastcoders</groupId>
    <artifactId>yavijava</artifactId>
    <version>6.0.05</version>
</dependency>
created at:10-25-2021
edited at: 10-25-2021: