Acdc RocknRoll
Acdc RocknRoll

Reputation: 687

Uri is not absolute

I am trying to unmarshall the following xml file with the method Jaxb.unmarshall(String,Class). I always get the error:

Exception in thread "main" java.lang.IllegalArgumentException: URI is not absolute:

XML file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<spieltag xmlns="http://arnezelasko.de/spieltag">
<game>
    <spieltag>28</spieltag>
    <nummer>1</nummer>
    <beginn>2010-03-26 20:30:00</beginn>
    <mannschaft_heim><![CDATA[VfL Bochum]]></mannschaft_heim>
    <mannschaft_gast><![CDATA[Eintracht Frankfurt]]></mannschaft_gast>
    <tore_heim_halbzeit>1</tore_heim_halbzeit>
    <tore_gast_halbzeit>1</tore_gast_halbzeit>
    <tore_heim_ergebnis>1</tore_heim_ergebnis>
    <tore_gast_ergebnis>2</tore_gast_ergebnis>
</game>
<game>
    <spieltag>28</spieltag>
    <nummer>2</nummer>
    <beginn>2010-03-27 15:30:00</beginn>
    <mannschaft_heim><![CDATA[Bayern München]]></mannschaft_heim>
    <mannschaft_gast><![CDATA[VfB Stuttgart]]></mannschaft_gast>
    <tore_heim_halbzeit></tore_heim_halbzeit>
    <tore_gast_halbzeit></tore_gast_halbzeit>
    <tore_heim_ergebnis></tore_heim_ergebnis>
    <tore_gast_ergebnis></tore_gast_ergebnis>
</game>

Upvotes: 1

Views: 15998

Answers (1)

J&#233;r&#244;me Radix
J&#233;r&#244;me Radix

Reputation: 10533

Here is a working Java unmarshalling example from your xml example.

You have a root element called spieltag and an inner element that also called spieltag. That may cause problems if you have not well defined this in your XMLSchema. In the example, I've used spieltag2 for the inner spieltag element.

Also, don't forget to compile package-info.java with the proper @XmlSchema :

As said here, You can use the @XmlSchema annotation on a package-info class to control the namespace qualification. If you have already written a package-info class make sure it is being compiled (some versions of ant had problems with package-info classes).

package-info

@XmlSchema( 
    namespace = "http://arnezelasko.de/spieltag", 
    elementFormDefault = XmlNsForm.QUALIFIED) 
package de.arnezelasko.spieltag;

For More Information

Upvotes: 1

Related Questions