Question

I'm using Maven for the first time. I am trying to build "GeoTools" (http://www.geotools.org/) which has a seemingly well documented "Getting Started" page. I am using NetBeans 7.3.1. When I build my project, I get a "Build Failure" :

Failed to execute goal on project tutorial: Could not resolve dependencies for project org.geotools:tutorial:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: org.geotools:gt-shapefile:jar:10-SNAPSHOT, org.geotools:gt-swing:jar:10-SNAPSHOT: Failure to find org.geotools:gt-shapefile:jar:10-SNAPSHOT in http://download.java.net/maven/2 was cached in the local repository, resolution will not be reattempted until the update interval of maven2-repository.dev.java.net has elapsed or updates are forced -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

I'm not really sure what that means. In my code I have several imports that are considered to not exist, though I followed the pom.xml instructions to the letter. For example:

import org.geotools.data.FileDataStore;

The above has a read underline with error saying:

package org.geotools.data does not exist

Here is my XML.

<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.geotools</groupId>
<artifactId>tutorial</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>tutorial</name>
<url>http://maven.apache.org</url>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <geotools.version>10-SNAPSHOT</geotools.version>
</properties>
<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-shapefile</artifactId>
        <version>${geotools.version}</version>
    </dependency>
    <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-swing</artifactId>
        <version>${geotools.version}</version>
    </dependency>
</dependencies>
<repositories>
    <repository>
        <id>maven2-repository.dev.java.net</id>
        <name>Java.net repository</name>
        <url>http://download.java.net/maven/2</url>
    </repository>
    <repository>
        <id>osgeo</id>
        <name>Open Source Geospatial Foundation Repository</name>
        <url>http://download.osgeo.org/webdav/geotools/</url>
    </repository>
</repositories>

Can anyone give me some advice to get this tool running? Am I making a fundamental Maven error or could it be tool-specific? The JARs show up under "Dependencies" so I don't understand why there's a problem.

Thanks in advance.

Was it helpful?

Solution

The real answer is that the GeoTools tutorial is pernicious. So if any future stragglers come here know this: on the NetBeans tutorial (and perhaps the Eclipse tutorial which I also failed to get to work) there are steps which define how to set up the pom.xml. Follow them. However, do NOT copy and paste their full pom.xml file, there's an error in it somewhere. I merely added the dependencies and repositories and built the project - successfully.

But wait there's more. After building the project I was unable to run the Quickstart.java example they provide. It crashed because

JMapFrame.showMap(map)

only accepts a "MapContext" type, which the documentation calls "deprecated". So, I imported

org.geotools.map.MapContext

and changed

MapContent map = new MapContent();

to

MapContext map = new MapContext();

Viola, beating the system. I wish developers would actually test their tutorials!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top