Меню

Invalid content was found starting with element ошибка

I’m using Java’s JAXB parser to marshal and unmarshal XML files to a specific class. The unmarshaling works fine, however, it chokes on marshaling a file with the following error:

cvc-complex-type.2.4.a: Invalid content was found starting with element ‘DataPath’. One of ‘{«http://hg.flyingwhales.nl/cinnabar/schemas/project.xsd»:DataPath}’ is expected.

I don’t understand why this wouldn’t work, cause unmarshaling a file works fine.

As requested, here is a MCVE:

ProjectRepository.java:

package com.flyingwhales;

import org.xml.sax.SAXException;

import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import java.io.File;
import java.io.IOException;

/**
 * Created by Jesse on 11/13/2016.
 */

public final class ProjectRepository {
    private static Validator validator;
    private static Marshaller marshaller;
    private static Unmarshaller unmarshaller;

    // This class is not meant to be instantiated.
    private ProjectRepository() {}

    static {
        File schemaFile = new File("project.xsd");
        SchemaFactory schemaFactory = SchemaFactory
                .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);

        try {
            Schema schema = schemaFactory.newSchema(schemaFile);
            validator = schema.newValidator();

            // Initialize JAXB stuff too.
            JAXBContext jaxbContext = JAXBContext.newInstance(Project.class);
            marshaller = jaxbContext.createMarshaller();
            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
            marshaller.setSchema(schema);
            unmarshaller = jaxbContext.createUnmarshaller();
        } catch (SAXException | JAXBException e) {
            e.printStackTrace();
        }
    }

    public static Project load(File file) throws Exception {
        if (!validate(file)) {
            throw new Exception("project file contains invalid markup");
        }

        Project project = (Project)unmarshaller.unmarshal(file);
        project.setProjectFile(file);

        return project;
    }

    public static void save(Project project, File path) throws JAXBException {
        marshaller.marshal(project, path);
    }

    public static boolean validate(File file) throws IOException {
        Source source = new StreamSource(file);

        try {
            validator.validate(source);
        } catch (SAXException e) {
            return false;
        }

        return true;
    }
}

Project.java

package com.flyingwhales;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.File;

@XmlRootElement(name = "Project")
public class Project {
    private String name = "Project";
    private String type = "Standalone";
    private String dataPath = "Data";
    private String scriptPath = "Data/Scripts";
    private String artPath = "Art";
    private String sfxPath = "Sound/SFX";
    private String bgmPath = "Sound/BGM";

    private File projectFile;

    public Project() { }

    public Project(File file) {
        setProjectFile(file);
    }

    @XmlAttribute( name = "name" )
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @XmlAttribute (name = "type" )
    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @XmlElement(name = "DataPath")
    public String getDataPath() {
        return dataPath;
    }

    public void setDataPath(String dataPath) {
        this.dataPath = dataPath;
    }

    @XmlElement (name = "ScriptPath")
    public String getScriptPath() {
        return scriptPath;
    }

    public void setScriptPath(String scriptPath) {
        this.scriptPath = scriptPath;
    }

    @XmlElement (name = "ArtPath")
    public String getArtPath() {
        return artPath;
    }

    public void setArtPath(String artPath) {
        this.artPath = artPath;
    }

    @XmlElement (name = "SFXPath")
    public String getSfxPath() {
        return sfxPath;
    }

    public void setSfxPath(String sfxPath) {
        this.sfxPath = sfxPath;
    }

    @XmlElement (name = "BGMPath")
    public String getBgmPath() {
        return bgmPath;
    }

    public void setBgmPath(String bgmPath) {
        this.bgmPath = bgmPath;
    }

    void setProjectFile(File file) {
        projectFile = file;
    }

    public File getProjectFile() {
        return projectFile;
    }
}

package-info.java

@XmlSchema(namespace = "http://hg.flyingwhales.nl/cinnabar/schemas/project.xsd")
package com.flyingwhales;

import javax.xml.bind.annotation.XmlSchema;

Main.java

    package com.flyingwhales;

import javax.xml.bind.JAXBException;
import java.io.File;

