2 Replies Latest reply: Jan 2, 2013 11:02 PM by Christian Sadilek RSS

    Problem demarshalling Map

    David Hahn Newbie

      Hello everyone!


      I have a resolver class which inlcudes a map with translations:


      public class TranslationResolver {
          public TranslationResolver(){}
          private Map<String, Map<String, String>> translations;
          public Map<String, Map<String, String>> getTranslations() {
              return translations;
          public void setTranslations(Map<String, Map<String, String>> translations) {
              this.translations = translations;


      and a service which has methods to return the resolver or the map from the resolver:


      public class RPCDemoService implements TranslationRemoteService {
          public TranslationResolver getResolver() {
              TranslationResolver transResolver = new TranslationResolver();
              Map<String, Map<String, String>> allTranslations = getTranslations();
              return transResolver;
          public Map<String, Map<String, String>> getTranslations() {
              //create map for german translations
              Map<String, String> deTranslations = new HashMap<String, String>();
              deTranslations.put("hello", "Hallo");
              deTranslations.put("one", "Eins");
              //create map for english translations
              Map<String, String> enTranslations = new HashMap<String, String>();
              enTranslations.put("hello", "Hello");
              enTranslations.put("one", "One");
              //put the translations together
              Map<String, Map<String, String>> allTranslations = new HashMap<String, Map<String,String>>();
              allTranslations.put("de", deTranslations);
              allTranslations.put("en", enTranslations);
              return allTranslations;


      When i call the getTranslations() method through a rpc proxy, i get the correct translations:

      Translations: {de={hello=Hallo, one=Eins}, en={hello=Hello, one=One}}


      But when i call the getResolver() method, the values of the inner map are null:

      Translations: {de={hello=null, one=null}, en={hello=null, one=null}}


      I found out, tha if I create a custom marshaller, copy content from generated marshaller (ServerMarshallingFactoryImpl.java) and delete the commented (setAssumedMapKeyType and setAssumedMapValueType) lines, it works:


      public TranslationResolver demarshall(EJValue a0, MarshallingSession a1) {
              try {
                if (a0.isNull()) {
                  return null;
                EJObject obj = a0.isObject();
                String objId = obj.get("^ObjectID").isString().stringValue();
                if (a1.hasObject(objId)) {
                  return a1.getObject(TranslationResolver.class, objId);
                TranslationResolver entity = new TranslationResolver();
                a1.recordObject(objId, entity);
                if ((obj.containsKey("translations")) && (!obj.get("translations").isNull())) {
                  entity.setTranslations((Map) java_util_Map.demarshall(obj.get("translations"), a1));
                return entity;
              } catch (Throwable t) {
                throw new RuntimeException("error demarshalling entity: org.errai.samples.rpcdemo.client.shared.TranslationResolver", t);



      I've attached a sample, which extends your RPC Demo and shows the problem