Eclipse IDE integration  

Guide to ArcGIS Server templates and projects


The ArcGIS Server Plug-ins for Eclipse provide several templates and projects to help you quickly get started building applications and running samples. If you have not already installed the plug-ins, refer to the ArcGIS plug-in installation document.

 

Requirements to run the projects (Refer to http://support.esri.com for the latest configurations)

  • Eclipse WTP 1.5.x - Download from http://www.eclipse.org/webtools/.
  • Java 1.5.x
  • Apache Tomcat 5.5.x
  • JBOSS (NOTE: Only required when running the EJB samples or building EJB solutions. Optional for Web Applications)
    • 4.0.3 SP1 or higher for EJB Project
    • 4.0.2 for other Web applications

These required components must also be configured properly within Eclipse to run the ArcGIS plug-ins. The following links show the necessary steps:

 

After setting up the preferences and servers, you can begin a project. The following topics are covered in this document:

 

Configurations

 

Setting Eclipse ArcGIS preferences

Before beginning any project, it can be useful to set up common preferences for the new project wizards. Click Window>Preferences from the main menu. Select ArcGIS>Server from the left panel of the dialog box. The connection information entered here will be used by the project wizards. You can specify information needed to connect to some of the more commonly used servers such as ArcGIS Server, ArcIMS, and ArcGIS Web services. Each time you are prompted to add a data source, it will be automatically prefilled with these values.

You can also check the box to Show New Project Wizard Advanced Options. This will provide a couple of extra steps in the wizard for further customization if needed. By default this is unchecked.

 

 

Setting up Apache Tomcat

Tomcat 5.5.x can be downloaded from http://tomcat.apache.org/. It is also important to make sure that Tomcat is set to use a 1.5.x or higher JDK.  You should check by using the Configure Tomcat shortcut from the Tomcat install to display the properties dialog below. Click the Java tab and make sure the Java Virtual Machine is set to a jvm.dll located in a 1.5.x JDK.

 

To set up Tomcat in Eclipse, there are a few simple steps:

1. Click Windows>Preferences. In the Preferences dialog box, expand the Server option and select Installed Runtimes. Click the Add button.

 

2. Navigate to the appropriate Apache Tomcat server and click Next.

 

3. Click the Browse button and locate Tomcat installation directory on your file system. Click the Installed JREs button to add a JDK as the default JRE.  Check an appropriate JDK or click Add and browse for a JDK. Click OK to close the Preferences dialog box.

 

4. The dialog box appears as follows. Click Finish. It is ready to be used when creating new projects.

 

Setting up JBOSS

NOTE: This step is only required if you are going to be running or working with the EJB samples or building and testing EJB applications. Optionally, JBoss can be used as an alternative to Apache Tomcat for running the Web Application samples or building and testing Web Applications.

First download JBOSS from http://labs.jboss.com/portal/jbossas/download. The ArcGIS Server Eclipse plug-ins are developed and tested with JBOSS 4.0.3 SP1. After installing JBOSS, you need to create a folder for caching ArcGIS Server output under JBOSS_HOME\server\default\deploy where JBOSS_HOME is the location where you install JBOSS. The same folder should be specified as an output directory for ArcGIS Server when it is installed.

 

To set up JBoss in Eclipse, there are a few simple steps:

1. Choose Window>Preferences. In the Preferences dialog box, expand the Server option and select Installed Runtimes. Click the Add button.

 

2. Navigate to the appropriate JBOSS server and click Next.

 

3. You must browse for the correct application server directory (install location of JBOSS) and choose an appropriate JRE.

 

Click the Installed JRE preferences link if you need to install an appropriate JRE. Click the Installed JRES button to add a JDK as the default JRE. Check an appropriate JDK or click Add and browse for a JDK. Click OK to close the Preferences dialog box.

 

 

4. Click Finish after defining the JBOSS runtime. It is now ready to be used by the projects.

 

Web Mapping Application project

 

1. Create a new ArcGIS Server project. From the Eclipse main menu, select File>New>Project. Navigate to the ESRI Templates>Server and choose ArcGIS Server Project. Click Next.

 

2. Enter ArcGISWebProject for the name and choose a target runtime from the drop-down list. You need to have setup a server runtime as described in the Configurations section.

 

3. Input valid server information for the GIS server, username, password and domain. Click the Connect button. You see the server objects appear in the bottom left.  Then click the arrows to select which objects to use. Click Finish to build the project.

 

If you click Finish before setting up a GIS server or do not input all the information, you can only manually edit an XML file later on.  It is important to enter the information here. 

4. Once the project is created, you may see an agreement dialog from Sun regarding the cache. Click I agree. Eclipse also prompts you to switch to the J2EE perspective. Click Yes.

 

5. The new project is under the Dynamic Web Projects folder. You may have to open it to see your newly created project. Right-click the project and select Run As>Run on Server.

 

6. Choose the appropriate server to host your Web application. The first time, you must manually define the server. Subsequent uses allow you to choose an existing server. Click Finish to start your Web application.

 

The results appear in the integrated Eclipse viewer as in the following:

If you did not enter the correct GIS server information, you can navigate to the faces-config.xml file and edit it directly since it has already been instantiated. 

 

 

EJB Project

 

1. Create a new ArcGIS Server project. From the Eclipse main menu, select File>New>Project. Navigate to ESRI Templates>Server and choose ArcGIS EJB Project. Click Next.

 

 

2. Enter a project name and select a target runtime (JBoss v4.0). Click Next.

 

 

3. The Select Project Facets dialog box appears. Click Next.

 

4. The Modules dialog box now appears. Click New Modules to select the modules. Uncheck Application client module and Connector module. This tutorial project only requires an EJB module and a Web module. Click Finish.

 

5. An EJB module and Web module will be created and appear in the list. They are automatically checked. Click Next.

 

6. Select EJB Route Finder from the template list. The upper right contains information about the sample. You now need to create the EJBs using data sources. Click the Create button for NetworkAnalyst.

 

To use a JCA connector, check the Use JCA Connector box. Be sure to manually deploy the ArcGIS JCA connector by copying ARCGISHOME/java/ejb/lib/arcgis_jca.rar to the JBOSSHOME/server/default/deploy directory.

 

 

7. Input information to a server object with Network Analyst capabilities and accept the default name. Click OK.

 

8. Repeat the same steps for the Geocode EJB. Click the Create button and input the appropriate server information.

 

After creating the EJB type information, the dialog box appears as follows. Click Finish to create the new projects.

 

Three new projects are created as a result: an Enterprise Application project (Routing), a Dynamic Web Project, and an EJB Project:

 

 

9. To run the enterprise application, right-click the RoutingWeb web application and select Run As>Run on Server.

 

10. Select JBoss V4.0 from the list. Click Finish.

 

11. Eclipse deploys the EJBs and Web application to JBoss, and the Web application is displayed in a browser.

Enter the names of the EJBs you created earlier.


Also enter a start and end address. For example:
48 Turk St, 94102
2600 Sloat Blvd, 94116
1375 Fairfax Ave, 94124
50 Phelan Ave, 94112
1860 Hayes St, 94117
231 W Portal Ave, 94127

 

Click the Get Directions button.

 

The results appear on the map with printed directions on the right:

 

Web services project

Create a new ArcGIS Web service client application project.

 

1. From the Eclipse main menu, select File>New>Project. Choose the ArcGIS Web Services Project from ESRI Templates and click Next.

 

2. Select Map Viewer Application and click Next.

 

 

3. Enter a URL pointing to an ArcGIS web service catalog and press Enter. The wizard connects to the end point and finds all map server services (or other type of service based on the template selected) available from the catalog. For example: http://localhost:8399/arcgis/services

 

4. Select the map server you want use. You can also customize the application by checking or unchecking the appropriate controls.

 

5. Click Finish to create the project. Once the project is created, you might see an agreement dialog from Sun regarding the cache if this is your first time creating a web project. Click I agree. Eclipse will also prompt you to switch to the J2EE perspective. Click Yes.

 

6. WSProject and several Java files are displayed in the Package Explorer. Right-click MapViewer.java and select Run As>Java Application.

 

 

7. The Map Viewer application appears as follows:

 

8. Click the Get Web Services button to display a list of services in the drop-down menu for Map Server Web Service. Choose one of the services and it appears as follows:

 

Desktop application project

The desktop application project provides some base code for connecting to ArcGIS Server from a client application.

 

1. Create a new ArcGIS Server project. From the Eclipse main menu, select File>New>Project. Navigate to ESRI Templates>Server and choose ArcGIS Desktop Application Project. Click Next.

 

2. Accept the defaults and click Next. Input some valid connection information and click Finish.

 

A project is created with a ServerApp.java file. This file contains code to get a reference to a server context, initialize ArcObjects for server usage, and to obtain the SOM from the host machine.

 

Running ArcGIS server samples

The ArcGIS Web Samples wizard provides an easy way to quickly build and run the ArcGIS Server sample applications.

 

1. Create a new ArcGIS Server project. From the Eclipse main menu, select File>New>Project. Navigate to ESRI Templates>Server and choose ArcGIS Web Samples.  Click Next.

 

2. Give the project a name and choose a target runtime. If you have not defined a runtime, see the Configurations section. Click Next.

 

3. The dialog box provides the list of samples available. After selecting a sample, the description is provided in the top right. The data sources at the bottom automatically switches to the appropriate tab for the default data for that sample. After choosing the sample and selecting the data source, click Finish.

 

4. The new project is under the Dynamic Web Projects folder. You may have to open it to see your newly created project.  Right-click the project and select Run As>Run on Server. You may be asked to define a new server if you have not already done so. Simply choose the appropriate server from the list.

 

 

Importing a project from ArcGIS Manager

After creating a Web Application in ArcGIS Manager, you might want to further customize the application inside Eclipse. Once you have exported the application to a Web Archive File (WAR) it can be imported into Eclipse. However, any changes made in the Eclipse IDE are not reflected inside of ArcGIS Manager.

 

1. Select the File>Import option. Scroll down and select WAR file, then click Next.

 

2. Browse to the location of your WAR file. The Web project name is automatically selected. You must also set the target runtime if the default is not valid. Refer to the Configurations section if you have not already set up a server inside Eclipse. Click Finish to build the new project.

 

3. The project appears under the Dynamic Web Projects folder. You can expand that folder to see all its contents. To run the application, right-click the project folder and select Run As>Run on Server.