Getting started with Geomajas. Geomajas Developers and Geosparc

Similar documents
Struts 2 Maven Archetypes

Maven POM project modelversion groupid artifactid packaging version name

Sonatype CLM - IDE User Guide. Sonatype CLM - IDE User Guide

IBM. IBM WebSphere Application Server Migration Toolkit. WebSphere Application Server. Version 9.0 Release

EUSurvey OSS Installation Guide

Geomajas server documentation. Geomajas Developers and Geosparc

MAVEN INTERVIEW QUESTIONS

Checking Out and Building Felix with NetBeans

AUTOMATION TESTING FRAMEWORK FOR LUMINOUS LMS

Application prerequisites

If you don t have the JDK, you will need to install it. 1. Go to

Developing Android applications in Windows

What is Maven? Apache Maven is a software project management and comprehension tool (build, test, packaging, reporting, site, deploy).

Sample Spark Web-App. Overview. Prerequisites

Setting Up the Development Environment

EUSurvey Installation Guide

vrealize Code Stream Plug-In SDK Development Guide

Spring Web Services Tutorial With Example In

Setting up a Maven Project

TIBCO StreamBase 10.2 Building and Running Applications in Studio, Studio Projects and Project Structure. November 2017

Oracle Code Day Hands On Labs (HOL) (Install, Repository, Local Deploy, DevCS, OACCS)

Simplified Build Management with Maven

Module Road Map. 7. Version Control with Subversion Introduction Terminology

juddi Developer Guide

Overview of Web Application Development

This is a known issue (SVA-700) that will be resolved in a future release IMPORTANT NOTE CONCERNING A VBASE RESTORE ISSUE

AutoVue Integration SDK & Sample Integration for Filesys DMS

TransformixTools Axelor Demo Project

McMaster Service-Based ehealth Integration Environment (MACSeie) Installation Guide July 24, 2009

Unable To The Artifact From Any Repository Maven-clean-plugin

Oracle Code Day Hands On Labs HOL

System Installation Guide

Building ToCollege.net

Cisco CVP VoiceXML 3.1. Installation Guide

System Installation Guide

What s new in IBM Operational Decision Manager 8.9 Standard Edition

Slide 1 CS 170 Java Programming 1 Duration: 00:00:49 Advance mode: Auto

Dspace 5.1. Installation on Windows 7 (32 bit system)

Apache Directory Studio. User's Guide

IBM Maximo Anywhere Version 7 Release 6. Planning, installation, and deployment IBM

Maven. INF5750/ Lecture 2 (Part II)

NAMGIS Core manual. September 21, 2008

Maven Introduction to Concepts: POM, Dependencies, Plugins, Phases

Topics covered. Introduction to Maven Maven for Dependency Management Maven Lifecycles and Plugins Hands on session. Maven 2

Eclipse Ignore Xml Schema Problems >>>CLICK HERE<<<

TOP REASONS WHY YOU SHOULD SWITCH TO MAVEN 3

AppDev StudioTM 3.2 SAS. Migration Guide

Chapter 1: First steps with JAX-WS Web Services

CHAPTER 6. Organizing Your Development Project. All right, guys! It s time to clean up this town!

vsphere Client SDK Developer Guide 17 APR 2018 VMware vsphere 6.7 vsphere Client SDK 6.7

System Installation Guide

SVN_Eclipse_at_home. 1. Download Eclipse. a. Go to: and select Eclipse IDE for Java Developers

Introducing Apache Geronimo 1.1. Aaron Mulder CTO, Chariot Solutions Committer, Apache Geronimo

SE - Deployment to Installed Polarion. SE - Execution from Workspace. SE - Configuration.

Component based Development. Table of Contents. Notes. Notes. Notes. Web Application Development. Zsolt Tóth

KS CM 2.0 Implementation and Deployment Guide

Administering Apache Geronimo With Custom Server Assemblies and Maven. David Jencks

JDO Tools Guide (v5.1)

SmartPatch. Installation Manual Version 6.x

Google Plugin for Eclipse

Red Hat JBoss Enterprise Application Platform 6.4

