[postgis-users] error when try to getFeatureSource
Qian C.Y.
cyqian at gmail.com
Tue Mar 20 19:41:11 PDT 2007
I can connect to postgresql database, but when I try to getFeatureSource().
Would you please help me??
2007-3-21 10:39:17 FactoryRegistry scanForPlugins
警告: Can't load a service for category "CRSAuthorityFactory". Cause is
"NoClassDefFoundError: javax/units/ConversionException".
2007-3-21 10:39:17 FactoryRegistry scanForPlugins
警告: Can't load a service for category "CRSAuthorityFactory". Cause is
"NoClassDefFoundError: javax/units/ConversionException".
2007-3-21 10:39:17 FactoryRegistry scanForPlugins
警告: Can't load a service for category "CRSAuthorityFactory". Cause is
"NoClassDefFoundError: javax/units/ConversionException".
Exception in thread "main" java.lang.StackOverflowError
at java.util.HashSet.iterator(HashSet.java:154)
at javax.imageio.spi.DigraphNode.getOutNodes(DigraphNode.java:59)
at javax.imageio.spi.PartialOrderIterator.next(
PartiallyOrderedSet.java:179)
at javax.imageio.spi.FilterIterator.advance(ServiceRegistry.java
:792)
at javax.imageio.spi.FilterIterator.<init>(ServiceRegistry.java:787)
at javax.imageio.spi.ServiceRegistry.getServiceProviders(
ServiceRegistry.java:491)
at org.geotools.factory.FactoryRegistry.getServiceProviders(
FactoryRegistry.java:167)
at org.geotools.factory.FactoryRegistry.getServiceProviders(
FactoryRegistry.java:117)
at org.geotools.factory.FactoryRegistry.getServiceProvider(
FactoryRegistry.java:275)
at org.geotools.factory.FactoryRegistry.getServiceProvider(
FactoryRegistry.java:254)
at org.geotools.factory.FactoryCreator.getServiceProvider(
FactoryCreator.java:115)
at org.geotools.referencing.FactoryFinder.getAuthorityFactory(
FactoryFinder.java:235)
at org.geotools.referencing.FactoryFinder.getCRSAuthorityFactory(
FactoryFinder.java:496)
at
org.geotools.referencing.factory.epsg.LongitudeFirstFactory.createBackingStore
(LongitudeFirstFactory.java:180)
at
org.geotools.referencing.factory.DeferredAuthorityFactory.getBackingStore(
DeferredAuthorityFactory.java:136)
at
org.geotools.referencing.factory.BufferedAuthorityFactory.isAvailable(
BufferedAuthorityFactory.java:206)
at
org.geotools.referencing.factory.DeferredAuthorityFactory.isAvailable(
DeferredAuthorityFactory.java:124)
at org.geotools.factory.FactoryRegistry$DefaultFilter.filter(
FactoryRegistry.java:76)
at javax.imageio.spi.FilterIterator.advance(ServiceRegistry.java
:793)
at javax.imageio.spi.FilterIterator.<init>(ServiceRegistry.java:787)
at javax.imageio.spi.ServiceRegistry.getServiceProviders(
ServiceRegistry.java:491)
at org.geotools.factory.FactoryRegistry.getServiceProviders(
FactoryRegistry.java:167)
at ......
....................................
....................................
and the code:
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.geotools.data.DataStore;
import org.geotools.data.DataStoreFinder;
import org.geotools.data.FeatureSource;
import org.geotools.data.postgis.PostgisDataStore;
import org.geotools.data.postgis.PostgisDataStoreFactory;
public class Postgis {
@SuppressWarnings("unchecked")
/** Creates a new instance of Postgis */
public Postgis(String host,int port,String database,String user,String
password) {
params= new HashMap();
params.put("dbtype","postgis");
params.put("host",host);
params.put("port",new Integer(port));
params.put("database",database);
params.put("user",user);
params.put("passwd",password);
}
public void connect(){
try {
//pgDataStore=(PostgisDataStore)factory.createDataStore(params);
pgDataStore=DataStoreFinder.getDataStore(params);
................
}
public void getFS(String featureName){
try {
FeatureSource fsBC=pgDataStore.getFeatureSource(featureName);
} catch (IOException ex) {
ex.printStackTrace();
.........
}
}
public static void main(String[] args) throws IOException {
Postgis pg=new Postgis("localhost",5432,"mapdb","user","passwd");
pg.connect();
pg.getFS("roads");
}
private Map params;
private DataStore pgDataStore;
//private PostgisDataStoreFactory factory=new PostgisDataStoreFactory();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20070321/4b0bffcd/attachment.html>
More information about the postgis-users
mailing list