Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » MOXy failes to serialize list of objects
MOXy failes to serialize list of objects [message #1385603] Mon, 09 June 2014 20:54 Go to next message
Erland Lewin is currently offline Erland LewinFriend
Messages: 2
Registered: July 2009
Junior Member
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();
    }

}
Re: MOXy failes to serialize list of objects [message #1385634 is a reply to message #1385603] Tue, 10 June 2014 07:48 Go to previous message
Erland Lewin is currently offline Erland LewinFriend
Messages: 2
Registered: July 2009
Junior Member
Ok, I solved it.

The problem was that StringObj didn't have a public constructor with no arguments.

/Erland
Previous Topic:Sequence Generating with MappedSuperclass id
Next Topic:Lazy-loaded basic attribute never refreshed
Goto Forum:
  


Current Time: Tue Sep 24 01:24:42 GMT 2024

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

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

Back to the top