Hello Maven. TestNG, Eclipse, IntelliJ IDEA. Óbuda University, Java Enterprise Edition John von Neumann Faculty of Informatics Lab 2.

form layout - we will demonstrate how to add your own custom form extensions in to form layout

Database Explorer Quickstart

i2b2 Workbench Developer s Guide: Eclipse Neon & i2b2 Source Code

Red Hat JBoss Developer Studio 10.4 Installation Guide

OSGeo Web Mapping Typification: GeoMajas, Mapbender, MapFish and OpenLayers. Christoph Baudson Arnulf Christl FOSS4G 2010 Barcelona

Red Hat JBoss Developer Studio 10.3 Getting Started with JBoss Developer Studio Tools

Oracle Developer Depot Technical Review

TIBCO LiveView Web Getting Started Guide

CSE 454 Final Report TasteCliq

IBM Maximo Anywhere Version 7 Release 6. Planning, installation, and deployment IBM

Content. Development Tools 2(57)

DevOps and Maven. Eamonn de Leastar Dr. Siobhán Drohan Produced by:

Sonatype CLM Enforcement Points - Nexus. Sonatype CLM Enforcement Points - Nexus

Javascript Validator Xml Schema Eclipse Plugin

Continuous Integration (CI) with Jenkins

SCCM Plug-in User Guide. Version 3.0

SOA-14: Continuous Integration in SOA Projects Andreas Gies

Appendix A: Courseware setup

App Studio 4.1 Deployment Guide

FIRST STEPS WITH SOFIA2

EMC Documentum Composer

Tutorial on Basic Android Setup

WA1927 Introduction to Struts 2.x Using Eclipse. Classroom Setup Guide. Web Age Solutions Inc. Copyright Web Age Solutions Inc.

PHEWR Installation Guide (version 3)

Jaxb2 Maven Plugin Could Not Process Schema

OpenL Tablets OpenL Tablets BRMS

Red Hat JBoss Developer Studio 11.3

Developing Ajax Web Apps with GWT. Session I

Apache Syncope - Getting Started. Version 2.0.7

Release Notes June 15, Date: 15-Jun :49 URL:

Please see the docs for latest release in 1.99.* Some of the information below might be outdated

PetaLinux SDK User Guide. Eclipse Plugin Guide

Red Hat Developer Studio 12.9

Software Development Kit

WFCE - Build and deployment. WFCE - Deployment to Installed Polarion. WFCE - Execution from Workspace. WFCE - Configuration.

SAP NW CLOUD HANDS-ON WORKSHOP

How To Get Database Schema In Java Using >>>CLICK HERE<<<

Webservices In Java Tutorial For Beginners Using Netbeans Pdf

Transcription:

Getting started with Geomajas Geomajas Developers and Geosparc

Getting started with Geomajas by Geomajas Developers and Geosparc 1.12.0-SNAPSHOT Copyright 2010-2014 Geosparc nv Abstract Documentation for first time users to get started with the Geomajas GIS framework.

Table of Contents 1. Starting a new GWT based Geomajas project... 1 1. Prerequisites / Command line... 1 2. Create your Geomajas project... 1 3. Run your Geomajas project... 3 4. Configure your Geomajas project... 3 5. Getting started with database layers... 4 6. How to continue... 5 2. Using Geomajas in your IDE of choice... 6 1. Eclipse... 6 1.1. Running/debugging with the Google Plug-in for Eclipse (embedded Jetty option)... 6 1.2. Running/debugging with the Google Plug-in for Eclipse... 11 2. IntelliJ IDEA... 11 3. NetBeans... 14 3. About... 15 1. About this project... 15 2. License information... 15 3. Author information... 15 iii

List of Figures 1.1. Choose the correct archetype... 2 1.2. Screenshot when building the Geomajas GWT archetype... 3 2.1. Import project as Maven project... 7 2.2. Eclipse project properties dialog, Google Web Toolkit... 8 2.3. Eclipse project properties dialog, Google Web Application... 8 2.4. Debug configurations dialog... 9 2.5. JettyRunner as main class... 9 2.6. Running Jetty... 10 2.7. Running the GWT application... 10 2.8. Classpath of GWT plug-in (no-server mode)... 11 2.9. Open project using pom... 12 2.10. IDEA GWT run configuration... 12 2.11. run gwt:i18 target... 13 2.12. Project structure for simple GWT project... 13 iv

