'dojo' is undefined

4564
5
Jump to solution
02-14-2013 08:26 AM
JonathanBailey
Occasional Contributor III
Hello,

Having a problem configuring the ArcGIS Server Javascript API. I've downloaded v3.3 from Esri.com, and followed the installation instructions. Since the target server does not have Internet access, I've changed the configuration to point to the Javascript API that I installed on the local server, following the directions in the REST API SDK help.

I've set up several services that are running, and I can view them in ArcMap and in ArcCatalog. However, when trying to view the services from ArcGIS Manager, the map does not appear, and the error ''dojo' is undefined' is thrown.

I think that the problem might be with how the URLs are being constructed in the output. Here are the contents of the rest-config.properties file that I modified according to the REST API SDK instructions:

#The log level of the application #possible values: SEVERE,WARNING,INFO,CONFIG,FINE,FINER,FINEST,OFF,ALL logLevel=SEVERE #enable/disable console logging consoleLogging=false #Collection of allowed cross-domain origins, If this property is not specified, it will default to allowing access to all domains allowedOrigins=* #Client App properties #JS API URLs jsapi.arcgis=http://172.10.1.41/arcgis_js_api/library/3.3/jsapi #jsapi.arcgis.sdk=http://help.arcgis.com/en/webapi/javascript/arcgis/ jsapi.arcgis.css=http://172.10.1.41/arcgis_js_api/library/3.3/jsapi/js/dojo/dijit/themes/tundra/tundra.css  #ArcGIS.com URLs arcgis.com.map=http://www.arcgis.com/home/webmap/viewer.html arcgis.com.map.text=ArcGIS.com Map


but looking at the HTML output when I try to preview the Sample World Cities, the URLs have changed:

[HTML]<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<title>ArcGIS JavaScript API: SampleWorldCities</title>
<style type="text/css"> @import "http://172.10.1.41/jsapi/arcgis/3.3/js/dojo/dijit/themes/tundra/tundra.css";
@import "/arcgis/rest/static/jsapi.css";
</style> <script type="text/javascript"> var djConfig = { parseOnLoad: true };
</script> <script type="text/javascript" src="http://172.10.1.41/jsapi/arcgis/?v=3.3"> </script> <script type="text/javascript"> dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("esri.map");
var map;
function init() {
    map = new esri.Map("map");
          var layer = new esri.layers.ArcGISDynamicMapServiceLayer("http://localhost:6080/arcgis/rest/services/SampleWorldCities/MapServer");
          map.addLayer(layer);
    var resizeTimer;
    dojo.connect(map, 'onLoad', function(theMap) {
      dojo.connect(dijit.byId('map'), 'resize', function() {
        clearTimeout(resizeTimer);
        resizeTimer = setTimeout(function() {
          map.resize();
          map.reposition();
         }, 500);
       });
     });
    }
dojo.addOnLoad(init);
</script> </head> <body class="tundra"> <div dojotype="dijit.layout.BorderContainer" design="headline" gutters="true" style="width: 100%; height: 100%; margin: 0;"> <div dojotype="dijit.layout.ContentPane" region="top" id="navtable"> <div style="float:left;" id="breadcrumbs">ArcGIS JavaScript API: SampleWorldCities</div> <div style="float:right;" id="help">
Built using the <a href="http://help.arcgis.com/en/webapi/javascript/arcgis/">ArcGIS JavaScript API</a>
</div> </div> <div id="map" dojotype="dijit.layout.ContentPane" region="center"> </div> </div> </body>
</html>
[/HTML]

Any ideas on what I should look at to fix my configuration?

Thanks,

Jon.
0 Kudos
1 Solution

Accepted Solutions
JonathanBailey
Occasional Contributor III
After consulting with Esri technical support, here are the full instructions for setting up a local install of the Javascript API. Following these instructions results in a properly configured Javascript API:


  1. Follow original JSAPI install help to modify init.js files using domain name or IP for the server name. (Note: if using the server name, the name must be fully-qualified with the domain name.)


  2. Open IIS and configure <server_name>\Sites\Default Web Site\arcgis_js_api\library\3.3\jsapi as a Web Application.


  3. Still in IIS, select Default Document for jsapi the web app.  Make sure that Default.ashx (case-sensitive) is in the list.


  4. Make modifications to C:\Program Files\ArcGIS\Server\framework\runtime\tomcat\webapps\arcgis#rest\WEB-INF\classes\resources\rest-config.properties.  Make sure lines 11 through 14 look like this:


  5. #JS API URLs jsapi.arcgis=http://<server_name>/arcgis_js_api/library/3.3/jsapi/ jsapi.arcgis.sdk=http://<server_name>/arcgis_js_sdk/sdk/ jsapi.arcgis.css=http://<server_name>/arcgis_js_api/library/3.3/jsapi/js/dojo/dijit/themes/tundra/tundra.css


  6. Make sure the following imports are in: C:\Program Files\ArcGIS\Server\framework\runtime\tomcat\webapps\arcgis#rest\www\client\mapserver\mapserverJSAPI.jsp:


  7. <style type="text/css"> @import "<%=jsapiArcgisCssUrl%>"; @import "<%=cpath%>/static/jsapi.css"; @import "<%=jsapiArcgisUrl%>/js/esri/css/esri.css"; </style>


