Posted by: Rich Cumbers | September 2, 2009

Property “Value” is already defined. Use to resolve this conflict.

I am working on an internal project in my spare time at IBM that requires some marshalling of XML using Java. The obvious candidate is JAXB which in the main works very well. However when it fails, information on the web can be frustrating, telling you to fix it using <jaxb:property> but not actually giving you any useful information. I admit this is for a specific error that I needed to fix, but I do not think it is uncommon.

Therefore I have written a short xsd example that when run through (or xjc.bat on windows) exhibits the same error I was getting. The contents of the Dummy.xml file are as follows (sorry for formatting, wordpress not me!):

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="">
<xsd:complexType name="complexTypeOne">
<xsd:extension base="xsd:string">
<xsd:attribute name="value" type="simpleTypeOne"/>

<xsd:complexType name="complexTypeTwo">
<xsd:extension base="xsd:string">
<xsd:attribute name="value" type="simpleTypeTwo"/>

<xsd:simpleType name="simpleTypeTwo">
<xsd:restriction base="xsd:string">
<xsd:pattern value="[0123456789]+"/>

<xsd:simpleType name="simpleTypeOne">
<xsd:restriction base="xsd:token">
<xsd:enumeration value="exist"/>
<xsd:enumeration value="noexist"/>

The Dummy.xml file consists of two complexTypes with an attribute of the same name, not a huge problem as the Java XML parsers run quite happily when validating XML, but when it comes to using JAXB code generation it falls over. In this case the same name is value and when run with produces the following error:

Property "Value" is already defined. Use <jaxb:property> to resolve this conflict.

The way to fix this issue is indeed to use a <jaxb:property> tag, and the way I found to fix this was using an external bindings file. This file will detail alternate names to use for the clashing names and will allow JAXB to parse without throwing errors. The bindings.xsd can be found here:

<jxb:bindings version="2.0"
<jxb:bindings schemaLocation="Dummy.xml" node="/xsd:schema">
<jxb:bindings node="//xsd:complexType[@name='complexTypeOne']">
<jxb:bindings node=".//xsd:attribute[@name='value']">
<jxb:property name="ValueToFixError1"/>
<jxb:bindings node="//xsd:complexType[@name='complexTypeTwo']">
<jxb:bindings node=".//xsd:attribute[@name='value']">
<jxb:property name="ValueToFixError2"/>

The bindings.xsd defines the xml file to perform the modifications to (schemaLocation="Dummy.xml") and then specifies using XPATH notation the relevant values to change. Fairly self explanatory if you can see the files for yourself, less so if you are just told to use tags! To specify the bindings.xsd on the command line simply do: -b bindings.xsd Dummy.xml which should now compile your code!



  1. Thanks for sharing this information.
    It helpt me to solve my problems with generating my java classes for a given schema.

    One piece of advise: I would rename the files.
    bindings.xsd –> dummy.xjb
    dummy.xml –> dummy.xsd.


  2. Hey, thanks for posting this. It saved me a lot of time.

  3. encountered the same issue. your post was just the insight needed. thanks!

  4. God bless you ! Many thanks from Italy.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


%d bloggers like this: