1

I am trying to add a PostGIS database a data store in my Geoserver installation but I keep getting this error:

Error creating data store, check the parameters. Error message: Unable to obtain connection: Cannot create PoolableConnectionFactory (Something unusual has occurred to cause the driver to fail. Please report this exception.)

I am thinking that maybe I need to add an entry to my pg_hba.conf file, but it seems that adding anything to it causes the postgres server to not be able to start back up again.

Has anyone had this issue before? Was it solvable by addeding an entry to pg_hba.conf?

Since my geoserver resides on http://localhost:8080/ I tried adding:

host all all 127.0.0.1/8080

to pg_hba.conf but trying to restart the server just results in postgres crashing until I remove it again.

This is what the contents of my pg_hba.conf look like:

# Database administrative login by Unix domain socket
local   all             postgres                                peer

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     postgres                                peer
#host    replication     postgres        127.0.0.1/32            md5
#host    replication     postgres        ::1/128                 md5

Here are the geoserver log outputs after I try to make the data store:

catalina.out: https://pastebin.com/aBuJchYP

catalina.2018.06-16.log: https://pastebin.com/MuXhkcA9

localhost_access_log.2018-06-16.txt: https://pastebin.com/qh61BmAs

Other info:

  • geoserver version: 2.13
  • Postgres version: 9.6.9
  • PosGIS version: 2.4
  • can you connect to postgis from the server using psql or pgadmin? – Ian Turton Jun 16 '18 at 9:28
  • @IanTurton Yes. – wfgeo Jun 16 '18 at 9:53
  • then your hba file is probably fine - look in the geoserver log to find the relevant portion and add it to your question. – Ian Turton Jun 16 '18 at 9:56
  • @IanTurton Thank you, I added what I think is the most relevant part of the three log files that I noticed were being updated upon trying to add the store. See the pastebin links. – wfgeo Jun 16 '18 at 10:05
  • That is odd, which version of GeoServer are you using? did you add any other jars to it? which version of PostgreSQL and PostGIS are you accessing? – Ian Turton Jun 16 '18 at 10:08
1

I was finally able to solve this issue (although quickly ran into more).

It seems that the postgis .jar file was not included in the .war file that created the geoserver folder. I'm not sure if it is an oversight on the part of the geoserver team or if it is being caused by some strangeness on my end.

I downloaded postgis-jdbc-2.1.7.jar from http://postgis.net/stuff/ and put it in my /var/lib/tomcat8/webapps/geoserver/WEB_INF/lib folder and then I was able to publish data stores.

  • 1
    I checked my working installation and I do not have such jar. I do have gt-jdbc-postgis-20-SNAPSHOT.jar in my 2.14 snapshot version and the 2.12.1 war seems to contain gt-jdbc-postgis-19.1.jar. – user30184 Jun 16 '18 at 16:11
  • You have PostGIS 2.4 while I have version 2.3. Could that explain anything? – user30184 Jun 16 '18 at 16:19
  • Unzip the war file and check – Ian Turton Jun 16 '18 at 17:51
  • @user30184: The problem was that the postgis driver was entirely missing from the WEB-INF folder in geoserver. I don't think it has to do with the postgis version. – wfgeo Jun 18 '18 at 12:38
  • But as I tried to tell, I do not have postgis-jdbc-2.1.7.jar (or any other version) anywhere in my geoserver/WEB_INF/lib but Geoserver runs still fine with PostGIS for me. I guess that gt-jdbc-postgis is supposed to be enough for discussing with PostGIS. @IanTurton, could you verify? – user30184 Jun 18 '18 at 13:12
0

Here's what a working pg_hba.conf file should look like:

# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#host    replication     postgres        127.0.0.1/32            md5
#host    replication     postgres        ::1/128                 md5
host     all             all             0.0.0.0/0               md5
  • unfortunately this did not help after all. I am still unable to make a postgis data store with geoserver. i did restart the service after making the changes as well – wfgeo Jun 16 '18 at 9:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.