List of Examples 1.1. Create project using Maven archetype... 1 1.2. Build the project and run it... 3 v

Chapter 1. Starting a new GWT based Geomajas project Geomajas uses the Apache Maven project management tool for its build and documentation process. The easiest way to start using Geomajas is by creating a new project using the Maven archetype. This will create a simple working project that you can use as a starting point. 1. Prerequisites / Command line To create the simple project with the Maven archetype, you need to install Maven on your system. Maven can be downloaded from http://maven.apache.org/. We recommend using the latest stable version (2.2.1 at the time of writing). Installing Maven is quite simple: unzip the distribution file in the directory of your choice and make some environment changes so you can run the executable mvn. More information for your specific OS can be found at the bottom of http://maven.apache.org/ download.html. 2. Create your Geomajas project At this point it is assumed that Maven has been successfully installed. Using Maven, you can now create your Geomajas project, called the Geomajas GWT Application archetype. 1. Step1: Go to the folder you want to create the Geomajas application in, and execute the following command: Example 1.1. Create project using Maven archetype mvn archetype:generate -DarchetypeCatalog=http://files.geomajas.org/archetype- The above catalog will give you the latest stable release, which is what you normally want. If you need the latest snapshot version, use the following catalog: mvn archetype:generate -DarchetypeCatalog=http://files.geomajas.org/latest/arc Maven will now prompt the user for input. Note If anything fails with these Maven commands, you need to check the output to check the problem. One typical problem is the need to define a proxy to allow Maven to access external repository websites. See the http://maven.apache.org/guides/mini/guideproxies.html for details. 2. Step2: Maven will display the full list of available archetypes. Make sure you select the correct one: geomajas-gwt-archetype. In the image below, the correct number would be 36: 1

Starting a new GWT based Geomajas project Figure 1.1. Choose the correct archetype 3. Step3: Next Maven asks for the groupid. Often the package name is used, but any other name will do (e.g. mygroupid). 4. Step4: Next Maven asks for the artifactid. This represents the name for your application (e.g. myapp). Note The artifactid cannot contain special characters! 5. Step5: Next Maven asks for the first version for your application. 1.0-SNAPSHOT is a good first version. 6. Step6: Next Maven asks for the base package wherein to place Java files. By default this is the same as the groupid. Just hit "enter" to continue with the default or enter another package name (e.g. my.app). 2

Starting a new GWT based Geomajas project Figure 1.2. Screenshot when building the Geomajas GWT archetype Tip You have now created a Geomajas project! Now you are ready to run it. 3. Run your Geomajas project 1. Step1: Go to the folder with the artifactid name (myapp in the example above) and execute the following command: Example 1.2. Build the project and run it mvn install jetty:run The "install" target will create a web archive (.war file) for the project in the target directory. This.war file can be dropped into a Java application container such as Tomcat. The "jetty:run" target will immediately start a jetty server and start the application in it. Jetty is a Java application container that can run your project without the need to install a separate Java application. 2. Step2: Open a web browser and access your Geomajas application at http://localhost:8080/. 4. Configure your Geomajas project Once you have your Geomajas project running, you might want to make some modifications to the Geomajas configuration and customize it. More details about the Geomajas configuration can be found in the developer's guide [http://files.geomajas.org/maven/trunk/geomajas/docbookdevuserguide/html/master.html#part-configuration]. Here you find the most important configuration files used in your Geomajas project: 3

