+ Reply to Thread
Results 1 to 19 of 19

Thread: Issue Upgrading to version 3.0

  1. #1
    Adam Conner
    Join Date
    Dec 2010
    Posts
    13
    Points
    0
    Answers Provided
    0


    0

    Default Issue Upgrading to version 3.0

    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/jav...mapManual.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

  2. #2
    Jeff Pace
    Join Date
    Jun 2010
    Posts
    912
    Points
    252
    Answers Provided
    38


    0

    Default Re: Issue Upgrading to version 3.0

    Quote Originally Posted by aconner View Post
    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/jav...mapManual.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.co...st/info?f=json
    or in my case also
    http://services.arcgisonline.com/Arc...st/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.co...st/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.
    Last edited by jeff.pace; 06-14-2012 at 06:48 AM.

  3. #3
    Adam Conner
    Join Date
    Dec 2010
    Posts
    13
    Points
    0
    Answers Provided
    0


    0

    Default Re: Issue Upgrading to version 3.0

    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.

  4. #4
    Jeff Pace
    Join Date
    Jun 2010
    Posts
    912
    Points
    252
    Answers Provided
    38


    0

    Default Re: Issue Upgrading to version 3.0

    Quote Originally Posted by aconner View Post
    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?

  5. #5
    Rene Rubalcava
    Join Date
    Apr 2010
    Posts
    464
    Points
    239
    Answers Provided
    39


    0

    Default Re: Issue Upgrading to version 3.0

    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.

  6. #6
    Kelly Hutchins

    Join Date
    Oct 2009
    Posts
    885
    Points
    622
    Answers Provided
    106


    0

    Default Re: Issue Upgrading to version 3.0

    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/jav...space_esri.htm

  7. #7
    Adam Conner
    Join Date
    Dec 2010
    Posts
    13
    Points
    0
    Answers Provided
    0


    0

    Default Re: Issue Upgrading to version 3.0

    Quote Originally Posted by Kelly View Post
    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/jav...space_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/jav...mapManual.html
    on line 83

    Code:
    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.

  8. #8
    Robert Winterbottom
    Join Date
    Feb 2012
    Posts
    37
    Points
    0
    Answers Provided
    0


    0

    Default Re: Issue Upgrading to version 3.0

    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.

  9. #9
    Kelly Hutchins

    Join Date
    Oct 2009
    Posts
    885
    Points
    622
    Answers Provided
    106


    0

    Default Re: Issue Upgrading to version 3.0

    Ok this issue looks like a bug but you can workaround it by adding the following before creating the basemap gallery

    Code:
    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");
        }
      }
    }

    Quote Originally Posted by aconner View Post
    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/jav...mapManual.html
    on line 83

    Code:
    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.

  10. #10
    Kelly Hutchins

    Join Date
    Oct 2009
    Posts
    885
    Points
    622
    Answers Provided
    106


    1

    Default Re: Issue Upgrading to version 3.0

    Robert,

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

    http://help.arcgis.com/en/webapi/jav...gration_30.htm

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


    Quote Originally Posted by RWinter85 View Post
    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.

  11. #11
    Robert Winterbottom
    Join Date
    Feb 2012
    Posts
    37
    Points
    0
    Answers Provided
    0


    0

    Default Re: Issue Upgrading to version 3.0

    Quote Originally Posted by Kelly View Post
    Robert,

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

    http://help.arcgis.com/en/webapi/jav...gration_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 :
    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
    Code:
    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.

  12. #12
    Kelly Hutchins

    Join Date
    Oct 2009
    Posts
    885
    Points
    622
    Answers Provided
    106


    0

    Default Re: Issue Upgrading to version 3.0

    The posted code looks fine. Can you post your complete app or better yet a simplified version that will demonstrate the problem?

    Quote Originally Posted by RWinter85 View Post
    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 :

  13. #13
    Matt Lane
    Join Date
    Oct 2009
    Posts
    113
    Points
    85
    Answers Provided
    15


    1

    Default Re: Issue Upgrading to version 3.0

    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.

  14. #14
    Robert Winterbottom
    Join Date
    Feb 2012
    Posts
    37
    Points
    0
    Answers Provided
    0


    0

    Default Re: Issue Upgrading to version 3.0

    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.

  15. #15
    Jorge Fiallega
    Join Date
    Jun 2010
    Posts
    35
    Points
    0
    Answers Provided
    0


    0

    Default Re: Issue Upgrading to version 3.0

    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/js...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/js...jox/gfx/svg.js. Origin null is not allowed by Access-Control-Allow-Origin.

    Uncaught Error: NETWORK_ERR: XMLHttpRequest Exception 101

  16. #16
    Jeff Pace
    Join Date
    Jun 2010
    Posts
    912
    Points
    252
    Answers Provided
    38


    0

    Default Re: Issue Upgrading to version 3.0

    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.

  17. #17
    Jorge Fiallega
    Join Date
    Jun 2010
    Posts
    35
    Points
    0
    Answers Provided
    0


    0

    Default Re: Issue Upgrading to version 3.0

    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 ?

  18. #18
    Jeff Pace
    Join Date
    Jun 2010
    Posts
    912
    Points
    252
    Answers Provided
    38


    0

    Default Re: Issue Upgrading to version 3.0

    suspicions are it is the dojo upgrade

    http://forums.arcgis.com/threads/615...3.0-of-the-API

  19. #19
    Andrew Rowe
    Join Date
    Feb 2013
    Posts
    1
    Points
    0
    Answers Provided
    0


    0

    Default Re: Issue Upgrading to version 3.0

    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.

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts