I'm new to MOXy.
I've tried to create a minimal Jersey application which tries to serialize an object containing a list of other objects as JSON. When I run this in Tomcat 7 under Eclipse, I get an Internal Server Error without a stack trace.
If I change the list in ObjWithList to be a List<String>, the program works as it should.
I'm using Tomcat 7, Jersey 2.9, Eclipse Kepler SR2, under Mac OS X.
I'd appreciate some help.
package nu.lewin.jsonTest;
// imports omitted for brevity
@XmlRootElement
public class ObjWithList {
public List<StringObj> stuff;
public ObjWithList()
{
stuff = new ArrayList<StringObj>();
stuff.add( new StringObj( "Banana" ) );
stuff.add( new StringObj( "Apple" ) );
}
}
package nu.lewin.jsonTest;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class StringObj {
public String name;
public StringObj( String str )
{
this.name = str;
}
}
The service looks like this:
package nu.lewin.jsonTest;
// imports removed for brevity
@Path( "/test" )
public class Service {
@GET
@Produces(MediaType.APPLICATION_JSON)
public ObjWithList createSimpleBean() {
return new ObjWithList();
}
}