Starting a new GWT based Geomajas project main configuration : src/main/webapp/web-inf/applicationcontext.xml map configuration : src/main/webapp/web-inf/mapmain.xml overview map configuration : src/main/webapp/web-inf/mapoverview.xml countries layer configuration : src/main/webapp/web-inf/clientlayercountries.xml and src/main/ webapp/web-inf/layercountries.xml OpenStreetMap layer configuration : src/main/webapp/web-inf/clientlayerosm.xml and src/ main/webapp/web-inf/layerosm.xml GWT configuration file : src/main/java/application.gwt.xml web.xml: src/main/webapp/web-inf/web.xml If you have the jetty server running and you make changes to the configuration, press ENTER to reload the application without stopping the server. 5. Getting started with database layers The Geomajas sample application comes with a predefined layer configuration for PostgreSQL/ PostGIS and SQLServer databases (configurations for other supported databases like Oracle and MySQL can be added in a similar way). To activate the database layer, the following steps should be taken: 1. Create the sample database. This should be a spatially enabled database with name 'app' and login user 'app' with password 'app'. 2. Import the layer data in the database. For reference, the data is provided as a shape file in the directory: src/main/resources/context/shapes/road.shp. There are also 2 scripts available for both the PostGIS and SQLServer databases: src/main/webapp/web-inf/example/road_postgres.sql and src/main/webapp/web-inf/example/road_sqlserver.sql. These can be run from PgAdmin or SQL Server Management Studio respectively. 3. Uncomment the necessary dependencies in your pom.xml file. Geomajas provides 2 layer plugins that can work with databases: Geotools layer and Hibernate layer plugin. The Geotools layer plugin does not require the creation of a Java mapping, which makes it easier to configure, but it also has no support for complex attributes (many-to-one, one-to-many). The Hibernate layer plugin does require Java mapping objects (have a look at the Road.java class to see how the mapping works) but offers complex attribute support instead. The choice of layer plugin will depend on the needs of your application and whether or not you want to make use of the advanced feature editing capabilities of Geomajas. As an example, for the Geotools layer with a PostGIS database, the following dependencies should be uncommented: <!-- uncomment if you want to use geotools with postgis, for another db you wi <dependency> <groupid>org.postgis</groupid> <artifactid>postgis-jdbc</artifactid> </dependency> <dependency> <groupid>postgresql</groupid> <artifactid>postgresql</artifactid> </dependency> 4. Uncomment the necessary application context entries in your web.xml file. This is necessary to add the roads layer to your Spring context definition. The specific entries to uncomment will again depend on your choice of layer plugin and database. For he Geotools layer with a PostGIS database, the following entries should be uncommented: 4

Starting a new GWT based Geomajas project <!-- To use Roads layer stored in PostGIS through GeoTools layer, uncomment th WEB-INF/example/geotools/mapMain.xml WEB-INF/example/geotools/spring-geotools.xml WEB-INF/example/geotools/clientLayerRoads.xml <!-- for PostGIS --> WEB-INF/example/geotools/postgis/layerRoads.xml 5. Restart your application. An editable road layer should appear. 6. How to continue The archetype generates a dependency on the geomajas-dep project to manage the version of the Geomajas dependencies. This project exists for the sole purpose of keeping track of the latest released versions. It is quite likely that a new version of geomajas-dep has been released since the latest release of the archetype. Therefore, we recommend you update this dependency to the latest version. You can check the latest version using this URL: http://repo.geomajas.org/nexus/index.html#nexussearch;quick~geomajas-dep. References which may be interesting to read: GWT project page: http://code.google.com/webtoolkit/. SmartGWT showcase: http://www.smartclient.com/smartgwt/showcase/. DZone's GWT refcardz: http://refcardz.dzone.com/refcardz/gwt-style-configuration-and-js. Spring documentation: http://www.springsource.org/documentation. DZone's Spring configuration refcardz: http://refcardz.dzone.com/refcardz/spring-configuration. Maven project: http://maven.apache.org/. Maven by example book: http://www.sonatype.com/books/mvnex-book/reference/publicbook.html. Maven reference book: http://www.sonatype.com/books/mvnref-book/reference/public-book.html. DZone's maven 2 refcardz: http://refcardz.dzone.com/refcardz/apache-maven-2. 5

