Announcement

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

    Function expected error

    One module in our application uses SmartGWT. This module worked fine for sometime. We made a few changes - refactoring the code and upgrading to the latest GWT SDK. I tried with various versions (GWT 2.0.4, GWT 2.2.0, 2.3.0) and SmartGWT 2.4 and the latest nightly build. Any suggestions to resolve this problem?

    We are getting an error at "mainPanel.add".

    HorizontalPanel mainPanel;
    HStack hstack;
    ....
    Canvas canvas = new Canvas();
    canvas.addChild(hstack);
    HorizontalPanel mainPanel.add(canvas);

    Error Details:
    Message from webpage
    Run debugger?
    Error:
    'Function expected' in .../prototype.js at line 313
    ...... recursed on Canvas.draw

    (OK) (Cancel)

    Development Mode Logger Output:
    (CustomUnCaughtExceptionHandler.java:44) 2011-06-28 09:52:27,271 [ERROR] CustomExceptionHandler. Message : One or more exceptions caught, see full set in UmbrellaException#getCauses, Cause : com.google.gwt.core.client.JavaScriptException: (Error): Unknown failure, LocalizedMessage : One or more exceptions caught, see full set in UmbrellaException#getCauses, StackTrace : [Ljava.lang.StackTraceElement;@bb05d6
    com.google.gwt.event.shared.UmbrellaException: One or more exceptions caught, see full set in UmbrellaException#getCauses
    at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:129)
    at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:124)
    at com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java:116)
    at com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java:172)
    at com.google.gwt.user.client.ui.Image.onBrowserEvent(Image.java:665)
    at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1321)
    at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1277)
    at sun.reflect.GeneratedMethodAccessor61.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    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:167)
    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:132)
    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.GeneratedMethodAccessor57.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    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:167)
    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(Unknown Source)
    Caused by: com.google.gwt.core.client.JavaScriptException: (Error): Unknown failure
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:237)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:289)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
    at com.smartgwt.client.widgets.BaseWidget.draw(BaseWidget.java)
    at com.smartgwt.client.widgets.BaseWidget.getElement(BaseWidget.java:292)
    at com.smartgwt.client.widgets.BaseWidget.getElement(BaseWidget.java:264)
    at com.google.gwt.user.client.ui.ComplexPanel.add(ComplexPanel.java:94)
    at com.google.gwt.user.client.ui.HorizontalPanel.add(HorizontalPanel.java:49)
    ... 30 more

    #2
    3rd party code (in prototype.js) is crashing, not SmartGWT.

    Comment


      #3
      Please look at the error details below. It appears that
      com.smartgwt.client.core.JsObject is causing this problem. If I am mistaken, please correct me, after all I am no JavaScript expert. Is it possible that SmartGWT has a name collision with another module (GWM/prototype.js)? This could happen if SmartGWT and GWM are using different versions of prototype.js. Even if the problem was not caused by SmartGWT, you guys are smart. Could you point me to some direction to troubleshoot this issue?

      11:12:57.046 [ERROR] [client] 11:12:57.046:WARN:Log:Error: 'Function expected' in http://127.0.0.1:8888/client/gwm/ext/scripts/prototype.js at line 313
      anonymous(iterator=>anonymous()) anonymous(iterator=>"frozen", true) ListGrid.deriveFrozenFields() ListGrid.deriveVisibleFields() ListGrid.setFields(_1=>Array[1]) ListGrid.prepareForDraw() ListGrid.draw(_1=>undef, _2=>undef, _3=>undef, _4=>undef) Layout.layoutChildren(_1=>"initial draw", _2=>undef, _3=>undef) Layout.drawChildren() Canvas.draw(_1=>undef) Canvas.drawChildren() ** recursed on Canvas.draw
      com.smartgwt.client.core.JsObject$SGWT_WARN: 11:12:57.046:WARN:Log:Error: 'Function expected' in http://127.0.0.1:8888/client/gwm/ext/scripts/prototype.js at line 313
      anonymous(iterator=>anonymous()) anonymous(iterator=>"frozen", true) ListGrid.deriveFrozenFields() ListGrid.deriveVisibleFields() ListGrid.setFields(_1=>Array[1]) ListGrid.prepareForDraw() ListGrid.draw(_1=>undef, _2=>undef, _3=>undef, _4=>undef) Layout.layoutChildren(_1=>"initial draw", _2=>undef, _3=>undef) Layout.drawChildren() Canvas.draw(_1=>undef) Canvas.drawChildren() ** recursed on Canvas.draw
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105)
      at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
      at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167)
      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:132)
      at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
      at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:289)
      at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
      at com.smartgwt.client.widgets.BaseWidget.draw(BaseWidget.java)
      at com.smartgwt.client.widgets.BaseWidget.getElement(BaseWidget.java:292)
      at com.smartgwt.client.widgets.BaseWidget.getElement(BaseWidget.java:264)
      at com.google.gwt.user.client.ui.ComplexPanel.add(ComplexPanel.java:94)
      at com.google.gwt.user.client.ui.HorizontalPanel.add(HorizontalPanel.java:49)
      at ....

      Comment


        #4
        We don't use prototype.js. The first line of the stack trace indicates a crash in prototype.js:

        11:12:57.046 [ERROR] [client] 11:12:57.046:WARN:Log:Error: 'Function expected' in http://127.0.0.1:8888/client/gwm/ext/scripts/prototype.js at line 313
        It's probably something along the lines of a collision in functionality added to native objects such as Array. Note we fixed one such known collision after 2.4, so you might try a nightly.

        Comment


          #5
          Your responses are not YET helpful for me. I tried SmartGWT nightly builds but no improvement yet.

          You said "The first line of the stack trace indicates a crash in prototype.js"
          But the second line also indicates that SmartGWT "com.smartgwt.client.core.JsObject" is somehow involved in this issue. prototype.js is part part of GWM library. We got many modules that do not use SmartGWT and they all work fine. This one particular module that uses SmartGWT crashing indicates to me that SmartGWT could be the main actor. Could you be a little more open to better understand and resolve this issue?

          Comment


            #6
            We've actually pointed you right to the problem twice now: "It's probably something along the lines of a collision in functionality added to native objects such as Array" - this means you have to look at the line in question in your copy of prototype.js and figure out what native function prototype is overriding.

            You may not be familiar enough with JavaScript to handle this, but that's not us being unhelpful, we can't run your code to see the problem.

            It may also help to switch the order of imports so SmartGWT is last. This will cause SmartGWT to override methods installed by prototype.js instead of vice versa, and the methods installed by SmartGWT may handle a superset of prototype's needs but not vice versa.

            Comment


              #7
              Thank you. The above response was somewhat helpful. I am not sure where we can control the imports or the classpath in a deployment(war) file where the lib directory has above 300 jar files. Do you guys have any other suggestions?

              The line 313 points to
              if (iterator(value, index))
              in the following code. I also attached the actual prototype.js.

              var Enumerable = {......
              findAll: function(iterator) {
              var results = [];
              this.each(function(value, index) {
              if (iterator(value, index))
              results.push(value);
              });
              return results;
              },
              Last edited by stagirus; 7 Jul 2011, 16:15.

              Comment


                #8
                It's not .jar files. Reorder your .gwt.xml <inherits> to put SmartGWT last.

                Comment


                  #9
                  You made my day sir. That worked. Thank you very much. During our recent refactoring, SmartGWT moved up in the imports/inherits. That seems to be the cause of this problem.

                  Obviously, "import" and "include" have so many (overridden) meanings!

                  Comment

                  Working...
                  X