View solution in original post

0 Kudos
5 Replies
JatinPatel
Occasional Contributor
Are you sure the IP address is not the issue.
To avoid it, change the address to one of esri's js library. same thing with dojo, if it works then something else is wrong.
0 Kudos
JonathanBailey
Occasional Contributor III
Yes, I'm sure the IP address is not the issue.

The machine is not connected to the Internet, so I cannot test with the libraries on Esri's site.
0 Kudos
DianaBenedict
Occasional Contributor III
Jon

When I use Chrome and plug in the ESRI library location
http://serverapi.arcgisonline.com/jsapi/arcgis/3.3/

I am able to see the following

/*
Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/

/*
This is an optimized version of Dojo, built for deployment and not for
development. To get sources and documentation, please visit:

  http://dojotoolkit.org
*/

//>>built

ETC......


On your local machine, when you plug in the src with the IP address are you able to see the code? or atleast get prompted to download the file (depending on your browser version.  If you not then there are additional issues going on such as unexpected firewalls or path is not specified correctly.

In some cases when I reference my own JS files I do the following:
<script type="text/javascript" src="js/mapOperations.js"></script>

Note the "js/..." is relative to where my html home page is loading.

I also see that your syntax is slightly different than mine for referencing the 3.3 Javascript API. You do the following ".../?v=3.3"  In my example I removed the "?v=" and simply put 3.3 .. though I am not sure if that even matters. Worth a try though.
0 Kudos
JonathanBailey
Occasional Contributor III
Hi Diana,

When I browse to the following in Chrome

http://172.10.1.41/jsapi/arcgis/?v=3.3

I get a 404 error. I expected this, because it's not the correct path to init.js. In the rest-config.properties, I specified the correct path, which is:

http://172.10.1.41/arcgis_js_api/library/3.3/jsapi/

When I browse to this path in Chrome, then the contents of the .js file are displayed.

But, note that I didn't specify the first path above -- it's what's contained in the HTML when I click on a map service in ArcGIS Manager to view it.

Thanks,

Jon.
0 Kudos
JonathanBailey
Occasional Contributor III
After consulting with Esri technical support, here are the full instructions for setting up a local install of the Javascript API. Following these instructions results in a properly configured Javascript API:


  1. Follow original JSAPI install help to modify init.js files using domain name or IP for the server name. (Note: if using the server name, the name must be fully-qualified with the domain name.)


  2. Open IIS and configure <server_name>\Sites\Default Web Site\arcgis_js_api\library\3.3\jsapi as a Web Application.


  3. Still in IIS, select Default Document for jsapi the web app.  Make sure that Default.ashx (case-sensitive) is in the list.


  4. Make modifications to C:\Program Files\ArcGIS\Server\framework\runtime\tomcat\webapps\arcgis#rest\WEB-INF\classes\resources\rest-config.properties.  Make sure lines 11 through 14 look like this:


  5. #JS API URLs jsapi.arcgis=http://<server_name>/arcgis_js_api/library/3.3/jsapi/ jsapi.arcgis.sdk=http://<server_name>/arcgis_js_sdk/sdk/ jsapi.arcgis.css=http://<server_name>/arcgis_js_api/library/3.3/jsapi/js/dojo/dijit/themes/tundra/tundra.css


  6. Make sure the following imports are in: C:\Program Files\ArcGIS\Server\framework\runtime\tomcat\webapps\arcgis#rest\www\client\mapserver\mapserverJSAPI.jsp:


  7. <style type="text/css"> @import "<%=jsapiArcgisCssUrl%>"; @import "<%=cpath%>/static/jsapi.css"; @import "<%=jsapiArcgisUrl%>/js/esri/css/esri.css"; </style>


0 Kudos