The only obvious thing I can see is that there is no "create spatial index"
parameter in the PostGIS data store. I'm not sure if that would prevent it
matching. In general I would always use
PostgisNGDataStoreFactory.DBTYPE.key etc rather than raw strings to make
sure they are correct. The only other thing I can suggest is attach a
debugger/breakpoint to
org.geotools.data.DataUtilities.canProcess(Map<String, ?>, Param...) to see
why it is returning false.

Ian

On Sat, 25 Sept 2021 at 01:43, Alessandro Ferrucci <
alessandroferru...@gmail.com> wrote:

> Hello -
>
> I am using GeoTools 22.2.
>
> I am trying to retrieve a PostGIS DataStore utilizing this code:
>
>             Map postGISParams = new HashMap<>();
>             //must be postgis
>             postGISParams.put("dbtype", "postgis");
>             //the name or ip address of the machine running PostGIS
>             postGISParams.put("host", hostname);
>             //the port that PostGIS is running on (generally 5432)
>             postGISParams.put("port", port);
>             //the name of the database to connect to.
>             postGISParams.put("database", database);
>             //the user to connect with
>             postGISParams.put("user", user);
>             //the password of the user.
>             postGISParams.put("passwd", password);
>             //the schema of the database
>             postGISParams.put("schema", schema);
>
>             postGISParams.put("create spatial index", Boolean.TRUE);
>             DataStore dataStore = null;
>             try {
>                 //storage in PostGIS
>                 dataStore = DataStoreFinder.getDataStore(postGISParams);
>             } catch (Exception ex) {
>                 logger.error(ex.getMessage(), ex);
>             }
>             if (dataStore == null) {
>                 logger.error("ERROR: DataStore is null");
>                 Iterator it = DataStoreFinder.getAvailableDataStores();
>                 logger.info("Available data stores");
>                 while (it.hasNext()) {
>                     Object n = it.next();
>                     logger.info(n.getClass().toString());
>                 }
>                 System.exit(-1);
>             }
>
> the dataStore returned is null, no exception is thrown and DataStoreFinder
> returns the following dataStores:
>
> class org.geotools.data.postgis.PostgisNGJNDIDataStoreFactory
> class org.geotools.data.shapefile.ShapefileDirectoryFactory
> class org.geotools.data.shapefile.ShapefileDataStoreFactory
> class org.geotools.data.postgis.PostgisNGDataStoreFactory
>
> I cannot figure out why the PostgisDataStoreFactory is not returning a
> DataStore ( but the available stores include PostgisNGDataStoreFactory).
>
> Here is my dependency tree output from Maven.
>
> Thank you
>
> [INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ TestProject ---
> [INFO] company:TestProject:jar:1.0.0
> [INFO] +- com.lmax:disruptor:jar:3.2.0:compile
> [INFO] +- org.apache.logging.log4j:log4j-api:jar:2.11.2:compile
> [INFO] +- org.apache.logging.log4j:log4j-core:jar:2.11.2:compile
> [INFO] +- org.apache.logging.log4j:log4j-slf4j-impl:jar:2.11.2:compile
> [INFO] |  \- org.slf4j:slf4j-api:jar:1.7.25:compile
> [INFO] +- commons-io:commons-io:jar:2.4:compile
> [INFO] +- org.springframework:spring-beans:jar:5.1.3.RELEASE:compile
> [INFO] |  \- org.springframework:spring-core:jar:5.1.3.RELEASE:compile
> [INFO] |     \- org.springframework:spring-jcl:jar:5.1.3.RELEASE:compile
> [INFO] +- org.springframework:spring-test:jar:5.1.3.RELEASE:test
> [INFO] +- net.minidev:json-smart:jar:2.2:compile
> [INFO] |  \- net.minidev:accessors-smart:jar:1.1:compile
> [INFO] |     \- org.ow2.asm:asm:jar:5.0.3:compile
> [INFO] +- com.google.code.gson:gson:jar:2.3.1:compile
> [INFO] +-
> org.springframework.security:spring-security-core:jar:5.1.2.RELEASE:compile
> [INFO] |  +- org.springframework:spring-aop:jar:5.1.3.RELEASE:compile
> [INFO] |  +- org.springframework:spring-context:jar:5.1.3.RELEASE:compile
> [INFO] |  \-
> org.springframework:spring-expression:jar:5.1.3.RELEASE:compile
> [INFO] +-
> org.springframework.ldap:spring-ldap-core:jar:2.3.2.RELEASE:compile
> [INFO] |  \- org.springframework:spring-tx:jar:4.3.4.RELEASE:compile
> [INFO] +- junit:junit:jar:4.10:test
> [INFO] |  \- org.hamcrest:hamcrest-core:jar:1.1:test
> [INFO] +- javax.mail:mail:jar:1.4:compile
> [INFO] |  \- javax.activation:activation:jar:1.1:compile
> [INFO] +- com.oracle.jdbc:ojdbc8:jar:12.2.0.1:compile
> [INFO] +- org.postgresql:postgresql:jar:42.2.24:compile
> [INFO] |  \- org.checkerframework:checker-qual:jar:3.5.0:runtime
> [INFO] +- com.opencsv:opencsv:jar:3.10:compile
> [INFO] +- joda-time:joda-time:jar:2.8.1:compile
> [INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.8.10:compile
> [INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.10:compile
> [INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.3:compile
> [INFO] +-
> com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.6.0:compile
> [INFO] +- org.apache.commons:commons-lang3:jar:3.12.0:compile
> [INFO] +- com.sun.pdfview:PDFRenderer:jar:0.9.0:compile
> [INFO] +- commons-beanutils:commons-beanutils:jar:1.9.2:compile
> [INFO] |  +- commons-logging:commons-logging:jar:1.1.1:compile
> [INFO] |  \- commons-collections:commons-collections:jar:3.2.1:compile
> [INFO] +- commons-codec:commons-codec:jar:1.10:compile
> [INFO] +- org.locationtech.jts:jts-core:jar:1.18.1:compile
> [INFO] +- org.geotools:gt-shapefile:jar:22.2:compile
> [INFO] |  +- org.geotools:gt-main:jar:22.2:compile
> [INFO] |  |  \- org.apache.commons:commons-text:jar:1.6:compile
> [INFO] |  +- org.jdom:jdom2:jar:2.0.6:compile
> [INFO] |  \- javax.media:jai_core:jar:1.1.3:compile
> [INFO] +- org.geotools.jdbc:gt-jdbc-postgis:jar:22.2:compile
> [INFO] |  \- org.geotools:gt-jdbc:jar:22.2:compile
> [INFO] |     \- commons-dbcp:commons-dbcp:jar:1.4:compile
> [INFO] +- org.geotools:gt-cql:jar:22.2:compile
> [INFO] |  \- org.geotools:gt-xml:jar:22.2:compile
> [INFO] |     \- org.apache.xml:xml-commons-resolver:jar:1.2:compile
> [INFO] +- org.geotools:gt-epsg-hsql:jar:22.2:compile
> [INFO] |  +- org.geotools:gt-referencing:jar:22.2:compile
> [INFO] |  |  +- org.ejml:ejml-ddense:jar:0.34:compile
> [INFO] |  |  |  \- org.ejml:ejml-core:jar:0.34:compile
> [INFO] |  |  +- commons-pool:commons-pool:jar:1.5.4:compile
> [INFO] |  |  +- org.geotools:gt-metadata:jar:22.2:compile
> [INFO] |  |  |  \- org.geotools:gt-opengis:jar:22.2:compile
> [INFO] |  |  |     \- systems.uom:systems-common-java8:jar:0.7.2:compile
> [INFO] |  |  |        +- tec.uom:uom-se:jar:1.0.8:compile
> [INFO] |  |  |        |  +- javax.measure:unit-api:jar:1.0:compile
> [INFO] |  |  |        |  \- tec.uom.lib:uom-lib-common:jar:1.0.2:compile
> [INFO] |  |  |        +- si.uom:si-quantity:jar:0.7.1:compile
> [INFO] |  |  |        \- si.uom:si-units-java8:jar:0.7.1:compile
> [INFO] |  |  +- jgridshift:jgridshift-core:jar:1.2:compile
> [INFO] |  |  |  \- javax:javaee-api:jar:7.0:compile
> [INFO] |  |  |     \- com.sun.mail:javax.mail:jar:1.5.0:compile
> [INFO] |  |  \- net.sf.geographiclib:GeographicLib-Java:jar:1.49:compile
> [INFO] |  \- org.hsqldb:hsqldb:jar:2.4.1:compile
> [INFO] +- org.apache.commons:commons-csv:jar:1.0:compile
> [INFO] +- org.springframework:spring-jdbc:jar:4.1.7.RELEASE:compile
> [INFO] +- com.zaxxer:HikariCP:jar:2.4.2:compile
> [INFO] +- org.apache.httpcomponents:httpclient:jar:4.3.5:compile
> [INFO] |  \- org.apache.httpcomponents:httpcore:jar:4.3.2:compile
> [INFO] +- com.jolbox:bonecp:jar:0.8.0.RELEASE:compile
> [INFO] |  \- com.google.guava:guava:jar:15.0:compile
> [INFO] +- com.sun.xml.bind:jaxb-impl:jar:2.2.11:compile
> [INFO] +- com.sun.xml.bind:jaxb-core:jar:2.2.11:compile
> [INFO] +- net.sf.supercsv:super-csv:jar:2.4.0:compile
> [INFO] +- com.googlecode.json-simple:json-simple:jar:1.1:compile
> [INFO] +- org.seleniumhq.selenium:selenium-java:jar:2.44.0:test
> [INFO] |  +- org.seleniumhq.selenium:selenium-chrome-driver:jar:2.44.0:test
> [INFO] |  |  \-
> org.seleniumhq.selenium:selenium-remote-driver:jar:2.44.0:test
> [INFO] |  |     +- cglib:cglib-nodep:jar:2.1_3:test
> [INFO] |  |     \- org.seleniumhq.selenium:selenium-api:jar:2.44.0:test
> [INFO] |  +-
> org.seleniumhq.selenium:selenium-htmlunit-driver:jar:2.44.0:test
> [INFO] |  |  \- net.sourceforge.htmlunit:htmlunit:jar:2.15:test
> [INFO] |  |     +- xalan:xalan:jar:2.7.1:test
> [INFO] |  |     |  \- xalan:serializer:jar:2.7.1:test
> [INFO] |  |     +- org.apache.httpcomponents:httpmime:jar:4.3.3:test
> [INFO] |  |     +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.15:test
> [INFO] |  |     +- xerces:xercesImpl:jar:2.11.0:test
> [INFO] |  |     |  \- xml-apis:xml-apis:jar:1.4.01:test
> [INFO] |  |     +- net.sourceforge.nekohtml:nekohtml:jar:1.9.21:test
> [INFO] |  |     +- net.sourceforge.cssparser:cssparser:jar:0.9.14:test
> [INFO] |  |     |  \- org.w3c.css:sac:jar:1.3:test
> [INFO] |  |     \-
> org.eclipse.jetty:jetty-websocket:jar:8.1.15.v20140411:test
> [INFO] |  |        +-
> org.eclipse.jetty:jetty-util:jar:8.1.15.v20140411:test
> [INFO] |  |        +- org.eclipse.jetty:jetty-io:jar:8.1.15.v20140411:test
> [INFO] |  |        \-
> org.eclipse.jetty:jetty-http:jar:8.1.15.v20140411:test
> [INFO] |  +-
> org.seleniumhq.selenium:selenium-firefox-driver:jar:2.44.0:test
> [INFO] |  +- org.seleniumhq.selenium:selenium-ie-driver:jar:2.44.0:test
> [INFO] |  |  +- net.java.dev.jna:jna:jar:3.4.0:test
> [INFO] |  |  \- net.java.dev.jna:platform:jar:3.4.0:test
> [INFO] |  +- org.seleniumhq.selenium:selenium-safari-driver:jar:2.44.0:test
> [INFO] |  +- org.seleniumhq.selenium:selenium-support:jar:2.44.0:test
> [INFO] |  \- org.webbitserver:webbit:jar:0.4.14:test
> [INFO] |     \- io.netty:netty:jar:3.5.2.Final:test
> [INFO] \- com.opera:operadriver:jar:1.5:test
> [INFO]    +- com.opera:operalaunchers:jar:1.1:test
> [INFO]    +- com.google.protobuf:protobuf-java:jar:2.4.1:test
> [INFO]    +- commons-jxpath:commons-jxpath:jar:1.3:test
> [INFO]    +- org.apache.commons:commons-exec:jar:1.1:test
> [INFO]    \- org.ini4j:ini4j:jar:0.5.2:test
> [INFO]
> ------------------------------------------------------------------------
> _______________________________________________
> GeoTools-GT2-Users mailing list
> GeoTools-GT2-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>


-- 
Ian Turton
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to