Errai
  1. Errai
  2. ERRAI-537

Errai JAX-RS Jackson Enum java.util.Map keys values bug

    Details

    • Type: Bug Bug
    • Status: Closed Closed (View Workflow)
    • Priority: Major Major
    • Resolution: Done
    • Affects Version/s: 2.3.0.CR1
    • Fix Version/s: 2.3.0.Final
    • Component/s: ErraiJAXRS
    • Labels:
      None
    • Environment:
      GWT 2.5.0; Errai 2.3.0.CR1 ; resteasy.version 2.3.5.Final;
    • Workaround Description:
      Hide

      Change key of map to Integer insted of Enum types, and call SomeEnum.VALUE.ordinal() to put keys.

      Show
      Change key of map to Integer insted of Enum types, and call SomeEnum.VALUE.ordinal() to put keys.
    • Steps to Reproduce:
      Hide

      DTO:
      com.some.company.project.program.entities.TestCase

      import java.util.HashMap;
      import java.util.Map;
      import org.jboss.errai.common.client.api.annotations.Portable;

      public class TestCase {

      @Portable
      public static class SomeClass {
      private Map<SomeEnum, String> map = new HashMap<SomeEnum, String>();

      public Map<SomeEnum, String> getMap()

      { return map; }

      public void setMap(Map<SomeEnum, String> map)

      { this.map = map; }

      }

      @Portable
      public static enum SomeEnum

      { ENUM_VALUE }

      }

      Rest service:

      @Path("/test/")
      @Consumes(

      { MediaType.APPLICATION_JSON })
      @Produces({ MediaType.APPLICATION_JSON }

      )
      public class DataResourcesImpl {

      @Path("testGet")
      @POST
      public void testGet(SomeClass inData) {
      };
      }

      Method invoke data transfer from client to server side:

      @Inject
      private Caller<DataResourcesImpl> dataResources;

      SomeClass outData = new SomeClass();
      Map<SomeEnum, String> map = new HashMap<SomeEnum, String>();
      map.put(SomeEnum.ENUM_VALUE, "any type");
      outData.setMap(map);
      dataResources.call(new RemoteCallback<SomeClass>() {
      @Override
      public void callback(SomeClass response)

      { GWT.log(""); }

      }).testGet(outData);

      Show
      DTO: com.some.company.project.program.entities.TestCase import java.util.HashMap; import java.util.Map; import org.jboss.errai.common.client.api.annotations.Portable; public class TestCase { @Portable public static class SomeClass { private Map<SomeEnum, String> map = new HashMap<SomeEnum, String>(); public Map<SomeEnum, String> getMap() { return map; } public void setMap(Map<SomeEnum, String> map) { this.map = map; } } @Portable public static enum SomeEnum { ENUM_VALUE } } Rest service: @Path("/test/") @Consumes( { MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON } ) public class DataResourcesImpl { @Path("testGet") @POST public void testGet(SomeClass inData) { }; } Method invoke data transfer from client to server side: @Inject private Caller<DataResourcesImpl> dataResources; SomeClass outData = new SomeClass(); Map<SomeEnum, String> map = new HashMap<SomeEnum, String>(); map.put(SomeEnum.ENUM_VALUE, "any type"); outData.setMap(map); dataResources.call(new RemoteCallback<SomeClass>() { @Override public void callback(SomeClass response) { GWT.log(""); } }).testGet(outData);
    • Similar Issues:
      Show 10 results 

      Description

      Getting error while trying to send data with Map<EnumKey,AnyType> in it as parameter to REST service(@PUT,@POST) from client side to server side.
      Stack trace:
      INFO] WARN Failed executing PUT /api/getSearchResult
      [INFO] org.jboss.resteasy.spi.ReaderException: org.codehaus.jackson.map.JsonMappingException: Can not construct Map key of type com.some.company.project.program.entities.SomeEnum from String ""ENUM_VALUE"": not a valid representation: Can not construct Map key of type com.some.company.project.program.entities.SomeEnum from String ""ENUM_VALUE"": not one of values for Enum class
      [INFO] at [Source: org.mortbay.jetty.HttpParser$Input@243e9f36; line: 1, column: 196]
      [INFO] at [Source: org.mortbay.jetty.HttpParser$Input@243e9f36; line: 1, column: 196] (through reference chain: com.some.company.project.parser.shared.entities.SearchOptions["credentials"])
      [INFO] at org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:202)
      [INFO] at org.jboss.resteasy.core.MethodInjectorImpl.injectArguments(MethodInjectorImpl.java:136)
      [INFO] at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:159)
      [INFO] at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:257)
      [INFO] at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:222)
      [INFO] at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:211)
      [INFO] at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:542)
      [INFO] at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524)
      [INFO] at org.jboss.resteasy.core.SynchronousDispatcher.invokePropagateNotFound(SynchronousDispatcher.java:169)
      [INFO] at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:212)
      [INFO] at org.jboss.resteasy.plugins.server.servlet.FilterDispatcher.doFilter(FilterDispatcher.java:59)
      [INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
      [INFO] at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
      [INFO] at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      [INFO] at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
      [INFO] at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
      [INFO] at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
      [INFO] at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      [INFO] at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
      [INFO] at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      [INFO] at org.mortbay.jetty.Server.handle(Server.java:324)
      [INFO] at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
      [INFO] at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
      [INFO] at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
      [INFO] at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
      [INFO] at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
      [INFO] at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
      [INFO] at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
      [INFO] Caused by: org.codehaus.jackson.map.JsonMappingException: Can not construct Map key of type com.some.company.project.program.entities.SomeEnum from String ""ENUM_VALUE"": not a valid representation: Can not construct Map key of type com.some.company.project.program.entities.SomeEnum from String ""ENUM_VALUE"": not one of values for Enum class
      [INFO] at [Source: org.mortbay.jetty.HttpParser$Input@243e9f36; line: 1, column: 196]
      [INFO] at [Source: org.mortbay.jetty.HttpParser$Input@243e9f36; line: 1, column: 196] (through reference chain: com.some.company.project.parser.shared.entities.SearchOptions["credentials"])
      [INFO] at org.codehaus.jackson.map.JsonMappingException.from(JsonMappingException.java:163)
      [INFO] at org.codehaus.jackson.map.deser.StdDeserializationContext.weirdKeyException(StdDeserializationContext.java:255)
      [INFO] at org.codehaus.jackson.map.deser.std.StdKeyDeserializer.deserializeKey(StdKeyDeserializer.java:40)
      [INFO] at org.codehaus.jackson.map.deser.std.MapDeserializer._readAndBind(MapDeserializer.java:307)
      [INFO] at org.codehaus.jackson.map.deser.std.MapDeserializer.deserialize(MapDeserializer.java:249)
      [INFO] at org.codehaus.jackson.map.deser.std.MapDeserializer.deserialize(MapDeserializer.java:33)
      [INFO] at org.codehaus.jackson.map.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:299)
      [INFO] at org.codehaus.jackson.map.deser.SettableBeanProperty$MethodProperty.deserializeAndSet(SettableBeanProperty.java:414)
      [INFO] at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:697)
      [INFO] at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
      [INFO] at org.codehaus.jackson.map.ObjectMapper._readValue(ObjectMapper.java:2704)
      [INFO] at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1315)
      [INFO] at org.codehaus.jackson.jaxrs.JacksonJsonProvider.readFrom(JacksonJsonProvider.java:419)
      [INFO] at org.jboss.resteasy.core.interception.MessageBodyReaderContextImpl.proceed(MessageBodyReaderContextImpl.java:105)
      [INFO] at org.jboss.resteasy.plugins.interceptors.encoding.GZIPDecodingInterceptor.read(GZIPDecodingInterceptor.java:63)
      [INFO] at org.jboss.resteasy.core.interception.MessageBodyReaderContextImpl.proceed(MessageBodyReaderContextImpl.java:108)
      [INFO] at org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:169)
      [INFO] ... 27 more

        Activity

        Hide
        Christian Sadilek
        added a comment -

        Thanks for reporting. This should be fixed in the latest 2.3.0-SNAPSHOTs.

        Show
        Christian Sadilek
        added a comment - Thanks for reporting. This should be fixed in the latest 2.3.0-SNAPSHOTs.

          People

          • Assignee:
            Christian Sadilek
            Reporter:
            Pavel S
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: