0

I have been trying to insert into a Cassandra table using the GeoMesa api inside of a simple test class. Ultimately, I will need to insert point data into a Cassandra table that has a composite key from a Spark streaming job, but for simply proving it out, I am just trying to use the online GeoMesa api code that uses CassandraDataStore inside a simple app class. The problem is, I continue to have a compilation error due to a LazyLogging class from the typesafe logging library that several of the GeoMesa classes are using. Excluding the dependency in Gradle does not have any effect. Is there some way around this? The code and exception follows.

Code:

import java.util

object Application extends Serializable {

def main(args: Array[String]): Unit = {

val parameters = new util.HashMap[String, String]
parameters.put("geomesa.cassandra.contact.point", "localhost:9042")
parameters.put("geomesa.cassandra.keyspace", "tgeomesa")
parameters.put("geomesa.cassandra.catalog.table", "tstwrite")

val dataStore:org.geotools.data.DataStore =
  org.geotools.data.DataStoreFinder.getDataStore(parameters)

println("Completed")
}

}

// GeoMesa
compile group: 'org.locationtech.geomesa', name: 'geomesa-cassandra-datastore_2.11', version: '1.3.4'
compile group: 'org.geotools', name: 'gt-main', version: '15.1'

Exception in thread "main" java.lang.InstantiationError: com.typesafe.scalalogging.Logger
at com.typesafe.scalalogging.Logger$.apply(Logger.scala:31)
at com.typesafe.scalalogging.LazyLogging$class.logger(Logging.scala:28)
at org.locationtech.geomesa.utils.conf.ConfigLoader$.logger$lzycompute(ConfigLoader.scala:19)
at org.locationtech.geomesa.utils.conf.ConfigLoader$.logger(ConfigLoader.scala:19)
at org.locationtech.geomesa.utils.conf.ConfigLoader$.loadConfig(ConfigLoader.scala:38)
at org.locationtech.geomesa.utils.conf.ConfigLoader$.Config$lzycompute(ConfigLoader.scala:28)
at org.locationtech.geomesa.utils.conf.ConfigLoader$.Config(ConfigLoader.scala:25)
at org.locationtech.geomesa.utils.conf.GeoMesaSystemProperties$SystemProperty$$anonfun$get$1.apply(GeoMesaSystemProperties.scala:23)
at org.locationtech.geomesa.utils.conf.GeoMesaSystemProperties$SystemProperty$$anonfun$get$1.apply(GeoMesaSystemProperties.scala:23)
at scala.Option.getOrElse(Option.scala:121)
at org.locationtech.geomesa.utils.conf.GeoMesaSystemProperties$SystemProperty.get(GeoMesaSystemProperties.scala:22)
at org.locationtech.geomesa.utils.conf.GeoMesaSystemProperties$.getProperty(GeoMesaSystemProperties.scala:42)
at org.locationtech.geomesa.utils.conf.GeoMesaSystemProperties.getProperty(GeoMesaSystemProperties.scala)
at org.locationtech.geomesa.utils.audit.AuditProvider$Loader.load(AuditProvider.java:58)
at org.locationtech.geomesa.cassandra.data.CassandraDataStoreFactory.createDataStore(CassandraDataStoreFactory.scala:39)
at org.locationtech.geomesa.cassandra.data.CassandraDataStoreFactory.createDataStore(CassandraDataStoreFactory.scala:25)
at org.geotools.data.DataAccessFinder.getDataStore(DataAccessFinder.java:130)
at org.geotools.data.DataStoreFinder.getDataStore(DataStoreFinder.java:89)
at asrc.ml.clustering.Application$.main(Application.scala:15)
at asrc.ml.clustering.Application.main(Application.scala)

Scala: 2.11.8 GeoMesa: 1.3.4 Cassandra: 3.0.15

Thank you.

  • I haven't tried using gradle for scala projects before - it appears that there is some kind of dependency problem. If you'd like to try out geomesa, have you considered the cassandra [quick start](http://www.geomesa.org/documentation/tutorials/geomesa-quickstart-cassandra.html)? It uses maven to build. – Emilio Lahr-Vivaz Jan 31 '18 at 17:03
  • Ok thank you very much for confirming this, as I won't waste any more time debugging it. Would be nice if this was working with Scala though, as the next step not only for me but for others I would say is to integrate with Spark.. I will try the geomesa quick start with Maven/Java and report back – user1930364 Jan 31 '18 at 20:56
  • GeoMesa is written in scala, and does work with scala through maven or sbt. I just don't think anyone has tried to use gradle before. The tutorials are all written in java in order to be more accessible, but you can look at [unit tests](https://github.com/locationtech/geomesa/blob/master/geomesa-cassandra/geomesa-cassandra-datastore/src/test/scala/org/locationtech/geomesa/cassandra/data/CassandraDataStoreTest.scala) for scala examples. – Emilio Lahr-Vivaz Jan 31 '18 at 21:58
  • Right - apologies. I realized you meant the issue was Gradle after I posted. – user1930364 Jan 31 '18 at 22:27
  • I was able to run the geomesa-cassandra-quickstart, and it did indeed create the tables. However two things that I will mention - you must also add the five jar files that the install-cassandra-script.sh script pulls down, otherwise there are a bunch of ncf errors. Second, I took it a step further and was able to create a data store in Geoserver, however, there is now a conflict with the data format that the tutorial produces. I believe the tutorial is currently 1.4.0.0-SNAPSHOT. So there is an exception when I go to publish in GeoServer: – user1930364 Jan 31 '18 at 22:32
  • Caused by: java.lang.IllegalStateException: The schema CassandraQuickStart was written with a newer version of GeoMesa than this client can handle. Please ensure that you are using the same GeoMesa jar versions across your entire workflow. – user1930364 Jan 31 '18 at 22:34
  • This may be a topic for a new post, but obviously if I go through the effort to create a class for my needs in writing with geomesa, I want to make sure Geoserver can read it. My Geoserver version is 2.12.1. Is there still geomesa 1.3.4 quickstart code available online that will write the format that matches my geomesa plugin version? My plugin version for Geoserver is geomesa-cassandra-gs-plugin_2.11-1.3.4-install.tar.gz. Thanks – user1930364 Jan 31 '18 at 22:36
  • Ok I changed the version number in the parent and child poms to 1.3.4 and everything worked. Thanks so much for helping me move forward! – user1930364 Jan 31 '18 at 23:13
  • good to hear - each quickstart should have a git tag that corresponds with each geomesa release. e.g. for 1.3.4 it's https://github.com/geomesa/geomesa-tutorials/tree/geomesa-tutorials-1.3.4.0 – Emilio Lahr-Vivaz Feb 01 '18 at 13:40
  • Thanks for pointing out the missing Cassandra runtime dependencies in the tutorial! I've opened a ticket to fix that. – Emilio Lahr-Vivaz Feb 05 '18 at 19:26

0 Answers0