2

I'm trying to follow the tutorial found in the GeoServer Developer Manual found here. Unfortunately to someone without much GeoServer and without any Maven experience, I'm having a hard time wrapping my head around it and I can't seem to get it working.

The folder structure is as follows:

.
├── pom.xml
└── src
   ├── main
   |  ├── java
   |  |  └── HelloResource.java
   |  └── resources
   |     └── applicationContext.xml
   └── test
      └── java
         └── HelloResourceTest.java

The contents of the files are exactly what is specified in the tutorial in the link above. The tutorial never specified what the java files should be named and I'm not sure if that matters.

At the end of the tutorial, it says to run the following command, so I'm trying to run it from the root (a folder called "hello", I'm not sure if the position of this folder matters but right now it's in the root of the geoserver folder).

mvn install

When I run this, I get the following output in the command line:

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building hello_rest
[INFO]    task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
Downloading: http://repo1.maven.org/maven2/com/mockrunner/mockrunner/0.3.6/mockrunner-0.3.6.pom
[INFO] Unable to find resource 'com.mockrunner:mockrunner:pom:0.3.6' in repository central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

Missing:
----------
1) org.geoserver:gs-rest:jar:2.8-SNAPSHOT

  Try downloading the file manually from the project website.

  Then, install it using the command: 
      mvn install:install-file -DgroupId=org.geoserver -DartifactId=gs-rest -Dversion=2.8-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file there: 
      mvn deploy:deploy-file -DgroupId=org.geoserver -DartifactId=gs-rest -Dversion=2.8-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency: 
    1) org.geoserver:hello_rest:jar:1.0-SNAPSHOT
    2) org.geoserver:gs-rest:jar:2.8-SNAPSHOT

----------
1 required artifact is missing.

for artifact: 
  org.geoserver:hello_rest:jar:1.0-SNAPSHOT

from the specified remote repositories:
  central (http://repo1.maven.org/maven2)



[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Wed Aug 31 17:05:56 UTC 2016
[INFO] Final Memory: 9M/240M
[INFO] ------------------------------------------------------------------------

GeoServer is running on an Amazon Web Server instance running Ubuntu, and it is GeoServer version 2.8.2. I didn't set it up so I don't know all the details (though I can find out anything that needs to be known) but GeoServer is installed through Tomcat and is in the tomcat7 folder.

Does anyone have any insight on how I can get this working?

EDIT: Here's my pom file:

<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/maven-v4_0_0.xsd ">
  <modelVersion>4.0.0</modelVersion>

  <groupId>org.geoserver</groupId>
  <artifactId>hello_rest</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>hello_rest</name>

  <dependencies>
    <dependency>
      <groupId>org.geoserver</groupId>
      <artifactId>gs-rest</artifactId>
      <version>2.8-SNAPSHOT</version> <!-- change this to the proper GeoServer version -->
    </dependency>
    <dependency>
      <groupId>org.geoserver</groupId>
      <artifactId>gs-main</artifactId>
      <version>2.8-SNAPSHOT</version> <!-- change this to the proper GeoServer version -->
      <classifier>tests</classifier>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.mockrunner</groupId>
      <artifactId>mockrunner</artifactId>
      <version>0.3.6</version>
     <scope>test</scope>
    </dependency>

  </dependencies>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
     </plugin>
   </plugins>
  </build>

</project>
  • Please add the repository section of your pom file – Ian Turton Aug 31 '16 at 18:50
  • I added the pom file. – NinjaMeTimbers Aug 31 '16 at 19:14
1

You haven't told Maven where it can find the GeoTools and GeoServer snapshot jars. You need to add a repositories section to your pom file:

<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>
    <repository>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <id>boundless</id>
      <name>Boundless Maven Repository</name>
      <url>http://repo.boundlessgeo.com/main</url>
    </repository>
</repositories>

In general the GeoTools & GeoServer tutorials assume that you have worked through (at least) the quickstart tutorial.

Note: Pull requests improving the documentation are always appreciated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.