Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [geomesa-users] Using the Java API - NoClassDefFoundError

Hello, I am having one further difficulty.  I can perform successful "query-all" operations, but I am getting an exception when trying to apply the filter shown in GeoMesa's tutorial documentation.  I am trying to apply a bounding box filter, and my default geometry is an SRID 4326 Point.  I am using the Java API.

I've attached sample.txt to demonstrate a sample query function.  With the code commented out like as shown, the function works properly, performing a query-all.  However uncommenting the code causes the error in exception.txt.

Is there any additional functionality I need to include to set up my filtered query properly?

Thank you,
Connor



On Fri, May 23, 2014 at 12:59 PM, Chris Eichelberger <cne1x@xxxxxxxx> wrote:
Connor,

We have reworked the code so that it can use native SimpleFeatures
without any GeoMesa constants.  The default geometry, for example, will
now always be used as the index geometry.

With the date-time fields, there's one additional step:  We use the user
data within the feature-type to specify which date-time field should be
indexed.

Here's an example snippet of code that should give you a flavor of what
creating a new feature type now looks like:

  // assume that "dataStore" points to an Accumulo table
  // that does not yet exist

  // simple type that contains a default geometry and at
  // least one date-time field, all using YOUR field names
  String featureName = "example_type";
  String featureTypeString =
"who:String,what:Integer,*where:Point,when:Date";
  SimpleFeatureType featureType = DataUtilities.createType(featureName,
featureTypeString);

  // specify which date-time field should be indexed
  featureType.getUserData().put(index.SF_PROPERTY_START_TIME, "when");

  // create the table and type
  dataStore.createSchema(featureType);

This code should be a bit easier to read than the old version was.
Using this example feature-type, you could initialize a feature by just
calling

  newFeature.setAttribute("who", "Andrei Codrescu");
  newFeature.setAttribute("what", new Integer(1));
  newFeature.setAttribute("when", new Date());
  newFeature.setAttribute("where", somePointValue);

This has the advantage of using all of your field names.

NB:  For this to work well, you will want to start your ingest all over
again.  That is, delete the existing table, so that the new feature type
gets created as you want.

If this doesn't address your current issue, please let us know.

Thanks!

Sincerely,
  -- Chris


On Fri, 2014-05-23 at 11:51 -0500, Connor Manning wrote:
> Worked great!  I think all the dependencies are resolved properly now
> - thank you for your help.
>
>
> I am having a problem getting results from querying after writing a
> feature, following the documentation.  I wanted to ask if there's a
> new method for IndexEntryType.getTypeSpec(), which is appended to the
> featureSchema in the documentation.  This does not appear to exist in
> GeoMesa anymore, so perhaps this is why my query-all is not
> successful.
>
>
> I've also noticed that these lines:
>
>
> newFeature.setAttribute(Constants.SF_PROPERTY_START_TIME, new Date());
> newFeature.setAttribute(Constants.SF_PROPERTY_END_TIME, new Date());
>
>
> Cause the following exception:
> org.geotools.feature.IllegalAttributeException:Unknown attribute
> geomesa_index_start_time:null value:null
>
>
> So I have removed those lines in my test code.  So the IndexEntryType
> and the Start/End time lines are the only difference between my test
> code and the documentation.  Is there a new way to do either of
> these?  My write seems to be successful, but my queryAll of the
> FeatureSource returns an empty FeatureCollection.  Looking in the
> debugger, it does not appear the the write actually wrote anything to
> the DataStore.  Could this be caused by omitting the above mentioned
> lines?  Sample code attached in case that is useful.
>
> Thanks once again, this assistance is very much appreciated.
>
> Connor
>
>
>
>
> On Fri, May 23, 2014 at 10:27 AM, Chris Eichelberger <cne1x@xxxxxxxx>
> wrote:
>         Connor,
>
>         That error has do to with one of the GeoTools JAR files -- I
>         believe
>         it's gt-epsg-hsql-{version}.jar -- not being on the
>         classpath.  This is
>         marked as a "provided" dependency for GeoMesa, like the
>         Accumulo and
>         Zookeeper JARs.
>
>         Please let us know if adding that to your classpath doesn't
>         help.
>
>         Thanks!
>
>         Sincerely,
>           -- Chris
>
>         _______________
>
>         Chris Eichelberger,
>         Commonwealth Computer Research, Inc.
>         434-284-9422 (work)
>
>
>
>
>         >
>         > _______________________________________________
>         > geomesa-users mailing list
>         > geomesa-users@xxxxxxxxxxxxxxxx
>         > http://www.locationtech.org/mailman/listinfo/geomesa-users
>
>         _______________________________________________
>         geomesa-users mailing list
>         geomesa-users@xxxxxxxxxxxxxxxx
>         http://www.locationtech.org/mailman/listinfo/geomesa-users
>
>
>
> _______________________________________________
> geomesa-users mailing list
> geomesa-users@xxxxxxxxxxxxxxxx
> http://www.locationtech.org/mailman/listinfo/geomesa-users