Chapter 2. Using Geomajas in your IDE of choice This chapter is aimed at Java developers that whish to import the Geomajas project in their favourite IDE and start programming. The use of an IDE is not really required if you only want to configure layers, styles, etc. 1. Eclipse The combination of Eclipse, maven and GWT is not quite trivial, especially for advanced multi-module projects like Geomajas. There are 2 approaches possible for integrating eclipse with maven: Eclipse plug-in for maven, avoiding the use of the maven command-line interface: m2eclipse (http:// m2eclipse.sonatype.org/) is the most mature project here Maven plug-in to generate eclipse project configurations: maven-eclipse-plugin (http:// maven.apache.org/plugins/maven-eclipse-plugin/) It is clear that an IDE integrated solution like m2eclipse offers considerable advantages over manually generating Eclipse project configurations: direct import of maven projects support for maven properties and filtering In-place editing of poms full dependency support For a functional Geomajas setup, the following Eclipse plug-ins should be installed on a fresh Galileo download (http://www.eclipse.org/downloads/): m2eclipse: update site http://m2eclipse.sonatype.org/sites/m2e m2eclipse extras (especially WTP extension): http://m2eclipse.sonatype.org/sites/m2e-extras checkstyle: update site http://eclipse-cs.sf.net/update/ SVN team provider: update site http://download.eclipse.org/releases/helios, choose Collaboration ->Subversive SVN Team Provider (Incubation) Google's GWT Eclipse plug-in: http://dl.google.com/eclipse/plugin/3.6 (Plugin and SDK) 1.1. Running/debugging with the Google Plug-in for Eclipse (embedded Jetty option) There is a classpath issue with the Google Plug-in for Eclipse (GPE) that prevents us from using it in a reliable way when there are multiple versions of artifacts in the maven dependency tree: http://code.google.com/p/google-web-toolkit/issues/detail?id=5033 [http://code.google.com/p/ google-web-toolkit/issues/detail?id=5033] On top of that, GPE forces the use of the built-in jetty launcher, which has problems with loading libraries from the maven repository. Recent development by Google points in the direction of better 6

Using Geomajas in your IDE of choice maven support, but a as far as we know a stable solution which does not require explicit user interaction is not available. (see http://googlewebtoolkit.blogspot.com/2010/08/how-to-use-google-plugin-foreclipse.html). In view of these problems, the following workaround seems to be the most reliable way of using the GWT plugin for us: Run the GWT plug-in with the no-server option (this can be done straight from the project since GWT 2.1 Run an embedded Jetty server to replace the GWT server The following series of steps have to be performed to achieve a working project. Import the project as a maven project Figure 2.1. Import project as Maven project After the project has been imported and the workspace has been built, you should now manually mark the project as a GWT project in the project properties dialog. Open the Google -> Web Toolkit section and mark the checkbox. If the eclipse GWT version differs from the project version, the "Use specific SDK" checkbox will be enabled: 7

Using Geomajas in your IDE of choice Figure 2.2. Eclipse project properties dialog, Google Web Toolkit In the Google -> Web Application section, the WAR directory should be changed to the default maven war sources directory (src/main/webapp) Figure 2.3. Eclipse project properties dialog, Google Web Application Open the debug configurations dialog and create a new Java application: 8

Using Geomajas in your IDE of choice Figure 2.4. Debug configurations dialog Search for JettyRunner as the main class. JettyRunner is a specially prepared main class that starts up Jetty with the correct parameters (port 8888 and src/main/webapp as webapp directory) Figure 2.5. JettyRunner as main class Run the new Jetty server configuration (in debug mode): 9

Figure 2.6. Running Jetty Using Geomajas in your IDE of choice Now, run the GWT plug-in in no-server mode by by right-clicking on the project and selecting Debug As -> Web Application (running on an external server): Figure 2.7. Running the GWT application Click ok on the dialog screen You can now add breakpoints and debug your application as if it was a normal Java application. If you have multiple versions of GWT in your project workspace, make sure that the gwt-dev jar is in front of the default classpath (reported GWT issue): 10

Using Geomajas in your IDE of choice Figure 2.8. Classpath of GWT plug-in (no-server mode) 1.2. Running/debugging with the Google Plug-in for Eclipse If you want to run your application directly with GPE, some extra actions are needed to avoid classpath problems. You will have to change your web.xml by adding a special context listener that allows Spring component scanning and circumvents a GeoTools problem with the builtin Jetty classloader: <listener> <listener-class>org.geomajas.servlet.preparescanningcontextlistener</listener-c </listener> This solves most of the classpath problems but does not cure the problem of having multiple artifact versions in the classpath! This is usually only a problem when you have several Geomajas projects opened in your workspace. If this is the case, run the GWT plug-in with an embedded Jetty server as explained in the previous chapter and you should be fine. Note that this should be the first listener in your web.xm files, before the spring listeners. The following steps are needed to run GPE directly: Follow the configuration steps of the indirect mode, right up to the Jetty part Run the project as a GWT Web application by right-clicking on the project and selecting Run as -> Web Application. For debugging, debug the project as a GWT Web application by right-clicking on the project and selecting Debug as -> Web Application. 2. IntelliJ IDEA The setup in IntelliJ IDEA is quite straightforward and does not require running a separate Maven command. Just open the project from IDEA by selecting the pom in the root directory. 11

Using Geomajas in your IDE of choice Figure 2.9. Open project using pom IDEA will recognize this as a GWT project and assign the correct facet but as always you will have to make your own run configuration (which is fortunately trivial). You will need version 9.0 or later for the GWT 2.0 support. Figure 2.10. IDEA GWT run configuration Before being able to use this configuration, you need to invoke the gwt:i18n Maven target to assure the files which are used for internationalisation are available (otherwise, you will get compilation errors). You can do this from the "Maven projects" tab. 12

Figure 2.11. run gwt:i18 target Using Geomajas in your IDE of choice Some additional settings have to be done in the "project structure" dialog. Apart from specifying the GWT installation directory, there is a specific project setting which has to be done manually, which is setting the target Web facet to "Web". The project structure for the simple GWT project should look as follows: Figure 2.12. Project structure for simple GWT project After this, you should be able to run the project. Any changes in the source code will be automatically detected, and debugging is possible. Note When creating GWT run configurations, it is recommended to increase the amount of memory given to the process. You can do this by entering a higher -Xmx value in the VM parameters field, for example "-Xmx768m". 13

Using Geomajas in your IDE of choice 3. NetBeans You can both create the project from the archetype or open directly the Maven project in NetBeans. See http://wiki.netbeans.org/mavenbestpractices for more details. 14

Chapter 3. About 1. About this project Geomajas is a free and open source GIS application framework for building rich internet applications. It has sophisticated capabilities for displaying and managing geospatial information. The modular design makes it easily extensible. The stateless client-server architecture guarantees endless scalability. The focus of Geomajas is to provide a platform for server-side integration of geospatial data, allowing multiple users to control and manage the data from within their own browser. In essence, Geomajas provides a set of powerful building blocks, from which the most advanced GIS applications can easily be built. Key features include: Modular architecture Clearly defined API Integrated client-server architecture Built-in security Advanced geometry and attribute editing with validation Custom attribute definitions including object relations Advanced querying capabilities (searching, filters, style,...) See http://www.geomajas.org/. 2. License information Copyright 2009-2010 Geosparc nv. Licensed under the GNU Affero General Public License. You may obtain a copy of the License at http://www.gnu.org/licenses/ This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. See the GNU Affero General Public License for more details. The project also depends on various other open source projects which have their respective licenses. From the Geomajas source (possibly specific module), the dependencies can be displayed using the "mvn dependency:tree" command. For the dependencies of the Geomajas back-end, we only allow dependencies which are freely distributable for commercial purposes (this for example excludes GPL and AGPL licensed dependencies). 3. Author information This framework and documentation was written by the Geomajas Developers. If you have questions, found a bug or have enhancements, please contact us through the user fora at http://www.geomajas.org/. List of contributors for this manual: Pieter De Graef 15

About Jan De Moerloose Joachim Van der Auwera Frank Wynants Frank Maes 16