public class Main {
    public static void main(String[] args) {
        // Open and parse a file from the filesystem.
        try {
            Project loadedProject = ProjectRepository.load(new File("Test.cinnabar"));
            System.out.print("Loaded project: " + loadedProject.getName());
        } catch (Exception e) {
            e.printStackTrace();
        }

        // Try to create a project and save it to the hard drive.
        Project newProject = new Project(new File("New.cinnabar"));

        try {
            ProjectRepository.save(newProject, new File("New.cinnabar"));
        } catch (JAXBException e) {
            e.printStackTrace();
        }
    }
}

project.xsd

<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           targetNamespace="http://hg.flyingwhales.nl/cinnabar/schemas/project.xsd"
           xmlns="http://hg.flyingwhales.nl/cinnabar/schemas/project.xsd"
           elementFormDefault="qualified">

    <xs:element name="Project">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="DataPath" type="xs:string" />
                <xs:element name="ScriptPath" type="xs:string" />
                <xs:element name="ArtPath" type="xs:string" />
                <xs:element name="SFXPath" type="xs:string" />
                <xs:element name="BGMPath" type="xs:string" />
            </xs:sequence>

            <xs:attribute name="name" type="xs:string" use="required" />
            <xs:attribute name="type" type="xs:string" use="required" />
        </xs:complexType>
    </xs:element>
</xs:schema>

Test.cinnabar

<?xml version="1.0" encoding="UTF-8"?>
<Project name="Test project" type="Standalone"
         xmlns="http://hg.flyingwhales.nl/cinnabar/schemas/project.xsd"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://hg.flyingwhales.nl/cinnabar/schemas/project.xsd">

    <DataPath>Data</DataPath>
    <ScriptPath>Data/Scripts</ScriptPath>
    <ArtPath>Art</ArtPath>
    <SFXPath>Sound/SFX</SFXPath>
    <BGMPath>Sound/BGM</BGMPath>
</Project>

Simply run the code and it will produce the error. Make sure project.xsd is in the working directory.

Программа Retail Declaration более не поддерживается.

Для работы с ЕГАИС рекомендуем использовать Контур.Маркет.

