Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » EclipseLink MOXy exception due to package structure
EclipseLink MOXy exception due to package structure [message #1067854] Wed, 10 July 2013 21:49 Go to next message
Tim Braun is currently offline Tim Braun
Messages: 8
Registered: July 2013
Junior Member
I have this bindings file
<?xml version="1.0"?>
<xml-bindings
    xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"
    package-name="com">
    <java-types>
        <java-type name="com.test.Root">
            <xml-root-element name="root"/>
            <java-attributes>
                <xml-element java-attribute="element" xml-path="element" type="com.Element"/>
			</java-attributes>
        </java-type>
        <java-type name="com.Element"></java-type>
    </java-types>
</xml-bindings>

The package structure and the class location are as can be read off this bindings file.
When I unmarshall I get the following exception. Can somebody tell me why and how I can solve the problem? I don't want to change my package structure.

    JAXBException: The java-type with package [com.test] is not allowed in the bindings file keyed on package [com].
Re: EclipseLink MOXy exception due to package structure [message #1076520 is a reply to message #1067854] Wed, 31 July 2013 14:15 Go to previous message
Blaise Doughan is currently offline Blaise Doughan
Messages: 163
Registered: July 2009
Senior Member

You need to have one binding file per package. BTW when you specify the package name in the `xml-bindings` element you don't need to fully qualify the name on the `java-type` element.

When creating the JAXBContext on multiple binding files you can do the following:

List<String> mappingFiles = new ArrayList<String>(2);
mappingFiles.add("test/fooBindings.xml");
mappingFiles.add("test/barBindings.xml");
      
Map<String, Object> properties = new HashMap<String, Object>(1);
properties.put(JAXBContextProperties.OXM_METADATA_SOURCE, mappingFiles);
JAXBContext jaxbContext = JAXBContextFactory.createContext(new Class[] {Root.class}, properties);
Previous Topic:MOXy: Binding working and not working with 'same' XmlPath
Next Topic:EclipseLink MOXy: Logical operators in XmlPath annotation
Goto Forum:
  


Current Time: Fri Oct 31 05:42:42 GMT 2014

Powered by FUDForum. Page generated in 0.02159 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software