18 Replies Latest reply on Feb 7, 2013 1:23 PM by rowead

    Issue Upgrading to version 3.0

    aconner
      I am attempting to upgrade to version 3.0 of the API, and I have started getting errors.  The error I get is seen in the sample http://help.arcgis.com/en/webapi/javascript/arcgis/demos/widget/widget_basemapManual.html  I imagine this is a bug since the sample is broken as well.  Has anyone else seen or resolved this issue?

      Thanks,
      Adam Conner
      City of Philadelphia
        • Re: Issue Upgrading to version 3.0
          jeff.pace
          I am attempting to upgrade to version 3.0 of the API, and I have started getting errors.  The error I get is seen in the sample http://help.arcgis.com/en/webapi/javascript/arcgis/demos/widget/widget_basemapManual.html  I imagine this is a bug since the sample is broken as well.  Has anyone else seen or resolved this issue?

          Thanks,
          Adam Conner
          City of Philadelphia


          I get the same error, both on the sample and on my own app.

          Whenever a layer is loaded it tries to access
          http://sampleserver1.arcgisonline.com/ArcGIS/rest/info?f=json
          or in my case also
          http://services.arcgisonline.com/ArcGIS/rest/info?f=json (world basemap)
          and
          http://www.mymanatee.org/arcgis/rest/info?f=json (local services)

          These return valid json (200 0k http code) but for some reason throw an error in the app
          the error is (on the sample)

          XMLHttpRequest cannot load http://sampleserver1.arcgisonline.com/ArcGIS/rest/info?f=json. Origin http://help.arcgis.com is not allowed by Access-Control-Allow-Origin.

          and on my local development site
          XMLHttpRequest cannot load http://www.mymanatee.org/arcgis/rest/info?f=json. Origin http://jpgisdev.intranet is not allowed by Access-Control-Allow-Origin.

          Its seems like arcgis server is not properly returning the Access-Control-Allow-Origin "*" headers in the response.
          • Re: Issue Upgrading to version 3.0
            aconner
            I was able to get rid of the cross origin error by adding the allow cross origin header.  I used the instructions here: http://enable-cors.org/  I still get the "Uncaught TypeError: Cannot read property 'className' of null "  error even after this is fixed, this is the issue I am considering to be a bug until I hear otherwise.
            • Re: Issue Upgrading to version 3.0
              jeff.pace
              I was able to get rid of the cross origin error by adding the allow cross origin header.  I used the instructions here: http://enable-cors.org/  I still get the "Uncaught TypeError: Cannot read property 'className' of null "  error even after this is fixed, this is the issue I am considering to be a bug until I hear otherwise.


              Where did you add it?
              • Re: Issue Upgrading to version 3.0
                odoe
                Good, I assumed it was because I was running from a localhost, but then I pushed to a server and got same errors. In my case, it does not break my app, just a little annoying error. I've been running 3.0 through it's paces since yesterday and think I'm finally ready to update my apps.
                • Re: Issue Upgrading to version 3.0
                  khutchins-esristaff
                  This error can be ignored - here's a blurb from the help on this error:


                  Automatic detection of CORS support. This is done by attempting to access the /<instance-name>/rest/info endpoint of any ArcGIS server instance used in an ArcGIS API for JavaScript application. For servers that do not support CORS, this request will fail and an error will be logged to the browser's developer console. This can be observed in most of the API's samples as the majority of the servers used do not support CORS. This error can safely be ignored. There are cases where the API will not send a request to /<instance-name>/rest/info and are as follows:
                  The browser does not support CORS
                  The Server is already listed in esri.config.defaults.io.corsEnabledServers
                  esri.config.defaults.io.corsDetection is false
                  JSON is used instead of JSONP in the following cases:
                  The resource being fetched is on the same domain as the application
                  The resource being fetched is on a server that supports CORS

                  To read the blurb in context see the API reference for esri.request
                  http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/namespace_esri.htm
                  • Re: Issue Upgrading to version 3.0
                    aconner
                    This error can be ignored - here's a blurb from the help on this error:


                    Automatic detection of CORS support. This is done by attempting to access the /<instance-name>/rest/info endpoint of any ArcGIS server instance used in an ArcGIS API for JavaScript application. For servers that do not support CORS, this request will fail and an error will be logged to the browser's developer console. This can be observed in most of the API's samples as the majority of the servers used do not support CORS. This error can safely be ignored. There are cases where the API will not send a request to /<instance-name>/rest/info and are as follows:
                    The browser does not support CORS
                    The Server is already listed in esri.config.defaults.io.corsEnabledServers
                    esri.config.defaults.io.corsDetection is false
                    JSON is used instead of JSONP in the following cases:
                    The resource being fetched is on the same domain as the application
                    The resource being fetched is on a server that supports CORS

                    To read the blurb in context see the API reference for esri.request
                    http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/namespace_esri.htm


                    Kelly,
                      the CORS issue I am fine with ignoring, the fact that the sample code for creating a basemap gallery breaks is not related to CORS.  The link to the sample is here http://help.arcgis.com/en/webapi/javascript/arcgis/demos/widget/widget_basemapManual.html
                    on line 83

                    var basemapGallery = new esri.dijit.BasemapGallery({
                             showArcGISBasemaps:false,
                             basemaps:basemaps,
                             map:map
                            },"basemapGallery");
                            basemapGallery.startup();
                    


                    that call causes an uncaught error: "Uncaught TypeError: Cannot read property 'className' of null "

                    this is the issue that still exists and cannot be ignored.
                    • Re: Issue Upgrading to version 3.0
                      RWinter85
                      Im having a similar issue.  I upgraded my map to 3.0 this morning and at first it would not work at all until I moved some variables around.  Got it too work temporarily, went to lunch, and when I got back it was no longer working.   The error is "Type Error: cannot call method 'setRenderer' of null".  It is referring to where I call map.graphics.setRenderer(renderer), I had it working on 2.8 and even on 3.0 for a little but all of sudden the map stopped working.  Also getting "Uncaught Error: esri is not defined" when I try to create an extent object to be used as my initial extent.
                      • Re: Issue Upgrading to version 3.0
                        khutchins-esristaff
                        Ok this issue looks like a bug but you can workaround it by adding the following before creating the basemap gallery

                        esri.dijit.BasemapGallery.prototype._markSelected = function (basemap) {
                          if (basemap) {
                            // unselect all basemap gallery items
                            dojo.forEach(dojo.query(".esriBasemapGallerySelectedNode",
                        this.domNode), function (node) {
                              dojo.removeClass(node, "esriBasemapGallerySelectedNode");
                            });
                            // select current basemap gallery item
                            var basemapNode = dojo.byId("galleryNode_" + basemap.id);
                            if (basemapNode) {
                              dojo.addClass(basemapNode, "esriBasemapGallerySelectedNode");
                            }
                          }
                        }
                        



                        Kelly,
                          the CORS issue I am fine with ignoring, the fact that the sample code for creating a basemap gallery breaks is not related to CORS.  The link to the sample is here http://help.arcgis.com/en/webapi/javascript/arcgis/demos/widget/widget_basemapManual.html
                        on line 83

                        var basemapGallery = new esri.dijit.BasemapGallery({
                                 showArcGISBasemaps:false,
                                 basemaps:basemaps,
                                 map:map
                                },"basemapGallery");
                                basemapGallery.startup();
                        


                        that call causes an uncaught error: "Uncaught TypeError: Cannot read property 'className' of null "

                        this is the issue that still exists and cannot be ignored.
                        • Re: Issue Upgrading to version 3.0
                          khutchins-esristaff
                          Robert,

                          Check out the 'Migrating to 3.0' doc for some tips on upgrading your app:

                          http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp/migration_30.htm

                          If that doesn't help can you provide a code snippet that shows the problem?


                          Im having a similar issue.  I upgraded my map to 3.0 this morning and at first it would not work at all until I moved some variables around.  Got it too work temporarily, went to lunch, and when I got back it was no longer working.   The error is "Type Error: cannot call method 'setRenderer' of null".  It is referring to where I call map.graphics.setRenderer(renderer), I had it working on 2.8 and even on 3.0 for a little but all of sudden the map stopped working.  Also getting "Uncaught Error: esri is not defined" when I try to create an extent object to be used as my initial extent.
                          • Re: Issue Upgrading to version 3.0
                            RWinter85
                            Robert,

                            Check out the 'Migrating to 3.0' doc for some tips on upgrading your app:

                            http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp/migration_30.htm

                            If that doesn't help can you provide a code snippet that shows the problem?


                            Sure, I actually spoke a hair too soon about the "Type Error: cannot call method 'setRenderer' of null", after I posted my first comment I closed the browser and restarted it and I was no longer receiving that error, so now the map is up and running but I am still getting an error on creating an extent, Uncaught ReferenceError: esri is not defined, it is pointing to this little bit of code :
                            var initExtent = new esri.geometry.Extent({
                                "xmin":-15654227.28,
                                "ymin":1644618.94,
                                "xmax":-6848681.62,
                                "ymax":7514982.71,
                                "spatialReference":{
                                  "wkid":102100}
                            });
                             
                            I have noticed that if I comment this section out, on the next line of this file I create a symbol object and then I get the same error saying esri is not defined pointing to the symbol object instead, Ill include that code as well just in case it can help
                            var sfs = new esri.symbol.SimpleFillSymbol(
                                      esri.symbol.SimpleFillSymbol.STYLE_SOLID,
                                      new esri.symbol.SimpleLineSymbol(
                                        esri.symbol.SimpleLineSymbol.STYLE_SOLID,
                                        new dojo.Color([0, 0, 0]), 
                                        0.5 
                                      ),
                                      null
                            );

                            Thanks in advance.
                            • Re: Issue Upgrading to version 3.0
                              khutchins-esristaff
                              The posted code looks fine. Can you post your complete app or better yet a simplified version that will demonstrate the problem?

                              Sure, I actually spoke a hair too soon about the "Type Error: cannot call method 'setRenderer' of null", after I posted my first comment I closed the browser and restarted it and I was no longer receiving that error, so now the map is up and running but I am still getting an error on creating an extent, Uncaught ReferenceError: esri is not defined, it is pointing to this little bit of code :
                              • Re: Issue Upgrading to version 3.0
                                mattlane86
                                RWinter85, in my experience when you get that error, you are using the esri object before it has been downloaded and defined. Meaning you are probably calling it before the DOM is ready.
                                • Re: Issue Upgrading to version 3.0
                                  RWinter85
                                  Thanks for the quick response everyone.  Matt that was it.  I had moved those two sections of code to a separate .js file where I kept all of my global variables, so I moved them again but this time into my onLoad function which get's added on load and that fixed it.  I am glad it turned out to be an easy fix.  Thanks again.
                                  • Re: Issue Upgrading to version 3.0
                                    fiallega
                                    when trying to display any of the examples from the browser hitting directly the page by using file:///
                                    I get 4 error that do NOT allow the map to display.
                                    Version 2.8 works perfectly fine. and version 3.0 also works fine if I display it form a server as you guys have said.
                                    I still would like to work locally hitting the page directly.
                                    Here are the errors, two of which are the Access-Control-Allow-Origin but there are 2 more:

                                    XMLHttpRequest cannot load http://serverapi.arcgisonline.com/jsapi/arcgis/3.0compact/js/esri/nls/jsapi_en-us.js. Origin null is not allowed by Access-Control-Allow-Origin.

                                    Error
                                    serverapi.arcgisonline.com:15
                                    _428 serverapi.arcgisonline.com:15
                                    dojo._ioSetArgs.ld serverapi.arcgisonline.com:15
                                    _1c6 serverapi.arcgisonline.com:15
                                    _1c4 serverapi.arcgisonline.com:15
                                    dojo.Deferred.reject.errback serverapi.arcgisonline.com:15
                                    dojo.Deferred._1c3.cancel.cancel serverapi.arcgisonline.com:15
                                    dojo.xhr serverapi.arcgisonline.com:15
                                    dojo.xhrGet serverapi.arcgisonline.com:15
                                    _17e serverapi.arcgisonline.com:15
                                    _4b9 serverapi.arcgisonline.com:15
                                    _17e serverapi.arcgisonline.com:15
                                    _14f._preloadLocalizations._19b serverapi.arcgisonline.com:15
                                    _186 serverapi.arcgisonline.com:15
                                    _199 serverapi.arcgisonline.com:15
                                    _14f._preloadLocalizations serverapi.arcgisonline.com:15
                                    (anonymous function) serverapi.arcgisonline.com:34
                                    _c7 serverapi.arcgisonline.com:15
                                    _36 serverapi.arcgisonline.com:15
                                    _16 serverapi.arcgisonline.com:15
                                    req serverapi.arcgisonline.com:15
                                    (anonymous function) serverapi.arcgisonline.com:34

                                    XMLHttpRequest cannot load http://serverapi.arcgisonline.com/jsapi/arcgis/3.0compact/js/dojo/dojox/gfx/svg.js. Origin null is not allowed by Access-Control-Allow-Origin.

                                    Uncaught Error: NETWORK_ERR: XMLHttpRequest Exception 101
                                    • Re: Issue Upgrading to version 3.0
                                      jeff.pace
                                      Just to double check, you aren't running this file locally are you? You could do this at 2.8, you can not at 3.0.  You have to run it from a webserver.
                                      • Re: Issue Upgrading to version 3.0
                                        fiallega
                                        Thanks for the response.
                                        Yes I am. Could you tell me what the difference is between 2.8 and 3.0 that I can not run it as a local file ?
                                        • Re: Issue Upgrading to version 3.0
                                          rowead
                                          I solved my error by moving my code into the function that is called by the dojo.ready(init) method.  Using some esri methods before dojo is ready seems to generate the:

                                               Uncaught ReferenceError: esri is not defined

                                          error.