После отправки документа может возникнуть следующая ошибка:
Invalid content was found starting with element ‘orefv2:description’. One of ‘{«http://fsrar.ru/WEGAIS/ClientRef_v2»:RegionCode}’ is expected.

Данная ошибка связана с тем, что у российских контрагентов не указан регион.

Для решения ошибки выполните следующее:

  1. Перейдите в раздел Справочники/Организации.
  2. Щелкните левой кнопкой мыши на первый столбец (снежинку) и поставьте галку в поле Страна.  
  3. В столбце Страна щелкните левой кнопкой мыши на якорь и поставьте галку в поле Россия.
  4. Пересмотрите всех российских контрагентов и их подразделения и отредактируйте адреса организаций, указав регион у тех, у кого он не стоит.  
    Обратите внимание, что первые две цифры КПП представляют собой код региона. 
  5. Для редактирования адреса выделите нужное подразделение и нажмите Редактировать.

Вы определились с выбором?

Перейти к оформлению заказа

@Anasmirza20

Hi Team

I am getting this error while building the project

cvc-complex-type.2.4.a: Invalid content was found starting with element ‘base-extension’. One of ‘{layoutlib}’ is expected.

divlov, muhamadnursyami, rimba5446, luizppa, ammar-abyte, ChrisBews, nik312123, uenx, Aadityakesarwani, sudhin777, and 29 more reacted with thumbs up emoji
pramit8874, gayatripadmani, GithinjiHans, and lokesharora006 reacted with laugh emoji
anantshah93, songoten28, ismoilov9922, chsmy, shafqat125, prathamesh120, gumq, rudialfa, gayatripadmani, charafski, and 14 more reacted with eyes emoji

@jscott1989

Is anyone else seeing this issue? I’ve never seen it before…

@aspawa

I am getting this error while building the project

cvc-complex-type.2.4.a: Invalid content was found starting with element ‘base-extension’. One of ‘{codename, tag}’ is expected.

divlov, ammar-abyte, uenx, anantshah93, suzukiami607, gumq, Matheusbafutto, v012345, waheedkhan6446, choiyoungwan, and 4 more reacted with thumbs up emoji

@himeshshadiza

Hi @Anasmirza20 did you get any update on how to solve this issue

@KyleTrippK

Hello guys I am also facing the same error during gradle sync.

cvc-complex-type.2.4.a: Invalid content was found starting with element ‘base-extension’. One of ‘{layoutlib}’ is expected.

@idevchandra

I am having this issue too!

Android Studio Bumblebee | 2021.1.1 Patch 1
Build #AI-211.7628.21.2111.8139111, built on February 1, 2022
Runtime version: 11.0.11+0-b60-7590822 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 12.2
GC: G1 Young Generation, G1 Old Generation
Memory: 1280M
Cores: 8
Registry: external.system.auto.import.disabled=true
Non-Bundled Plugins: org.jetbrains.kotlin (211-1.6.10-release-923-AS7442.40)

@luizppa

Same issue here:

Android Studio: Bumblebee | 2021.1.1
macOS: 12.0
chip: apple M1
Gradle JDK: 1.8.0_321

@ammar-abyte

Hi, I’m getting this error while building project. Anyone here who solved that?

cvc-complex-type.2.4.a: Invalid content was found starting with element ‘base-extension’. One of ‘{codename, tag}’ is expected.

JDK: 1.8
Android Studio Version Bumblebee 2021.1.1

@jscott1989

I’m not seeing this. We are going to be replacing the gradle build system with bazel and will update all our dependencies etc. at the same time so it should be fixed then.

I’ll leave this issue open until then in case someone else figures it out

@brentscott

I was running into this same error. What fixed it for me was making sure the Gradle JDK was pointing to the right JDK (in my case JDK 1.8). File > Project Structure > SDK Location > Gradle Settings (Link)

gradle_settings

Haylemicheal, mescartin, pranayborode, vmartinmajorkeytech, x1wins, hexdecimal16, hy-liuyuzhe, sachingurnaney, DineshAndroapps, ExcaCambo, and 6 more reacted with thumbs up emoji
muHashh, dszharikov, zhangisland, NikitaZhebinDev, AHTanvir, datnt2, danishlaeeq, StanislawRichardt, soft-l, and josphatmwania reacted with thumbs down emoji
Ayx03 and Tamoooooo reacted with confused emoji

@exs-xgg

facing the same issue.
i7 6700k
2021.01.01 Bumblebee

@hemantac

to fix this issue simply reset your ide settings
File — Manage IDE Settings — Restore Default Settings

DanteAndroid and react06 reacted with thumbs up emoji
lucagiordano-visia, siddhimandodi, anantshah93, indahreforsiana, Ayx03, songoten28, xenrobi, hndrbrm, angelshurikan, samiyabatool, and 78 more reacted with thumbs down emoji
blackCmd, fahad-1337, AlphaOmarDiallo, TylerAnder, alvarodev-lc, and danieljay062198 reacted with confused emoji

@xenrobi

hey guys i have same eror here anybody already fix this error can you share in here thanks you

@uenx

I ended up fixing this by upgrading Gradle to the latest version (and modify my current source code accordingly)

@sudhin777

I am also facing the same issue.
cvc-complex-type.2.4.a: Invalid content was found starting with element ‘base-extension’. One of ‘{layoutlib}’ is expected.

My build version was
Android Studio Arctic Fox | 2020.3.1 Patch 4

I updated to version — Android Studio Bumblebee | 2021.1.1 Patch 1. Still issue exists. Any help is much appreciated.

@HarpreetKaur9

Screenshot 2022-02-18 at 1 19 35 PM
Hello
Anyone have solution for this??

———————ISSUE———————-

  1. cvc-complex-type.2.4.a: Invalid content was found starting with element ‘base-extension’. One of ‘{layoutlib}’ is expected.
  2. JAVA_LETTER_OR_DIGIT

I’m facing this issue in
JDK: 1.8
Android Studio Version Bumblebee 2021.1.1

@sudhin777

Hello all,
I also faced similar issue.
cvc-complex-type.2.4.a: Invalid content was found starting with element ‘base-extension’. One of ‘{layoutlib}’ is expected.

Finally i was able to fix this issue, by updating Android Gradle Plugin Version and Gradle Version.

Android Studio Configuration:
Android Studio Bumblebee | 2021.1.1 Patch 1
JDK: 1.8

image

norman-arauz, sandolkakos, uenx, jeancss01, kaierwen, Student8877, echolocation19, zhouyingge1104, vpeopleonatank, kipkemoifred, and 37 more reacted with thumbs up emoji
almiladurukavak, ibwc, willyichsanj, and GithinjiHans reacted with hooray emoji
joseortiz9, CamiloRic0, apurvaone, ibwc, sindaaaa, willyichsanj, GithinjiHans, and animesh0904071 reacted with heart emoji

@HarpreetKaur9

Hello all, I also faced similar issue. cvc-complex-type.2.4.a: Invalid content was found starting with element ‘base-extension’. One of ‘{layoutlib}’ is expected.

Finally i was able to fix this issue, by updating Android Gradle Plugin Version and Gradle Version.

Android Studio Configuration: Android Studio Bumblebee | 2021.1.1 Patch 1 JDK: 1.8

image

Facing same issue after this.

@siddhimandodi

Im also facing the same issue cvc-complex-type.2.4.a: Invalid content was found starting with element ‘base-extension’. One of ‘{layoutlib}’ is expected.

@oliver34

does any one solved this problem? Im also facing the same issue

@gowthambalashanmugam

Does anyone have an idea to resolve this issue?

@zhangtao2005

I face the same problem,In my case I opened the idea.log,and it says I haven’t the build-tools 28.0.3,then I installed this version of build-tools, after that, my problem solved.

@shafqat125

Add Ndk path in local.Properties like this
and download ndk’s from Sdk Tools in Sdk Manager
ndk.dir=C:UsersUserNameAppDataLocalAndroidSdkndk21.1.6352462
shot_one
shot_two

@gowthambalashanmugam

@zhangtao2005, Thank you, I had tried to play with older code but finally upgraded to latest react native and pulled all latest dependencies, hence its working fine

@arif-rahman-cse

Add Ndk path in local.Properties like this and download ndk’s from Sdk Tools in Sdk Manager ndk.dir=C:UsersUserNameAppDataLocalAndroidSdkndk21.1.6352462 shot_one shot_two

Thank you

@bdmostafa

I have the issues related to base-extension. I used distributionUrl=https://services.gradle.org/distributions/gradle-2.14.1-all.zip in gradle-wrapper.properties file and classpath 'com.android.tools.build:gradle:2.2.3' in build.gradle file of android directory.
image
This error returns when npx react-native run-android is run

image
Also, I tried to open project on Android Studio. This is the error of it.

@sbr5136014

Hi Team

I am getting this error while building the project

cvc-complex-type.2.4.a: Invalid content was found starting with element ‘base-extension’. One of ‘{layoutlib}’ is expected.

Same issue

@thienthancuagio

i fixed it. Please check the configuration below
image

@zhouyingge1104

Hello all, I also faced similar issue. cvc-complex-type.2.4.a: Invalid content was found starting with element ‘base-extension’. One of ‘{layoutlib}’ is expected.

Finally i was able to fix this issue, by updating Android Gradle Plugin Version and Gradle Version.

Android Studio Configuration: Android Studio Bumblebee | 2021.1.1 Patch 1 JDK: 1.8

image

This works for me, thanks a lot!

@Languomao

It is possible that your SDK tools is too new. Check the version through “adb version“ and reinstall the corresponding old version according to your needs,after that, my problem solved.
image

@beyrakIn

@thehunzter

@avinashgoswami

Hello all, I also faced similar issue. cvc-complex-type.2.4.a: Invalid content was found starting with element ‘base-extension’. One of ‘{layoutlib}’ is expected.

Finally i was able to fix this issue, by updating Android Gradle Plugin Version and Gradle Version.

Android Studio Configuration: Android Studio Bumblebee | 2021.1.1 Patch 1 JDK: 1.8

image

Worked for me, Thanks

@Atharva1720

Invalid content was found starting with element ‘base-extension’. One of ‘{layoutlib}’ is expected.
please tell any fix……..

@kckunal2612

I am also facing this issue but sadly none of the suggestions made above work for me.

Here’s the 2 error messages I see —
cvc-complex-type.2.4.a: Invalid content was found starting with element 'base-extension'. One of '{layoutlib}' is expected.
cvc-complex-type.2.4.a: Invalid content was found starting with element 'base-extension'. One of '{codename, tag}' is expected.

I think this could be an M1 Chip issue as this didn’t happen to me on an Intel chip.
Any help would be appreciated.

@voonngee

Same here.

3 error messages:-
cvc-complex-type.2.4.a: Invalid content was found starting with element ‘base-extension’. One of ‘{layoutlib}’ is expected.
cvc-complex-type.2.4.d: Invalid content was found starting with element ‘base-extension’. No child element is expected at this point.
cvc-complex-type.2.4.a: Invalid content was found starting with element ‘base-extension’. One of ‘{codename, tag}’ is expected.

Android Studio Bumblebee | 2021.1.1 Patch 1
M1 Chip

@GhiathAlbawab0

@kckunal2612

I am also facing this issue but sadly none of the suggestions made above work for me.

Here’s the 2 error messages I see — cvc-complex-type.2.4.a: Invalid content was found starting with element 'base-extension'. One of '{layoutlib}' is expected. cvc-complex-type.2.4.a: Invalid content was found starting with element 'base-extension'. One of '{codename, tag}' is expected.

I think this could be an M1 Chip issue as this didn’t happen to me on an Intel chip. Any help would be appreciated.

So here’s an update — I was finally able to fix this issue on my M1 Pro machine. ✅

The fix —

  • Updated gradle-wrapper.properties to use gradle version 6.9.0.
  • Updated my build.gradle to use architecture components version 2.4.0 (look for kapt "androidx.room:room-compiler...").

Now why did these changes work for me?

  1. Gradle 6.9 was the first release to include Apple Silicon Support. (see release notes). Thus, upgrading to this version was the first step (as has also been suggested by Google here).

Screenshot 2022-04-13 at 5 04 51 PM

  1. Instead of building from Android studio, I ran the gradlew build command. Once done, I looked at the error logs, and noticed an error for SQLite Room DB.
    Caused by: java.lang.Exception: No native library is found for os.name=Mac and os.arch=aarch64. path=/org/sqlite/native/Mac/aarch64 at org.sqlite.SQLiteJDBCLoader.loadSQLiteNativeLibrary(SQLiteJDBCLoader.java:333) at org.sqlite.SQLiteJDBCLoader.initialize(SQLiteJDBCLoader.java:64) at androidx.room.verifier.DatabaseVerifier.(DatabaseVerifier.kt:71) ...
    I looked up online and this StackOverflow answer seemed to give the solution that worked for me.
    Explanation
    — Room DB, part of Android architecture components library, uses SQLite internally, which had compatibility issues with the new Apple Silicon architecture. This was fixed in one of the Room alphas and updated in the Release Notes.

I hope you find this fix useful.

@sachingurnaney

I’m not seeing this. We are going to be replacing the gradle build system with bazel and will update all our dependencies etc. at the same time so it should be fixed then.

I’ll leave this issue open until then in case someone else figures it out

Update gradle version and target JDK 11 fixed my issue.

@JasonGaoH

Hello all, I also faced similar issue. cvc-complex-type.2.4.a: Invalid content was found starting with element ‘base-extension’. One of ‘{layoutlib}’ is expected.

Finally i was able to fix this issue, by updating Android Gradle Plugin Version and Gradle Version.

Android Studio Configuration: Android Studio Bumblebee | 2021.1.1 Patch 1 JDK: 1.8

image

This worked for me,Thanks。

@jscott1989

Closing all outstanding pull requests + issues as we’ve reworked the app to now build with Bazel. With this change, we should be able to properly accept pull requests going forward so these won’t sit around for so long. If this is still relevant please check it with the latest version [Using the Android T SDK] and re-open.

@DanteAndroid

to fix this issue simply reset your ide settings File — Manage IDE Settings — Restore Default Settings

Works like magic

@hamzaabualkhair

Hello all, I also faced similar issue. cvc-complex-type.2.4.a: Invalid content was found starting with element ‘base-extension’. One of ‘{layoutlib}’ is expected.
Finally i was able to fix this issue, by Go To File>>Settings>>Build, Execution, Deployment>Build Tools
And I am enable «Reload project after changes in the build scripts»>Any changes
after this Appeared new Error «Add Google maven repository»
I add Google maven repository to build.gradle and project worked without any errors
لقطة الشاشة 2022-06-14 162058

@sundy19

this is work for me also. thanks
image

@JauneQ

my project’ s compileSdkVersion and targetSdkVersion is API 28, so i remove the latest SDK Platforms and Android SDK Build-Tools, it works for me
image
image

@afridi315

As per my experience, most of the time it happens when your gradle version and gradle distributionUrl are not matching. Make sure you are using the right gradle version for you project. the following link may help, Gradle Versioning

Hi,

I am getting an error while parsing(unmarshallling) the xml using JAXB thru XSD validation.

Here is the xsd, that I am using for the validation followed by the xml sample and exception that I am getting.

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

	<xs:complexType name="process_variable_type">
	      <xs:sequence>
		<xs:element name="variable_name" type="xs:string"/>
		<xs:element name="label" type="xs:string"/>
		<xs:element name="value" type="xs:string"/>
		<xs:element name="previous_value" type="xs:string"/>
		<xs:element name="format" type="xs:string"/>
	      </xs:sequence>
	</xs:complexType>
	
	<xs:complexType name="text_field_type">
	  <xs:complexContent>
	    <xs:extension base="process_variable_type">
	    </xs:extension>
	  </xs:complexContent>
	</xs:complexType>
	
	<xs:complexType name="part_type">
	  <xs:sequence>
	   <xs:choice>
		<xs:element name="textFieldElement" type="text_field_type" /> 
	   </xs:choice>
	  </xs:sequence>
	  <xs:attribute name="name" type="xs:string" />
	</xs:complexType>
	
	<xs:element name="variable">
	  <xs:complexType>
	   <xs:sequence>
		<xs:element name="part" type="part_type" minOccurs="1" maxOccurs="1" /> 
	   </xs:sequence>
	  <xs:attribute name="dataIncluded" type="xs:string" />
	  <xs:attribute name="hasData" type="xs:string" />
	  <xs:attribute name="name" type="xs:string" />
	  <xs:attribute name="version" type="xs:string" />
	  </xs:complexType>
	</xs:element>
	
</xs:schema>

Sample XML:

<variable dataIncluded="yes" hasData="true" name="V1" version="25">
   <part name="textFieldElement">
      <textFieldElement xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:abx="http://www.activebpel.org/bpel/extension" xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:ext="http://www.activebpel.org/2.0/bpel/extension" xmlns:ns1="urn:ValueDisplayer" xmlns:ns2="urn:ValueProvider" xmlns:ns3="Invalid Document" xmlns:ns4="http://temp" xmlns:ns5="http://active-endpoints.com/services/order" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
         <variable_name>Variable1</variable_name>
         <label>Label2</label>
         <value>Value1</value>
         <previous_value>prevValue1</previous_value>
         <format>format1</format>
         <form_element_type>formElement1</form_element_type>
      </textFieldElement>
   </part>
</variable>

Error that I am getting is:

javax.xml.bind.UnmarshalException
 - with linked exception:
[org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'textFieldElement'. One of '{"":textFieldElement}' is expected.]
	at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:315)
	at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.createUnmarshalException(UnmarshallerImpl.java:476)
	at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:204)
	at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:173)
	at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:137)
	at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:194)
	at com.enfs.bpel.client.BpelClientUtility.unMarshal(BpelClientUtility.java:158)
	at com.enfs.bpel.client.BpelClientUtility.main(BpelClientUtility.java:140)
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'textFieldElement'. One of '{"":textFieldElement}' is expected.
	at com.sun.org.apache.xerces.internal.jaxp.validation.Util.toSAXParseException(Unknown Source)
	at com.sun.org.apache.xerces.internal.jaxp.validation.ErrorHandlerAdaptor.error(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
	at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorHandlerImpl.startElement(Unknown Source)
	at com.sun.xml.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.startElement(ValidatingUnmarshaller.java:67)
	at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:117)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
	at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:200)
	... 5 more

