0

I am currently developing a REST API using a jersey based jetty server and JAX-RS.

I manage to receive and send in response any type of java object, the only problem is when that object contains one more object. For instance:

public class Dummy {
    private String msgType;
    private String content;
    private String receiver;
    private Object prop;


    public Dummy(){

    }

    /* Getters Setters/*

In this case there is no response built and i end up with a 500. If i remove the object from the class the communication is successfull.

Service:

@POST
@Path("/cfp")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response cfpmessage(@QueryParam("name") String name, String          
jsonRequest){

Gson gson = new Gson();
CFPMessage cfp = gson.fromJson(jsonRequest, CFPMessage.class);

cfp.setReceiver("SolverAgent");
try {
    JadeGateway.execute(cfp);
    System.out.println("Price: " + cfp.getProp().getPrice());
} catch(Exception e) { e.printStackTrace(); }

ProposeMessage p = new ProposeMessage();
p.setMsgType(cfp.getMsgType());
p.setReceiver(cfp.getReceiver());
p.setProp(cfp.getProp());  // -> cfp.getProp() returns an object

return Response.ok(p).build();

In the browser i get the following error, no clue where to look next:

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>Error 500 Internal Server Error</title>
    </head>
    <body>
        <h2>HTTP ERROR 500</h2>
        <p>Problem accessing /api/comm/cfp. Reason:

            <pre>    Internal Server Error</pre>
        </p>
        <hr>
        <i>
            <small>Powered by Jetty://</small>
        </i>
        <hr/>


    </body>
</html>

Edit: Forgot to mention that the inner object implements serializable ofc.

Any help would be appreciated!

Best Regards

Jorge Lima
  • 157
  • 15

0 Answers0