Problems with ws

1

PersonalIamwhenitexecutesthepagetogeneratethejsonitonlyafternull,alreadyverifieditistakingthedataofthebankthestrangeranditisgivingthismessage:

  

Information:Scanningforrootresourceandproviderclassesinthe  packages:ResourceInformation:Rootresourceclassesfound:
  classResource.estoqueResourceInformation:Noproviderclasses  found.Information:InitiatingJerseyapplication,version'Jersey:  1.1112/09/201110:27AM'

/**Tochangethislicenseheader,chooseLicenseHeadersinProjectProperties.*Tochangethistemplatefile,chooseTools|Templates*andopenthetemplateintheeditor.*/packageResource;importController.estoqueControler;importModel.ESTOQUE;importjava.util.ArrayList;importjavax.ws.rs.GET;importjavax.ws.rs.Path;importjavax.ws.rs.Produces;/****@authorFelipee[![inseriradescriçãodaimagemaqui][1]][1]*/@Path("/estoque")
public class estoqueResource {

    @GET
    @Path("/Estoque")
    @Produces("application/json")
    public ArrayList<ESTOQUE> ESTOQUE() {
        return new estoqueControler().ESTOQUE();
    }
}
    
asked by anonymous 05.04.2016 / 02:44

1 answer

0

Jersey does not support automatic serialization of any kind, in the ArrayList case.

A Provider is a special type of class that checks the return type of the method and the format it is producing and, if it is compatible, it acts by serializing the object in that format.

You can write your own Provider , but the easiest solution is to provide an object in return that is compatible with an existing provider. Just create an annotated class with @XmlRootElement and put an attribute with the list inside the object.

Another option is to serialize the list inside the method by directly using a JSON library and return a String , because in this case the Jersey will not need a Provider . The advantage of this approach is flexibility, but it also leaves the code more "dirty".

    
05.04.2016 / 04:05