From: <Joh...@no...> - 2008-07-21 20:24:25
|
Helllo All, I have a very simple shapefile reading class based on the example (http://docs.codehaus.org/display/GEOTDOC/04+How+to+Read+a+Shapefile). Everything works OK when executing w/ "mvn exec:java". However, when I bundle everything up into a executable jar using "mvn assembly:assembly", I get a RuntimeException trying to use the generated jar file. I can't understand why there's a problem locating a function "length" nor really why it's being called. Any suggestions? Thanks! --john java -jar ./target/shapefile-reader-jar-with-dependencies.jar ~/shapefiles/country.shp java.lang.RuntimeException: Unable to find function Length at org.geotools.filter.FunctionFinder.findFunction(FunctionFinder.java:83) at org.geotools.filter.FilterFactoryImpl.function(FilterFactoryImpl.java:423) at org.geotools.feature.DefaultAttributeTypeFactory.createAttributeType(DefaultAttributeTypeFactory.java:158) at org.geotools.feature.AttributeTypeFactory.newAttributeType(AttributeTypeFactory.java:92) at org.geotools.data.shapefile.ShapefileDataStore.readAttributes(ShapefileDataStore.java:703) at org.geotools.data.shapefile.indexed.IndexedShapefileDataStore.getSchema(IndexedShapefileDataStore.java:898) at org.geotools.data.shapefile.indexed.IndexedShapefileDataStore.getSchema(IndexedShapefileDataStore.java:892) at org.geotools.data.shapefile.indexed.IndexedShapefileDataStore.getFeatureSource(IndexedShapefileDataStore.java:1002) at gov.noaa.eds.App.main(App.java:49) |
From: Jody G. <jga...@re...> - 2008-07-21 20:40:30
|
I can help with that one ... we make use of Factory Service Provider Interface (ie Factory SPI) which makes use of META_INF/services/* (a folder in your jar that advertises all the services the jar offers - including the length function). So when you do mvn assembly - you will need to make sure the META_INF/services files are all merged up (no I don't know how to do this). The length function is being called when you make an attribute type; the shapefile header has a limitation that strings can only be 256 characters long; we represent that as a restriction - the restriction that "length( . ) < 256". Cheers, Jody Joh...@no... wrote: > Helllo All, > > I have a very simple shapefile reading class based on the example > (http://docs.codehaus.org/display/GEOTDOC/04+How+to+Read+a+Shapefile). > > Everything works OK when executing w/ "mvn exec:java". However, when I > bundle everything up into a executable jar using "mvn > assembly:assembly", I get a RuntimeException trying to use the generated > jar file. I can't understand why there's a problem locating a function > "length" nor really why it's being called. Any suggestions? > > Thanks! > --john > > > java -jar ./target/shapefile-reader-jar-with-dependencies.jar > ~/shapefiles/country.shp > > java.lang.RuntimeException: Unable to find function Length > at > org.geotools.filter.FunctionFinder.findFunction(FunctionFinder.java:83) > at > org.geotools.filter.FilterFactoryImpl.function(FilterFactoryImpl.java:423) > at > org.geotools.feature.DefaultAttributeTypeFactory.createAttributeType(DefaultAttributeTypeFactory.java:158) > at > org.geotools.feature.AttributeTypeFactory.newAttributeType(AttributeTypeFactory.java:92) > at > org.geotools.data.shapefile.ShapefileDataStore.readAttributes(ShapefileDataStore.java:703) > at > org.geotools.data.shapefile.indexed.IndexedShapefileDataStore.getSchema(IndexedShapefileDataStore.java:898) > at > org.geotools.data.shapefile.indexed.IndexedShapefileDataStore.getSchema(IndexedShapefileDataStore.java:892) > at > org.geotools.data.shapefile.indexed.IndexedShapefileDataStore.getFeatureSource(IndexedShapefileDataStore.java:1002) > at gov.noaa.eds.App.main(App.java:49) > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Geotools-gt2-users mailing list > Geo...@li... > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > |
From: TundraGreen <wi...@th...> - 2008-10-15 18:19:36
|
I have exactly the same problem that John had from the same source, implementing the "How to read a shapefile example". I have read Jody's response and tried to implement it. I don't have any problem including something in the META-INF/servies folder in the jar. I know how to do that. But I haven't been able to figure out what to include. I tried following the directions in the API for implementing a DataStoreFactorySpi. These suggest the following: [Begin quote from API] Implementation Notes An instance of this interface should exist for all data stores which want to take advantage of the dynamic plug-in system. In addition to implementing this factory interface each DataStore implementation should have a services file: META-INF/services/org.geotools.data.DataStoreFactorySpi The file should contain a single line which gives the full name of the implementing class. example: e.g. org.geotools.data.mytype.MyTypeDataSourceFacotry The factories are never called directly by client code, instead the DataStoreFinder class is used. [/End quote from API] I don't know if this is what Jody was referring to, but in any event I haven't been able to find anything that works. Can anyone provide more detail about what is required to get org.geotools.filter.FunctionFinder.findFunction(FunctionFinder.java:xx) to be able to find the Length function. Will Jody Garnett wrote: > > I can help with that one ... we make use of Factory Service Provider > Interface (ie Factory SPI) which makes use of META_INF/services/* (a > folder in your jar that advertises all the services the jar offers - > including the length function). > > So when you do mvn assembly - you will need to make sure the > META_INF/services files are all merged up (no I don't know how to do > this). > > Jody > > >> >> >> java -jar ./target/shapefile-reader-jar-with-dependencies.jar >> ~/shapefiles/country.shp >> >> java.lang.RuntimeException: Unable to find function Length >> at >> org.geotools.filter.FunctionFinder.findFunction(FunctionFinder.java:83) >> at > > -- View this message in context: http://www.nabble.com/RuntimeException%3A-Unable-to-find-function-Length-tp18576842p19998467.html Sent from the geotools-gt2-users mailing list archive at Nabble.com. |