Thanks Jody for your patience and good advice! After some consideration I decided to stick with JNDI since GN + Postgresql has worked very well with that setup. So I stopped Tomcat, pulled the two Postgresql jars that were in each webapp /lib and put the latest one in Tomcat/lib. After editing the context.xml file (pasting the code from https://docs.geoserver.org/stable/en/user/tutorials/tomcat-jndi/tomcat-jndi.html) I started Tomcat and both GN and GS sprung to life without problem. Now, adding the required PostGIS/JNDI stores was no problem. I made a simple test wms and checked it in QGIS and also with GN4 harvester. Perfect. Time now for fine tuning. Now I must remember to remove the postgresql driver when updating each webapp, which I will most likely forget.
CONCLUSION: These were the obstacles that threw me off track. The manual page above must be edited and postgresql-X.X-XXX.jdbc3.jar changed to postgresql-XX.X.X.jar. Second, stress that jndiReferenceName in the GS store setup corresponds to the Resource name in context.xml. In my case jdbc/postgres equals java:comp/env/jdbc/postgres. This is by no means self-evident. Thanks again, Jody! Den mån 24 maj 2021 kl 16:18 skrev Jody Garnett <jody.garn...@gmail.com>: > Marts: > > Please remember to include the user list in discussion, for personal > support their are a number of commercial support providers (including my > employer). > > You could always setup the geoserver in its own tomcat running on a > different port (just try try it out). I did not expect you were working > directly in a production environment right away. > > There is no need to use JNDI, the goal was really to ensure that you had a > single jdbc driver for postgresql. JNDI drivers register themselves with > the JVM, the danger here is getting an instance created by the jdbc driver > included in your geonetwork app created for the geoserver app causing > conflict. It can be frustrating, some internal failure like a “class cast > exception”. > > I am not sure how you setup JNDI for geonetwork without moving the > postgres driver to tomcat libs folder? Oh look they made a tomcat specific > context.xml file in the geonetwork web app … > > https://geonetwork-opensource.org/manuals/trunk/en/install-guide/configuring-database.html > > > My recommendation still stands, pick one of the drivers probably the > newest, and move it to the $CATALINA_HOME/lib. Then remove both jdbc > drivers from both the geonetwork and geoserver wars. Don’t worry the web > applications can see the jdbc driver from $CATALINA_HOME/lib. > > Jody > > On Mon, May 24, 2021 at 2:06 AM Mats Elfström <mats.elfst...@giskraft.se> > wrote: > >> Thanks for the hints, Jody. >> Taking down my Geonetwork is not really an option since it is a public >> service. >> In 2019 I had Geonetwork and Geoserver running together under Tomcat with >> no problem. But then I did not use JNDI, only direct Postgresql access. It >> was for a former employer and I cannot check now. >> GS and GN have different JNDI solutions. GN has a fixed connection, not >> user changeable, while GS needs a selectable data source. So I do not think >> I can remove the jdbc jar from GN. >> However, I fail to see where the conflict arises. How come GS can see the >> JNDI data source even when I am not adressing it? >> >> Regards, Mats.E >> >> >> Den mån 24 maj 2021 kl 09:05 skrev Jody Garnett <jody.garn...@gmail.com>: >> >>> Let me check that out since my employer works with both applications. >>> >>> Before you start: Please try setting up geoserver in a tomcat just on >>> its own, just to confirm it works as you expect. Prior to sharing tomcat >>> with the two applications. >>> >>> Presently each application includes a postgresql driver, you will need >>> to make sure only one is used: >>> >>> - Your geonetwork is using postgresql jar version 42.2.5 ( >>> https://github.com/geonetwork/core-geonetwork/blob/4.0.4/pom.xml#L1499) >>> - The GeoServer postgresql jar version is indeed 42.2.19 ( >>> https://github.com/geotools/geotools/blob/25.0/pom.xml#L115) >>> >>> The general approach: >>> 1. Remove the jdbc driver from the individual applications (both of them) >>> 2. Add the jar to tomcat and a JNDI data source for each applicaiton >>> 3. For details see: >>> https://tomcat.apache.org/tomcat-9.0-doc/jndi-datasource-examples-howto.html#PostgreSQL >>> >>> -- >>> Jody Garnett >>> >>> >>> On Sun, 23 May 2021 at 10:04, Mats Elfström <mats.elfst...@giskraft.se> >>> wrote: >>> >>>> Dear list. >>>> I am struggling with a breaking and never before experienced Geoserver >>>> configuration error. >>>> The setup is Geoserver (2.18-2.20, all have the same problem) and >>>> Geonetwork 4.0.4 as webapps under Tomcat 9 on a Windows 2016 server. All >>>> being parts of a geodata service I am building. >>>> >>>> Geonetwork uses PostgreSQL 11.11/PostGis 3.0.3 on a JNDI connection. It >>>> has been running for about a month. >>>> Now I want to create Geoserver stores from the same PG instance, on >>>> another database which is loaded with geodata. I can connect to this >>>> database with QGIS and FME with no problem. >>>> However, Geoserver refuses to connect, and gives no helpful log hints. >>>> >>>> 1/ Standard PostGIS - PostGIS Database setup fails, producing two >>>> pages of Java errors, Oops, something went wrong... and An error occurred >>>> while loading the page. The log file reports a geotools.jdbc error: >>>> 2021-05-23 18:40:55,252 ERROR [geotools.jdbc] - There's code using JDBC >>>> based datastore and not disposing them. This may lead to temporary loss of >>>> database connections. Please make sure all data access code calls >>>> DataStore.dispose() before freeing all references to it >>>> This may be due to the existing JNDI connection to Geonetwork, but that >>>> is using another database and another user account. >>>> 2/ As an alternative, and what I would prefer is to set up another >>>> PostGIS (JNDI) - PostGIS Database (JNDI) connection for Geoserver. >>>> This fails due to false instructions. The manual instructs first to >>>> move the file postgresql-X.X-XXX.jdbc3.jar from the WEB-INF/lib folder >>>> and put it into the TOMCAT_HOME/lib folder. >>>> There is no such file in Geoserver 2.19. The closest is >>>> postgresql-42.2.19.jar, but moving that file breaks Geoserver which >>>> does not start because this file is missing. At the moment, this is a >>>> vanilla 2.19 Geoserver. >>>> >>>> Setting up PostGIS stores must be the most common connection of all, >>>> and I have been using that for years. But never with breaking errors like >>>> these. >>>> >>>> Regards, Mats.E >>>> -- >>>> >>>> >>>> *GisKraft*, Geodatakonsult >>>> >>>> Mats Elfström, Marsvinsholms stationsväg 80, 271 93 Ystad, Sweden >>>> <https://www.google.com/maps/search/Marsvinsholms+stationsv%C3%A4g+80,+271+93+Ystad,+Sweden?entry=gmail&source=g> >>>> tel: +46 70 595 39 35 / www.giskraft.se >>>> _______________________________________________ >>>> Geoserver-users mailing list >>>> >>>> Please make sure you read the following two resources before posting to >>>> this list: >>>> - Earning your support instead of buying it, but Ian Turton: >>>> http://www.ianturton.com/talks/foss4g.html#/ >>>> - The GeoServer user list posting guidelines: >>>> http://geoserver.org/comm/userlist-guidelines.html >>>> >>>> If you want to request a feature or an improvement, also see this: >>>> https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer >>>> >>>> >>>> Geoserver-users@lists.sourceforge.net >>>> https://lists.sourceforge.net/lists/listinfo/geoserver-users >>>> >>> >> >> -- >> >> >> *GisKraft*, Geodatakonsult >> >> Mats Elfström, Marsvinsholms stationsväg 80, 271 93 Ystad, Sweden >> <https://www.google.com/maps/search/Marsvinsholms+stationsv%C3%A4g+80,+271+93+Ystad,+Sweden?entry=gmail&source=g> >> tel: +46 70 595 39 35 / www.giskraft.se >> > -- > -- > Jody Garnett > -- *GisKraft*, Geodatakonsult Mats Elfström, Marsvinsholms stationsväg 80, 271 93 Ystad, Sweden tel: +46 70 595 39 35 / www.giskraft.se
_______________________________________________ Geoserver-users mailing list Please make sure you read the following two resources before posting to this list: - Earning your support instead of buying it, but Ian Turton: http://www.ianturton.com/talks/foss4g.html#/ - The GeoServer user list posting guidelines: http://geoserver.org/comm/userlist-guidelines.html If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer Geoserver-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geoserver-users