0
votes

Unmarshalling fails randomly with error as below javax.xml.bind.UnmarshalException - with linked exception: [Exception [EclipseLink-25008] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.XMLMarshalException Exception Description: A descriptor with default root element DirectPaymentConfirmationRequest was not found in the project]

XSD

    <?xml version="1.0" encoding="utf-16"?>
    <xs:schema   xmlns="http://test.com/Ft/Pare/DirectPayment/Message/Confirmation/Request/v0.10" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified">
    <xs:element name="DirectPaymentConfirmationRequest">
        <!—additional child elements
    </xs:element>
    </xs:schema>

XML input – 
    <?xml version="1.0" encoding="UTF-16"?>
    <DirectPaymentConfirmationRequest>
    <DirectPaymentReferenceId>12345</DirectPaymentReferenceId>
    <PaymentCardTransactionType>ECommerceAuthorisation</PaymentCardTransactionType>
    <Amount>10</Amount>
    <MerchantId>1111</MerchantId>
    <AddressCheckRequested>true</AddressCheckRequested>
    <AuthorisationTimeStamp>2014-02-14T13:55:50.739Z</AuthorisationTimeStamp>
    <AcquirerResponse>
      <ResponseCode>333</ResponseCode>
      <AuthorisationCode>123456</AuthorisationCode>
      <AddressCheckResult>Y</AddressCheckResult>
      <CVVCheckResult>Y</CVVCheckResult>
      <ProductCode>MAE</ProductCode>
      <TraceId>9722461401</TraceId>
    </AcquirerResponse>
    <CardDetail>
      <PaymentCardType>Visa</PaymentCardType>
      <PanToken>232323</PanToken>
      <ExpiryDate>2018</ExpiryDate>
      <LastFourDigits>1234</LastFourDigits>
      <BinNumber>123456</BinNumber>
      <CardState>NewCard</CardState>
    </CardDetail>
    </DirectPaymentConfirmationRequest>

Java code
    package com.transformer.generated;
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
    "directPaymentReferenceId",
    "paymentCardTransactionType",
    "amount",
    "merchantId",
    "addressCheckRequested",
    "authorisationTimeStamp",
    "acquirerResponse",
    "error",
    "cardDetail"
}    )
    @XmlRootElement(name = "DirectPaymentConfirmationRequest")
    public class DirectPaymentConfirmationRequest
    implements Serializable{}
1

1 Answers

0
votes

You need to make sure the DirectPaymentConfirmationRequest class is included when bootstrapping the JAXBContext. If you are bootstrapping from Java classes you can do:

JAXBContext jc = JAXBContext.newInstance(DirectPaymentConfirmationRequest.class);

If you generated the model, then you can create the JAXBContext on the package name of your generated model.