If I remove the following attribute in the textFieldElement from the sample, then I am able to unmarshal it successfully.

xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/"

But at the runtime, I cannot avoid this attribute in the XML message which I should unmarshal it.

Need help to resolve this.

..Thiruppathy.R

Перейти к содержимому

Столкнулся с такой ошибкой в Eclipse при описании сервлета. Был описан следующий сервлет в web.xml:

  <servlet>

    <servlet-name>AxisServlet</servlet-name>

    <display-name>Apache-Axis Servlet</display-name>

    <servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>

    <load-on-startup>1</load-on-startup>

  </servlet>

На строчке
display-name выдавалась ошибка:

cvc-complex-type.2.4.a: Invalid content was found starting with element ‘display-name’

Всё дело в положении
display-name. Eclipse требует, чтобы оно было перед
servlet-name. Сложно сказать, чем вызвано такое требование, но после перемещения
display-name в начало ошибка исчезла.

  <servlet>

    <display-name>Apache-Axis Servlet</display-name>

    <servlet-name>AxisServlet</servlet-name>

    <servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>

    <load-on-startup>1</load-on-startup>

  </servlet>

Notice! This page describes the nature of the error using a hypothetical example and not the erroneous data of the input test file. You should however be able to apply this information to your error case.

General description of the error:

