1

I'm working on a Web Map Service written in Java and using the GeoTools library. My goal is to make the data parsing json format, so I'm using the form Unsupported GeoTools. This is the parsingJSON method that takes in the path of the input file and returns as output the FeatureCollection of the files feature:

public FeatureCollection parsingJSON(String path) throws FileNotFoundException, IOException, ParseException {
        System.out.println("INTO PARSINGJSON");
        JSONParser parser = new JSONParser();

        File f = new File(path); 
        System.out.println("complete path file --->" + f.getAbsolutePath());

        Object obj = parser.parse(new java.io.FileReader(path));
        FeatureJSON fJSON = new FeatureJSON();
        FeatureCollection fc = fJSON.readFeatureCollection(obj.toString());
        return fc;
    }

When I run the code by passing the path of the file, gives me this exception:

mag 02, 2016 4:09:42 PM org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: Servlet.service() for servlet ServletWMS threw exception
java.lang.ClassNotFoundException: org.json.simple.parser.ParseException
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
    at com.lamiaservlet.servlets.ServletWMS.operation(ServletWMS.java:140)
    at com.lamiaservlet.servlets.ServletWMS.doGet(ServletWMS.java:51)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:612)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:503)
    at java.lang.Thread.run(Unknown Source)

I want to clarify that I imported the library properly json-simple-1.1 and I have the following pom.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>Servlet</groupId>
  <artifactId>Servlet</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <geotools.version>13.2</geotools.version>
  </properties>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <resources>
      <resource>
        <directory>src</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.4</version>
        <configuration>
          <warSourceDirectory>WebContent</warSourceDirectory>
          <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-main</artifactId>
            <version>${project.version}</version>
        </dependency>
        <!--   Third-party dependencies   -->
        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1</version>
        </dependency>

        <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-epsg-hsql</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>commons-lang</groupId>
          <artifactId>commons-lang</artifactId>
        </dependency>
        <dependency>
             <groupId>org.geotools</groupId>
            <artifactId>gt-geojson</artifactId>
             <version>${geotools.version}</version>
        </dependency>
    </dependencies>
  </dependencyManagement>
</project>

closed as off-topic by Ian Turton May 6 '16 at 10:47

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions relating to general Information Technology, with no clear GIS component, are off-topic here, but can be researched/asked at Stack Overflow (software development), Super User (computing hardware and software) and Database Administrators (relational databases)" – Ian Turton
If this question can be reworded to fit the rules in the help center, please edit the question.

  • What is the error? – Ian Turton Apr 24 '16 at 14:27
  • I edited the question. The error is already present when I try to create, through the MarshallerTest class, Capabilities Document. The createLayer methods allow you to add the layers to the document – maxada Apr 24 '16 at 16:51
  • 1
    Please edit again to focus the question on the piece that is failing, with the minimum of code to manifest the issue – Vince Apr 24 '16 at 20:59
  • your pom has no dependencies - see gist.github.com/ianturton/86c57ca1beea54b43ca8a3fc7467f9e2 for a fuller example pom.xml – Ian Turton Apr 25 '16 at 16:01
  • I modified the pom.xml file by entering the dependency, but there is the problem on " DataStore dataStore = DataStoreFinder.getDataStore(params);" – maxada Apr 26 '16 at 17:07
0

Your error has nothing to do with JSON, there is a problem with the PostGIS datastore jar on your path. The most likely cause of this issue is that you have combined jars from different GeoTools releases. Check your pom.xml file - the usual practice is to use a property geotools.version set to the version you plan to use:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <geotools.version>15-SNAPSHOT</geotools.version>
  </properties>

and then in dependencies use that property to set the version:

<dependencies>
    <dependency>
      <groupId>org.geotools</groupId>
      <artifactId>gt-main</artifactId>
      <version>${geotools.version}</version>
    </dependency>
    <dependency>
      <groupId>org.geotools</groupId>
      <artifactId>gt-render</artifactId>
      <version>${geotools.version}</version>
    </dependency>
  • I modified the pom.xml file by entering the dependency and properties. The problems persist! – maxada Apr 25 '16 at 14:58
  • Making this change, now nothing works any more! – maxada Apr 25 '16 at 15:03

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