简体   繁体   中英

jackson web service error MessageBodyWriter not found for media type=application/json

i know that there are so many question about this...but they didn't fit for me, i tryed to reinstall maven (because creating a new maven project or convert an existing dynamic web project gave me error to pom.xml) in eclipse but it keep saying that is already installed...so i'm questioning about the fact that is it possible to get json from a rest web service without using maven? i already get string/xml/html from my ws, now i've created a new class like this:

@Path("/jsonServices")
public class JerseyRestService {

    @GET
    @Path("/print/{name}")
    @Produces(MediaType.APPLICATION_JSON)
    public Student produceJSON( @PathParam("name") String name ) {

        Student st = new Student(name, "Diaz",22,1);

        return st;

    }

i've referenced also those libraries:jackson-all-1.9.9.jar jersey-media-moxy-2.3.jar jersey-entity-filtering-2.21.jar genson-1.3.jar but the error it gave me is: MessageBodyWriter not found for media type=application/json

and the browser:

HTTP Status 500 - Internal Server Error

type Status report

message Internal Server Error

description The server encountered an internal error that prevented it from fulfilling this request.

I solved including in WEB-INF -> lib:

  • jersey-media-moxy-2.3.jar
  • org.eclipse.persistence.core_1.0.2.jar
  • org.eclipse.persistence.core-2.4.2.jar
  • org.eclipse.persistence.core-2.5.0-RC2.jar
  • org.eclipse.persistence.moxy-2.4.2.jar
  • genson-1.3.jar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM