0

I am executing accumulo client in java using Geomesa Native API. Following is java client code:

package org.locationtech.geomesa.api;
import java.time.ZonedDateTime;
import java.util.*;
import org.geotools.geometry.jts.JTSFactoryFinder;

import com.google.gson.Gson;

import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.GeometryFactory;
public class GeomesaAccumuloClient {
    public static void main(String args[]){
        System.out.println("hello1");
        try {
            GeoMesaIndex<DomainObject> index =
                AccumuloGeoMesaIndex.build(
                        "asd",
                        "localhost:2181",
                        "hps",
                        "root", "9869547580",
                        false,
                        new DomainObjectValueSerializer(),
                        new DefaultSimpleFeatureView<DomainObject>("aj_p"));
        }
        catch(Throwable t) {
            System.err.println("Uncaught exception is detected! " + t
                    + " st: "+ Arrays.toString(t.getStackTrace()));
        }
    }
    public static class DomainObject {
        public final String id;
        public final int intValue;
        public final double doubleValue;

        public DomainObject(String id, int intValue, double doubleValue) {
            this.id = id;
            this.intValue = intValue;
            this.doubleValue = doubleValue;
        }
    }
    public static class DomainObjectValueSerializer implements ValueSerializer<DomainObject> {
        public static final Gson gson = new Gson();
        @Override
        public byte[] toBytes(DomainObject o) {
            System.out.println(gson.toJson(o).toString());
            return gson.toJson(o).getBytes();
        }

        @Override
        public DomainObject fromBytes(byte[] bytes) {
            return gson.fromJson(new String(bytes), DomainObject.class);
        }
    }
    private static Date date(String s) {
        return Date.from(ZonedDateTime.parse(s).toInstant());
    }
}

But when i execute this file using command

accumulo org.locationtech.geomesa.api.GeomesaAccumuloClient

I am getting following exception:

suresh@hpss-MacBook-Air:~/accumulo-1.8.0/lib/ext $ accumulo org.locationtech.geomesa.api.GeomesaAccumuloClient
hello1
2017-03-13 00:35:26,433 [imps.CuratorFrameworkImpl] INFO : Starting
2017-03-13 00:35:26,445 [state.ConnectionStateManager] INFO : State change: CONNECTED
Uncaught exception is detected! java.lang.IllegalArgumentException: Trying to create a schema with a partial (join) attribute index on the default date field 'dtg'. This may cause whole-world queries with time bounds to be much slower. If this is intentional, you may override this message by putting Boolean.TRUE into the SimpleFeatureType user data under the key 'override.index.dtg.join' before calling createSchema. Otherwise, please either specify a full attribute index or remove it entirely. st: [org.locationtech.geomesa.utils.index.TemporalIndexCheck$$anonfun$validateDtgIndex$1.apply(GeoMesaSchemaValidator.scala:102), org.locationtech.geomesa.utils.index.TemporalIndexCheck$$anonfun$validateDtgIndex$1.apply(GeoMesaSchemaValidator.scala:98), scala.Option.foreach(Option.scala:257), org.locationtech.geomesa.utils.index.TemporalIndexCheck$.validateDtgIndex(GeoMesaSchemaValidator.scala:98), org.locationtech.geomesa.utils.index.GeoMesaSchemaValidator$.validate(GeoMesaSchemaValidator.scala:30), org.locationtech.geomesa.index.geotools.GeoMesaDataStore.createSchema(GeoMesaDataStore.scala:141), org.locationtech.geomesa.accumulo.data.AccumuloDataStore.createSchema(AccumuloDataStore.scala:129), org.locationtech.geomesa.api.AccumuloGeoMesaIndex.<init>(AccumuloGeoMesaIndex.scala:45), org.locationtech.geomesa.api.AccumuloGeoMesaIndex$.buildWithView(AccumuloGeoMesaIndex.scala:165), org.locationtech.geomesa.api.AccumuloGeoMesaIndex$.build(AccumuloGeoMesaIndex.scala:146), org.locationtech.geomesa.api.AccumuloGeoMesaIndex.build(AccumuloGeoMesaIndex.scala), org.locationtech.geomesa.api.GeomesaAccumuloClient.main(GeomesaAccumuloClient.java:15), sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method), sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62), sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43), java.lang.reflect.Method.invoke(Method.java:498), org.apache.accumulo.start.Main$2.run(Main.java:157), java.lang.Thread.run(Thread.java:745)]
Suresh Prajapati
  • 3,991
  • 5
  • 26
  • 38
  • what this question has to do with Scala? – pedrofurla Mar 12 '17 at 20:08
  • Which version of GeoMesa are using? From a quick look, it appears there may be a small bug in the SFT definition that the default GeoMesa Native API code uses. – GeoJim Mar 12 '17 at 20:09
  • @GeoMesaJim GeoMesa tools version: 1.3.0 Commit ID: dc5246614da274264319c3c4c0711fe925403af6 Branch: geomesa_2.11-1.3.0 Build date: 2017-01-19T16:24:02-0500 – Suresh Prajapati Mar 12 '17 at 20:13
  • @pedrofurla The geomesa library is build using scala which in turn is using accumulo jar files to interact with accumulo storage in Geomesa native API. so it may possible that code problem resides in scala files used by geomesa – Suresh Prajapati Mar 12 '17 at 20:20
  • The message indicates the problem is with your geomesa schema. I don't know enough about geomesa to help, but it's definitely not related to Accumulo or Scala. The geomesa code is here: https://github.com/locationtech/geomesa/blob/master/geomesa-utils/src/main/scala/org/locationtech/geomesa/utils/index/GeoMesaSchemaValidator.scala#L102 – Christopher Mar 13 '17 at 03:47
  • @Christopher It's strange but my file GeoMesaSchemaValidator.scala in geomesa repository doesn't contains implementation of method `validateDtgIndex` still i am getting that exception :( – Suresh Prajapati Mar 13 '17 at 07:58
  • @SureshPrajapati You're probably using an older version, which I'm guessing they've since refactored. I don't know. I just linked to the master branch. You'd have to follow the stack trace in your code to see where it's coming from. – Christopher Mar 14 '17 at 10:57

1 Answers1

1

I've tested out your code on a copy of GeoMesa 1.3.0 and 1.3.1 and am unable to reproduce your issue directly. However, I think what is happening is you somehow have a mix of old and new jars. In the 1.3.x series

new DefaultSimpleFeatureView<DomainObject>("aj_p")

is not valid as DefaultSimpleFeatureView does not take parameters causing this to fail the compile. Removing "aj_p" and running

accumulo -add ./geomesa-native-api_2.11-1.3.1.jar org.locationtech.geomesa.api.GeomesaAccumuloClient

seemed to work fine and the test table appeared in my Accumulo instance's tables.

I would recommend verifying the jars on your classpath and perhaps re-installing or downloading the GeoMesa jars.

  • Thank you for pointing out the possible cause for the problem. Can you help me how can verify my jars on my classpath and how can correct them? – Suresh Prajapati Mar 13 '17 at 19:25
  • There are a number of ways you could do this. You can have java print out the classpath with code described here https://www.mkyong.com/java/how-to-print-out-the-current-project-classpath/, or you could modify the accumulo script to printout the classpath before running the java command. This may take some discovery to figure out. To correct them, simply replace the jar with ones from the 1.3.x line or ensure those are included on the classpath first. – Austin Heyne Mar 14 '17 at 15:07
  • Resolved!! That was version issue. Tested on version 1.3.0 and working as expected – Suresh Prajapati Mar 16 '17 at 06:05