vertx-examples icon indicating copy to clipboard operation
vertx-examples copied to clipboard

SimpleREST return "Internal Server Error"

Open relucant1 opened this issue 6 years ago • 4 comments
trafficstars

image i can run the SimpleREST's main method ,but when i call /products in chrome ,the api return "Internal Server Error" with http code 500 and show nothing in my ide console.please tell me some.thanks

relucant1 avatar Apr 06 '19 09:04 relucant1

I can't reproduce. Do you have anything in the server logs?

tsegismont avatar Apr 06 '19 14:04 tsegismont

I can't reproduce. Do you have anything in the server logs?

nothing in server logs. i thought the server maybe not receive the request. but the httpcode is 500. it's so strange .i thought maybe there is something wrong in the request header.i'm trying to make the server available. appreciate any suggest very much. image

relucant1 avatar Apr 07 '19 05:04 relucant1

Weird. Can you add this to the router definition and try again:

    router.errorHandler(500, rc -> {
      System.err.println("Handling failure");
      Throwable failure = rc.failure();
      if (failure != null) {
        failure.printStackTrace();
      }
    });

tsegismont avatar Apr 10 '19 12:04 tsegismont

The reson is

java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonGenerator.writeStartObject(Ljava/lang/Object;)V
        at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:630)
        at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:33)
        at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
        at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319)
        at com.fasterxml.jackson.databind.ObjectMapper.writeValue(ObjectMapper.java:2656)
        at com.fasterxml.jackson.core.base.GeneratorBase.writeObject(GeneratorBase.java:355)
        at io.vertx.core.json.JsonObjectSerializer.serialize(JsonObjectSerializer.java:22)
        at io.vertx.core.json.JsonObjectSerializer.serialize(JsonObjectSerializer.java:19)
        at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:119)
        at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:79)
        at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:18)
        at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
        at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319)
        at com.fasterxml.jackson.databind.ObjectMapper._configAndWriteValue(ObjectMapper.java:3906)
        at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(ObjectMapper.java:3220)
        at io.vertx.core.json.jackson.JacksonCodec.toString(JacksonCodec.java:152)
        at io.vertx.core.json.JsonArray.encodePrettily(JsonArray.java:759)
        at web.Server.handleListProducts(Server.java:78)
        at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1034)
        at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:131)
        at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:130)
        at io.vertx.ext.web.impl.RouterImpl.handle(RouterImpl.java:54)
        at io.vertx.ext.web.impl.RouterImpl.handle(RouterImpl.java:36)
        at io.vertx.core.http.impl.WebSocketRequestHandler.handle(WebSocketRequestHandler.java:50)
        at io.vertx.core.http.impl.WebSocketRequestHandler.handle(WebSocketRequestHandler.java:32)
        at io.vertx.core.http.impl.Http1xServerConnection.handleMessage(Http1xServerConnection.java:136)
        at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:369)
        at io.vertx.core.impl.EventLoopContext.execute(EventLoopContext.java:43)
        at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:232)
        at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:173)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
       ... 
       ...

I add this , and it works.

      <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.10.1</version>
      </dependency>

onemsg avatar Dec 17 '19 12:12 onemsg