wood burning stoves 2.0*
The moose likes Web Services and the fly likes javax.xml.bind .UnmarshalException in JAXB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "javax.xml.bind .UnmarshalException in JAXB" Watch "javax.xml.bind .UnmarshalException in JAXB" New topic
Author

javax.xml.bind .UnmarshalException in JAXB

Syed Khurram Mahmood
Greenhorn

Joined: Oct 06, 2005
Posts: 2
Hi I working in a project which receives xml from external source (on which I have not control) ... then using my own defined schema convert it to java objects. It was working fine... but then they changed the xml and I update my schema. I am getting this error while unmarshalling.


javax.xml.bind.UnmarshalException
- with linked exception:
[org.xml.sax .SAXParseException: unexpected root element (uri: "http://someurl.com", local:"Report"). Expected elements are <{}Report>] eref=(null/null) [ST [com.inceptor.base. ExceptionUnchecked: javax.xml.bind.UnmarshalException
- with linked exception:
[org.xml.sax.SAXParseException: unexpected root element (uri: "http://someurl.com/", local:"Report"). Expected elements are <{}Report>]





The XML that we receive is here

<Report xmlns:xsi= "http://www.w3.org/ 2001/XMLSchema-instance"
xmlns:xsd= "http://www.w3.org /2001/XMLSchema"
xmlns= "http://someurl.com/"
ReportName= "Keyword PerformanceReport 07_21_2008 09_17_50" ReportTime= "{From 07/30/2006 To 07/30/2006}" TimeZone="Various" ReportAggregation= "Daily" LastCompletedAvailableHour= "7/21/2008 7:00:00 AM (GMT-8:00)" LastCompletedAvailableDay = "7/21/2008 7:00:00 AM (GMT-8:00)" ReportFilter= "AccountId: 2998; " PotentialIncompleteData = "false">
<KeywordPerformance ReportColumns>
<Column name="AccountId" />
<Column name="AccountName" />
<Column name="AdId" />
<Column name="AverageCpc" />
<Column name="AveragePosition" />
<Column name="CampaignId" />
<Column name="CampaignName" />
<Column name="Clicks" />
<Column name="Ctr" />
<Column name="Impressions" />
<Column name="Keyword" />
<Column name="AdGroupId" />
<Column name="KeywordId" />
<Column name="Spend" />
<Column name="GregorianDate" />
<Column name="AdGroupName" />
<Column name="DestinationUrl" />
<Column name="ProductName" />
<Column name="CurrentMaxCpc" />
<Column name="CurrencyCode" />
<Column name="MatchType" />
<Column name="AdDistribution" />
<Column name="ConversionRate" />
<Column name="Conversions" />
<Column na me="CostPerConversion" />
</KeywordPerformance ReportColumns>
<Table>
<Row>
<AccountId value="2998" />
<AccountName value="Inceptor MAIN" />
<AdId value="2202843" />
<AverageCpc value=".00" />
<AveragePosition value="4.00" />
<CampaignId value="67337" />
<CampaignName value="synchable campaign" />
<Clicks value="0" />
<Ctr value="0.0000" />
<Impressions value="1" />
<Keyword value="conversion marketing" />
<AdGroupId value="52619280" />
<KeywordId value="198018583" />
<Spend value=".00" />
<GregorianDate value="7/30/2006" />
<AdGroupName value="devirt to url www.inceptor.com/ company_about.php" />
<DestinationUrl value="http://www.inceptor.com/" />
<ProductName value="Microsoft adCenter" />
<CurrentMaxCpc value=".05" />
<CurrencyCode value="USD" />
<MatchType value="Broad" />
<AdDistribution value="Search" />
<ConversionRate value="0" />
<Conversions value="0" />
<CostPerConversion value="0" />
</Row>
</Table>
<CopyRight>Copy Rights Text </CopyRight>
</Report>



The schema that I have defined is here


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault= "unqualified"
elementFormDefault= "qualified" version="1.0"
xmlns:xs= "http://www.w3.org/2001/XMLSchema">


<xs:element name="Report" type="ReportType" />
<xs:attributeGroup name="ReportAttributeGroup">
<xs:attribute name= "ReportBy" type="xs:string" />
<xs:attribute name= "ReportName" type="xs:string" />
<xs:attribute name= "ReportTime" type="xs:string" />
<xs:attribute name= "TimeZone" type="xs:string" />
<xs:attribute name= "ReportAggregation" type="xs:string" />
<xs:attribute name= "LastCompletedAvailableHour"
type= "xs:string" />
<xs:attribute name= "LastCompletedAvailableDay" type="xs:string" />
<xs:attribute name= "ReportFilter" type="xs:string" />
<xs:attribute name= "PotentialIncompleteData" type="xs:boolean" />
</xs:attributeGroup>


<xs:complexType name="ReportType">

<xs:sequence>
<xs:element name= "KeywordPerformanceReportColumns"
type= "KeywordPerformanceReportColumnsType" minOccurs="1"
maxOccurs="1" />
<xs:element name="Table" type="TableType" minOccurs="1"
maxOccurs="1" />
<xs:element name="CopyRight" type="xs:string" />
</xs:sequence>
<xs:attributeGroup ref="ReportAttributeGroup"></xs:attributeGroup>
</xs:complexType>

<xs:complexType name="ColumnType">
<xs:attribute name="name" type="xs:string"></xs:attribute>
</xs:complexType>


<xs:complexType name= "KeywordPerformanceReportColumnsType">
<xs:sequence>
<xs:element name="Column" type="ColumnType" minOccurs="0"
maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>


<xs:complexType name="TableType">
<xs:sequence>
<xs:element name="Row" type="RowType" minOccurs="0"
maxOccurs="unbounded">
</xs:element>
</xs:sequence>
</xs:complexType>


<xs:complexType name="AttributeStringType">
<xs:attribute name="value" type="xs:string"> </xs:attribute>
</xs:complexType>
<xs:complexType name="AttributeLongType">
<xs:attribute name="value" type="xs:long"> </xs:attribute>
</xs:complexType>
<xs:complexType name="AttributeDoubleType">
<xs:attribute name="value" type="xs:double"> </xs:attribute>
</xs:complexType>

<xs:complexType name="RowType">
<xs:sequence>
<xs:element name="AccountId" type="AttributeLongType"
minOccurs="1" maxOccurs="1" />
<xs:element name="AccountName" type="AttributeStringType"
minOccurs="1" maxOccurs="1" />
<xs:element name="AdId" type="AttributeLongType"
minOccurs="1" maxOccurs="1" />
<xs:element name="AverageCpc" type="AttributeDoubleType"
minOccurs="1" maxOccurs="1" />
<xs:element name="AveragePosition"
type="AttributeDoubleType" nillable="true" minOccurs="1"
maxOccurs="1" />

<xs:element name="CampaignId" type="AttributeLongType"
minOccurs="1" maxOccurs="1" />

<xs:element name="CampaignName" type="AttributeStringType"
minOccurs="1" maxOccurs="1" />

<xs:element name="Clicks" type="AttributeLongType"
minOccurs="1" maxOccurs="1" />
<xs:element name="Ctr" nillable="true"
type="AttributeDoubleType" minOccurs="1" maxOccurs="1" />
<xs:element name="Impressions" type="AttributeLongType"
minOccurs="1" maxOccurs="1" />
<xs:element name="Keyword" type="AttributeStringType"
minOccurs="1" maxOccurs="1" />
<!-- was orderId in v4-->
<xs:element name="AdGroupId" type="AttributeLongType"
minOccurs="1" maxOccurs="1" />
<!-- was orderItemId in v4-->
<xs:element name="KeywordId" type="AttributeLongType"
minOccurs="1" maxOccurs="1" />
<!-- I assume it as TotalCose in v4 -->
<xs:element name="Spend" nillable="true"
type="AttributeDoubleType" minOccurs="1" maxOccurs="1" />
<xs:element name="GregorianDate" type="AttributeStringType"
minOccurs="1" maxOccurs="1" />
<!-- was KeywordOrderName in v4 -->
<xs:element name="AdGroupName" type="AttributeStringType"
minOccurs="1" maxOccurs="1" />
<xs:element name="DestinationUrl" type="AttributeStringType"
minOccurs="1" maxOccurs="1" />
<xs:element name="ProductName" type="AttributeStringType"
minOccurs="1" maxOccurs="1" />
<!-- was MaxCPC in v4 -->
<xs:element name="CurrentMaxCpc" type="AttributeDoubleType"
minOccurs="1" maxOccurs="1" nillable="true" />
<xs:element name="CurrencyCode" type="CurrencyCodeType"
minOccurs="0" maxOccurs="1" />
<!-- was MatchTypeDesc in v4 -->
<xs:element name="MatchType" type="MatchTypeDesc"
minOccurs="0" maxOccurs="1" />
<xs:element name="AdDistribution" type="AdDistributionType"
minOccurs="1" maxOccurs="1" />

<xs:element name="ConversionRate" nillable="true"
type="AttributeDoubleType" minOccurs="0" maxOccurs="1" />
<xs:element name="Conversions" type="AttributeLongType"
minOccurs="1" maxOccurs="1" />
<xs:element name= "CostPerConversion" nillable="true"
type="AttributeDoubleType" minOccurs="0" maxOccurs="1" />
</xs:sequence>
</xs:complexType>

<xs:complexType name="AdDistributionType">
<xs:attribute name="value" type="AdDistributionAttributeType" />
</xs:complexType>

<xs:simpleType name="AdDistributionAttributeType">
<xs:restriction base="xs:string">
<xs:enumeration value="Search" />
<xs:enumeration value="Content" />
</xs:restriction>
</xs:simpleType>

<xs:complexType name="MatchTypeDesc">
<xs:attribute name="value" type="MatchTypeDescAttribute"></xs:attribute>
</xs:complexType>
<xs:simpleType name="MatchTypeDescAttribute">
<xs:restriction base="xs:string">
<xs:enumeration value="Exact" />
<xs:enumeration value="Broad" />
<xs:enumeration value="Phrase" />
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="DistributionChannelNameType">
<xs:restriction base="xs:string">
<xs:enumeration value="United Kingdom" />
<xs:enumeration value="Unknown" />
<xs:enumeration value="United States" />
<xs:enumeration value="Japan" />
<xs:enumeration value="UK" />
<xs:enumeration value="Australia" />
<xs:enumeration value="Germany" />
<xs:enumeration value="France" />
<xs:enumeration value="Canada (EN)" />
<xs:enumeration value="Canada (FR)" />
<xs:enumeration value="Korea" />
<xs:enumeration value="Sweden" />
<xs:enumeration value="New Zealand" />
<xs:enumeration value="Singapore" />
<xs:enumeration value="Malaysia" />
<xs:enumeration value="Austria" />
<xs:enumeration value="Spain" />
<xs:enumeration value="Latin America" />
<xs:enumeration value="Mexico" />
<xs:enumeration value="Taiwan" />
<xs:enumeration value="China" />
<xs:enumeration value="Hong Kong - CN" />
<xs:enumeration value="Netherlands" />
<xs:enumeration value="Brazil" />
<xs:enumeration value="Italy" />
<xs:enumeration value="Switzerland - DE" />
<xs:enumeration value="Switzerland - FR" />
<xs:enumeration value="Belgium - NL" />
<xs:enumeration value="Belgium - FR" />
<xs:enumeration value="Finland" />
<xs:enumeration value="Denmark" />
<xs:enumeration value="Norway" />
<xs:enumeration value="South Africa" />
<xs:enumeration value="India" />
<xs:enumeration value="Russia" />
<xs:enumeration value="United States - ES" />

</xs:restriction>
</xs:simpleType>

<xs:complexType name="CurrencyCodeType">
<xs:attribute name="value" type="CurrencyType"></xs:attribute>
</xs:complexType>
<xs:simpleType name="CurrencyType">
<xs:restriction base="xs:string">
<xs:enumeration value="AUD" />
<xs:enumeration value="BRL" />
<xs:enumeration value="CAD" />
<xs:enumeration value="CHF" />
<xs:enumeration value="DKK" />
<xs:enumeration value="EUR" />
<xs:enumeration value="GBP" />
<xs:enumeration value="JPY" />
<xs:enumeration value="NOK" />
<xs:enumeration value="NZD" />
<xs:enumeration value="SEK" />
<xs:enumeration value="USD" />
<xs:enumeration value="ZAR" />
<xs:enumeration value="AMD" />
<xs:enumeration value="ARS" />
<xs:enumeration value="CLP" />
<xs:enumeration value="CNY" />
<xs:enumeration value="COP" />
<xs:enumeration value="CRC" />
<xs:enumeration value="CZK" />
<xs:enumeration value="AED" />
<xs:enumeration value="DOP" />
<xs:enumeration value="DZD" />
<xs:enumeration value="EEK" />
<xs:enumeration value="EGP" />
<xs:enumeration value="AZM" />
<xs:enumeration value="BGL" />
<xs:enumeration value="GEL" />
<xs:enumeration value="GTQ" />
<xs:enumeration value="HKD" />
<xs:enumeration value="HNL" />
<xs:enumeration value="HRK" />
<xs:enumeration value="HUF" />
<xs:enumeration value="IDR" />
<xs:enumeration value="ILS" />
<xs:enumeration value="INR" />
<xs:enumeration value="IQD" />
<xs:enumeration value="IRR" />
<xs:enumeration value="ISK" />
<xs:enumeration value="JMD" />
<xs:enumeration value="JOD" />
<xs:enumeration value="BHD" />
<xs:enumeration value="KES" />
<xs:enumeration value="KGS" />
<xs:enumeration value="KRW" />
<xs:enumeration value="KWD" />
<xs:enumeration value="KZT" />
<xs:enumeration value="LBP" />
<xs:enumeration value="LTL" />
<xs:enumeration value="LVL" />
<xs:enumeration value="LYD" />
<xs:enumeration value="MAD" />
<xs:enumeration value="MKD" />
<xs:enumeration value="MNT" />
<xs:enumeration value="MOP" />
<xs:enumeration value="MVR" />
<xs:enumeration value="MXN" />
<xs:enumeration value="MYR" />
<xs:enumeration value="NIO" />
<xs:enumeration value="BND" />
<xs:enumeration value="BOB" />
<xs:enumeration value="OMR" />
<xs:enumeration value="PAB" />
<xs:enumeration value="PEN" />
<xs:enumeration value="PHP" />
<xs:enumeration value="PKR" />
<xs:enumeration value="PLN" />
<xs:enumeration value="PYG" />
<xs:enumeration value="QAR" />
<xs:enumeration value="ROL" />
<xs:enumeration value="RUR" />
<xs:enumeration value="SAR" />
<xs:enumeration value="ALL" />
<xs:enumeration value="SGD" />
<xs:enumeration value="SIT" />
<xs:enumeration value="SKK" />
<xs:enumeration value="SYP" />
<xs:enumeration value="THB" />
<xs:enumeration value="TND" />
<xs:enumeration value="TRL" />
<xs:enumeration value="TTD" />
<xs:enumeration value="TWD" />
<xs:enumeration value="UAH" />
<xs:enumeration value="BYB" />
<xs:enumeration value="UYU" />
<xs:enumeration value="UZS" />
<xs:enumeration value="VEB" />
<xs:enumeration value="VND" />
<xs:enumeration value="YER" />
<xs:enumeration value="YUN" />
<xs:enumeration value="BZD" />
<xs:enumeration value="ZWD" />


</xs:restriction>
</xs:simpleType>

</xs:schema>



I have even tried to change the schema.... though xml that I am using totally conforms to schema but still getting this problem in unmarshalling... .seem like namespace problem to me.. .. so ..I have two questions

1) Can anyone please guide me as to how to get rid of this problem?
2) How can I tell Jaxb to simply ignore namespaces?
Steve whetstone
Greenhorn

Joined: Oct 16, 2008
Posts: 1
Did you ever fins a resolution to this problem?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javax.xml.bind .UnmarshalException in JAXB