1

Java class:

package com;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class Bean {
   private String columnOne ;
   private String columnTwo;
   public String getColumnOne() {
      return columnOne;
 }
 public void setColumnOne(String columnOne) {
    this.columnOne = columnOne;
}
public String getColumnTwo() {
    return columnTwo;
}
public void setColumnTwo(String columnTwo) {
    this.columnTwo = columnTwo;
}
}

Main class:

package com;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;

public class JsonGenerator {

public static void main(String[] args) throws JAXBException {

    Bean b = new Bean();
    b.setColumnOne("a");
    b.setColumnTwo("b");

    JAXBContext jc = JAXBContext.newInstance(Bean.class);

    Marshaller marshaller = jc.createMarshaller();
    marshaller.setProperty("eclipselink.media.type","application/json");
    marshaller.marshal(b, System.out);

  }

  }

Exception:

Exception in thread "main" javax.xml.bind.PropertyException: name: eclipselink.media.type value: application/json at org.eclipse.persistence.jaxb.JAXBMarshaller.setProperty(JAXBMarshaller.java:891) at com.JsonGenerator.main(JsonGenerator.java:25)

can anybody please help in fixing the problem.

user2477196
  • 19
  • 1
  • 2
  • This seems to be related to : http://stackoverflow.com/questions/18498635/propertyexception-when-setting-marshaller-property-with-eclipselink-media-type-v – Eric Feb 26 '15 at 09:42

0 Answers0