cvc-complex-type.2.4.a: Invalid content was found starting with element »{0}». One of »{1}» is expected.

Error description in schema standard: http://www.w3.org/TR/2007/WD-xmlsche…c-complex-type

Possible causes for this error:

  • Element name is mistyped.
  • Mandatory element is missing
  • The end tag for an earlier element is missing
  • Element not described in schema is trying to be used.
    • One reason for the above could be that not all of the expected elements are given. E.g. InitgPty/PstlAdr/Ctry is expected, instead InitgPty/Ctry is given
  • Elements are in incorrect order.
  • Namespace definitions declared either in the root tag or a parent element don’t match with the prefix (or no prefix) used in the element.

An example 

In this example, elements «House» and «Garage» are defined in the namespace «house.ns». «Car» and «Brand» belong to the «car.ns» namespace.

Incorrect:

<House xmlns="http://house.ns" xmlns:car="http://car.ns">
    <Garage>
        <Car> <!-- This element is defined in the "car.ns" namespace. Therefore its name should be typed as "car:Car" -->
            <Brand>BMW</Brand> <!-- Same thing here -->
        </Car>
    </Garage>
</House>

Fixed:

<House xmlns="http://house.ns" xmlns:car="http://car.ns">
    <Garage>
        <car:Car>
            <car:Brand>BMW</car:Brand>
        </car:Car>
    </Garage>
