Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    java.lang.IllegalArgumentException: convertToMap - unable to convert JavaScript objec

    The following version’s I am using
    IE 7  Version 7.0.5730.13
    GWT SDK  Version 2.1.1
    JDK 1.6

    Issue Information:
    In my code I am having one DynamicForm which is consisting of some TextItem and SelectItem fields.
    Even if I used or not used setRequired (true) for the form fields. But when I try to call form.validate(), the below error is coming. This error is causing because of the below code in the JSOHelper.class under smartgwt.jar.

    Note:
    In the previous GWT SDK version 2.0.x, I have not faced this issue. After upgrading to the latest version I am facing the below issue .
    As per my project requirements i need to validate the form fields. I am not sure why this issue raised in this version GWT 2.1.1.
    Please help me.


    The below method is called under JSOHelper.class, when form.validate method is called from client.
    public static Map convertToMap(JavaScriptObject jsObj, boolean listAsArray) {
    Object javaObj = convertToJava(jsObj, listAsArray);
    if (javaObj instanceof Map) {
    return (Map) javaObj;
    } else {
    throw new IllegalArgumentException("convertToMap - unable to convert JavaScript object passed in to a Map"
    + SC.echo(jsObj));
    }
    }


    Error Console Info:
    java.lang.IllegalArgumentException: convertToMap - unable to convert JavaScript object passed in to a Map{type: "custom",
    condition: anonymous()}
    at com.smartgwt.client.util.JSOHelper.convertToMap(JSOHelper.java:483)
    at com.smartgwt.client.util.JSOHelper.convertToMap(JSOHelper.java:495)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:326)
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:207)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:126)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeBoolean(ModuleSpace.java:184)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeBoolean(JavaScriptHost.java:35)
    at com.smartgwt.client.widgets.form.DynamicForm.validate(DynamicForm.java)
    at com.fisglobal.gwt.base.client.sepadd.debtorBankMandate.incomingSdd.ReturnRefundIncomingSddPanel.validateReturnIncomingSDDAddPanel(ReturnRefundIncomingSddPanel.java:662)
    at com.fisglobal.gwt.base.client.sepadd.debtorBankMandate.incomingSdd.ReturnRefundIncomingSddPanel$4.onClick(ReturnRefundIncomingSddPanel.java:624)
    at com.smartgwt.client.widgets.events.ClickEvent.dispatch(ClickEvent.java:98)
    at com.smartgwt.client.widgets.events.ClickEvent.dispatch(ClickEvent.java:1)
    at com.google.gwt.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:204)
    at com.google.gwt.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:103)
    at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:101)
    at com.smartgwt.client.widgets.BaseWidget.fireEvent(BaseWidget.java:66)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:326)
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:207)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:126)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
    at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
    at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:214)
    at sun.reflect.GeneratedMethodAccessor36.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:281)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:531)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
    at java.lang.Thread.run(Thread.java:619)

    #2
    Hi Vikram,
    We'll need more information to debug this issue.
    If you could put together a simple standalone test case based on your DynamicForm definition which reproduces the issue we can run it on our end and get to the bottom of this ASAP.

    Also which SmartGWT version are you using (If you're not sure, open the developer console and evaluate "isc.version" and let us know what is reported back).

    Thanks
    Isomorphic Software

    Comment


      #3
      Sorry for the late reply as busy with the schedules. Actually i have created a small stand alone application like below to test my scenario, but in stand alone application dynamic form is validating properly where as in my application only i am facing exception problem.

      And i am using SmartGWT version as 2.4

      Here is the stand alone application details and it's code.

      //On module load.
      public void onModuleLoad() {
      GadgetPanel gadget = new GadgetPanel();
      RootPanel.get("formContainer").add(gadget);

      }

      //Code for the GadgetPanel
      public class GadgetPanel extends Composite {
      private VLayout container= new VLayout(10);
      private DynamicForm form = new DynamicForm();
      public GadgetPanel() {
      initWidget(vLayout);
      prepareTextForm();
      prpareButton();
      container.redraw();
      }

      private void prpareButton() {
      final IButton button = new IButton("submit");
      button.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
      @Override
      public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) {
      try {
      form.validate();
      } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      }
      }
      });
      container.addMember(button);

      }

      private void prepareTextForm() {
      final TextItem name= new TextItem();
      name.setTitle("Name");
      ExperimentCustomValidator icc = new ExperimentCustomValidator();
      name.setValidators(icc);
      form.setFields(name);
      container.addMember(form);

      }
      }


      //code for the ExperimentCustomValidator which is going to check the text item has value or not. if there is no value then it will display a red bubble icon on that field.

      public class ExperimentCustomValidator extends CustomValidator {

      @Override
      protected boolean condition(Object value) {

      if(getFormItem() == null || getFormItem().toString().trim().length() < 0 || value == null) {
      return false;
      } else {
      return true;
      }
      }
      }

      Analysis report about the above code and my application code:
      ------------------------------------------------------------
      Case1: Clicked the submit button without entering the value in the text field and the debug point will come to the below code under this package class, com.smartgwt.client.util.JSOHelper

      public static Map convertToMap(JavaScriptObject jsObj, boolean listAsArray) {
      Object javaObj = convertToJava(jsObj, listAsArray);
      if (javaObj instanceof Map) {
      return (Map) javaObj;
      } else {
      throw new IllegalArgumentException("convertToMap - unable to convert JavaScript object passed in to a Map"
      + SC.echo(jsObj));
      }
      }

      ------------------------
      If we inspect the above javaObj variable, it will be as like below. I mean it is an instance of Map, so it is going inside if loop and then will go to my custom validator class (ExperimentCustomValidator ) to validate that filed. In this stand alone application it is working fine.
      javaObj HashMap<K,V> (id=155)

      Case2:
      Now i have removed my entire code and i kept the same code what i mentioned above, but in this case the above javaObj variable is not an instance of Map, so it is going to the else block and throwing the exception(IllegalArgumentException). Which is why i am not able to validate the form.

      Observation:
      1.I have used the same code only in both cases but why convertToMap method is not converting JavaScriptObject to the Map.
      2. And the above convertToMap method is called by the below method.
      public static Map convertToMap(JavaScriptObject jsObj) {
      return convertToMap(jsObj, false);
      }

      So here the above method is always sending false as a second argument, I am not sure why it is hard code like that in the smart gwt jar class file.

      3. Why we have to covert all-ways JavaScriptObject object as Map during form Validation.

      Please let me know your valuable inputs.

      Thank you,
      Vikram

      Comment


        #4
        Hello,

        i have same problem on my app on SmartGWT 3.0 (GWT 2.4.0; we are going to upgrade it, but project is too big).

        Problem is on CustomValidator and convertToMap. Problem exist randomly. Some time its work, but other time throws UmbrellaException.

        Pls exist there some working solution? Thx

        Comment


          #5
          Sorry, the only way we'd look at a problem in such an old version would be if you purchased Consulting time and paid hourly for the effort.

          You need to upgrade, and then if you still have a problem, let us know, with runnable code demonstrating the issue.

          Comment

          Working...
          X