Jaxb UnMarshal Error : unexpected element (uri:"", local:"processedSalesOrderTypeList"). Expected elements are Jaxb UnMarshal Error : unexpected element (uri:"", local:"processedSalesOrderTypeList"). Expected elements are xml xml

Jaxb UnMarshal Error : unexpected element (uri:"", local:"processedSalesOrderTypeList"). Expected elements are


I can think of 2 different reasons why your Unmarshaller is failing.

  1. Looking in your schema, "processedSalesOrderTypeList" is not defined.In the error you mentioned, the valid elements are:

<{api.supplieroasis.com}processedSalesOrderMessage>,<{api.supplieroasis.com}salesOrderMessage>,<{api.supplieroasis.com}shipperOfRecordAccountNumber>,<{api.supplieroasis.com}shippingAccountNumber>,<{api.supplieroasis.com}uspsMailerId>,<{api.supplieroasis.com}warehouseName>

The XML namespace is contained within the braces {} and the element name comes right after it. These values are specified in your ObjectFactory. As you can see, since "processedSalesOrderTypeList" is not defined within your ObjectFactory so when the Unmarshaller encounters the "processedSalesOrderTypeList" element in your XML, it has no idea how to process it.

  1. I've had an issue with the namespaces mismatching in code generated from xjc which caused a lot of the elements to return null during deserialization. The strange thing was some of the elements would be correctly parsed but some wouldn't. First I would add a ValidationEventHandler to see all XML validation errors:

    unmarshaller.setEventHandler(new DefaultValidationEventHandler());

Then, if you get an error similar to the one below, this answer should help you.

unexpected element (uri:"", local:"MyEntity")

I would look for the class which has this field (it could be a root-level class). Use judgement in finding this class, if the element tag it is failing to parse is the root element then most likely the class has the same exact name as the element. If the element is a child of another element, look in the respective class for that particular element.

Once you locate the class, look to see that the namespaces match up correctly. I've had an issue where the namespace was blank and needed to be filled in.

Fill in the namespace with the same namespace that the XML has. Code Example:

<test:MyEntity xmlns:test="com.example">...</test:MyEntity>

@XmlElement(name = "MyEntity", namespace = "test:com.example")

In essence, make sure the namespace in the annotation and the XML are matching, if not and namespace verification is enabled it will refuse to unmarshal the XML.

If this does not fix your problem and you see an exception regarding ObjectFactory, I would look for the QName that corresponds to this particular element. The correct snippet of code should something like this, making sure the namespaces are matching (create it if it does not exist):

QName _MyEntity_QNAME = new QName("test:com.example", "MyEntity");

In the same ObjectFactory, look for the @XmlElementDecl. This is the annotation that defines how the XML element is converted into a Java object. The correct code should look something like this:

@XmlElementDecl(namespace = "test:com.example", name = "MyEntity")public JAXBElement<MyEntity> createMyEntity(MyEntity value) {    return new JAXBElement<MyEntity>(_MyEntity_QNAME, MyEntity.class, null, value);}

After the namespaces all match up, deserialization should work. If not, go back and check for the exception and post it and I will provide some more insight.


Your JAXB object factory and XSD seems to be different..try recreating the JAXB classes again.


Your XSD doesn't match XML. But you can create new XSD from XML. I use trang utility. It is better to provide many XMLs to generate all elements.

I saved your XML to 1.xml, ran:

trang 1.xml 1.xsd

download link

Then you can create java classes with openjdk native utility

xjc -d /tmp/zzz 1.xsd

your classes will appear in /tmp/zzz