_______________________________________________
geomesa-users mailing list
geomesa-users@xxxxxxxxxxxxxxxx
http://www.locationtech.org/mailman/listinfo/geomesa-users

    public FeatureIterator<SimpleFeature> query(
    		DataStore dataStore,
    		String featureName) throws IOException
    {
    	FeatureSource<SimpleFeatureType, SimpleFeature> featureSource =
    			dataStore.getFeatureSource(featureName);

    	/*
		String bbox = "BBOX(" + Constants.SF_PROPERTY_GEOMETRY + ", 45, 45, 55, 55)";
		
		Filter cqlFilter = null;
		
		try
		{
			cqlFilter = ECQL.toFilter(bbox);
		} 
		catch (CQLException e) 
		{
			e.printStackTrace();
		}
	
		Query query = new Query(featureName, cqlFilter);
    	*/
    	
    	// Perform a query and return the iterator.
    	FeatureCollection<SimpleFeatureType, SimpleFeature> featureCollection =
    			featureSource.getFeatures(/*query*/);
    	
    	return featureCollection.features();
    }
java.lang.NullPointerException
	at geomesa.core.data.FilterToAccumulo.visitBBOX(FilterToAccumulo.scala:88)
	at geomesa.core.data.FilterToAccumulo.process(FilterToAccumulo.scala:69)
	at geomesa.core.data.FilterToAccumulo.visit(FilterToAccumulo.scala:58)
	at geomesa.core.data.FilterToAccumulo.visit(FilterToAccumulo.scala:56)
	at geomesa.core.index.IndexQueryPlanner.getIterator(IndexQueryPlanner.scala:82)
	at geomesa.core.index.IndexSchema.query(IndexSchema.scala:95)
	at geomesa.core.data.AccumuloFeatureReader.<init>(AccumuloFeatureReader.scala:32)
	at geomesa.core.data.AccumuloDataStore.getFeatureReader(AccumuloDataStore.scala:282)
	at geomesa.core.data.AccumuloDataStore.getFeatureReader(AccumuloDataStore.scala:54)
	at org.geotools.data.AbstractDataStore.getFeatureReader(AbstractDataStore.java:369)
	at org.geotools.data.DefaultFeatureResults.reader(DefaultFeatureResults.java:215)
	at org.geotools.data.store.DataFeatureCollection.openIterator(DataFeatureCollection.java:231)
	at org.geotools.data.store.DataFeatureCollection.iterator(DataFeatureCollection.java:199)
	at org.geotools.data.store.DataFeatureCollection.features(DataFeatureCollection.java:188)
	at org.geotools.data.store.DataFeatureCollection.features(DataFeatureCollection.java:79)
	at geoProxy.GeoProxyMain.queryTest(GeoProxyMain.java:203)
	at geoProxy.GeoProxyMain.testLocalFunctionality(GeoProxyMain.java:69)
	at geoProxy.GeoProxyMain.main(GeoProxyMain.java:40)

Back to the top