</House>

An alternative way is to declare namespaces where they’re going to be used. This is a way to avoid using namespace prefixes in elements:

<House xmlns="http://house.ns">
    <Garage>
        <Car xmlns="http://car.ns">
            <Brand>BMW</Brand>
        </Car>
    </Garage>
</House>

An example

<PstlAdr>
  <AdrType>ADDR</AdrType>.
</PstlAddr>

Error messageError cvc-complex-type.2.4.a: Invalid content was found starting with element ‘AdrType’. One of ‘{«urn:iso:std:iso:20022:tech:xsd:pain.001.001.03»:AdrTp, «urn:iso:std:iso:20022:tech:xsd:pain.001.001.03»:Dept, «urn:iso:std:iso:20022:tech:xsd:pain.001.001.03»:SubDept, «urn:iso:std:iso:20022:tech:xsd:pain.001.001.03»:StrtNm, «urn:iso:std:iso:20022:tech:xsd:pain.001.001.03»:BldgNb, «urn:iso:std:iso:20022:tech:xsd:pain.001.001.03»:PstCd, «urn:iso:std:iso:20022:tech:xsd:pain.001.001.03»:TwnNm, «urn:iso:std:iso:20022:tech:xsd:pain.001.001.03»:CtrySubDvsn, «urn:iso:std:iso:20022:tech:xsd:pain.001.001.03»:Ctry, «urn:iso:std:iso:20022:tech:xsd:pain.001.001.03»:AdrLine}’ is expected.

How to fix: This issue can be fixed by using one of the elements suggested by the error message. Further information can be found from the schema definition.

<PstlAdr>
  <AdrTp>ADDR</AdrTp>
</PstlAdr> 

0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии

А вот еще интересные материалы:

  • Яшка сломя голову остановился исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного где ошибка
  • Invalid community post ошибка
  • Invalid column name sql ошибка