Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Got PropertyException when using MOXy
Got PropertyException when using MOXy [message #1234708] Wed, 22 January 2014 16:33 Go to next message
Paul G is currently offline Paul GFriend
Messages: 1
Registered: January 2014
Junior Member
Hey Forum!
I'm trying to use EclipseLink MOXy to marshal some models into XML. Therefor I would like to use ObjectGraphs to have a custom and different output of what is serialized into xml.

But when I try to implement the good examples of Blaise Doughan's blog (title: MOXy's Object Graphs - Input/Output Partial Models to XML & JSON) with Maven, I got following exception:
javax.xml.bind.PropertyException: name: eclipselink.object-graph value: contact info

Thats the used pom.xml:
<project xmlns="..." xmlns:xsi="..."
  xsi:schemaLocation="... ...">





This is the model (
package main.eclipselink_test;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

import org.eclipse.persistence.oxm.annotations.XmlNamedAttributeNode;
import org.eclipse.persistence.oxm.annotations.XmlNamedObjectGraph;

	    name="contact info",

public class Model {

	public Model() {
	public Model(int id, String name) { = id; = name;
    private int id;
    private String name;

Thats the Application (
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;

import org.eclipse.persistence.jaxb.MarshallerProperties;

public class App 
    public static void main( String[] args ) throws JAXBException
    	JAXBContext jc = JAXBContext.newInstance(Model.class);
    	Model model = new Model(0, "testing");
        // Output XML
        Marshaller marshaller = jc.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        marshaller.marshal(model, System.out);
        // Output XML - Based on Object Graph
        marshaller.setProperty(MarshallerProperties.OBJECT_GRAPH, "contact info");
        marshaller.marshal(model, System.out);

As you may see, I get the error message in
Exception in thread "main" javax.xml.bind.PropertyException: name: eclipselink.object-graph value: contact info
	at javax.xml.bind.helpers.AbstractMarshallerImpl.setProperty(Unknown Source)
	at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.setProperty(Unknown Source)
	at main.eclipselink_test.App.main(

(Sorry for the masses of code. I don't have the permission to post links.)

Does anybody have some suggestions what went wrong? Thanks!
Re: Got PropertyException when using MOXy [message #1235094 is a reply to message #1234708] Thu, 23 January 2014 15:07 Go to previous messageGo to next message
Matt MacIvor is currently offline Matt MacIvorFriend
Messages: 14
Registered: July 2009
Junior Member
Hi Paul,

The problem here is that you're not picking up the EclipseLink MOXy JAXB implementation. The class com.sun.xml.internal.bind.v2.runtime.MarshallerImpl if from the JAXB reference implementation included in the JDK.

In order to use the MOXy implementation, you will need to include a file in the package with your domain classes.

The file should contain:

This should trigger the EclipseLink implementation to be used instead of the RI.

I hope this helps


[Updated on: Thu, 23 January 2014 15:08]

Report message to a moderator

Re: Got PropertyException when using MOXy [message #1235125 is a reply to message #1234708] Thu, 23 January 2014 16:18 Go to previous message
Blaise Doughan is currently offline Blaise DoughanFriend
Messages: 163
Registered: July 2009
Senior Member

Hi Paul,

Here is a link to a Maven project I have on GitHub that you could use as a model:

You need to make sure the file is in the following location:

Previous Topic:Performance Question - eclipselink.jdbc.cache-statements
Next Topic:Add entities programmatically
Goto Forum:

Current Time: Tue Oct 13 08:56:53 GMT 2015

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

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