I don't tink you have the units jar - it is one of the jars that you
pick up with either
a) use of maven
b) downloading geotools
Cheers,
Jody
> I use gt2 to connect postgresql+postgis. I can connect to the
> 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();
>
> }
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> ------------------------------------------------------------------------
>
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users