Which steps should be taken to build the spatialindex table inside PostgreSQL when using a JNDI connection?
Is the table built by GeoNetwork or does it need to be created manually?
What I have tried so far:
For building the spatialindex
table in GeoNetwork (3.0.6) in the Postgres database as opposed to using a shapefile internally, I switched database connection to JNDI, as recommended in the advanced configuration docs.
Creating JNDI connection first
To do so, I had to change the database type used in srv.xml
to <import resource="../config-db/jndi-postgres-postgis.xml"/>
and configure my datasource in context.xml
like so:
<Resource
name="jdbc/geonetwork"
type="javax.sql.DataSource"
auth="Container"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/geonetwork"
username="geonetwork_user"
password=""
maxActive="20"
maxIdle="20"
maxWait="200"
initialSize="20"
removeAbandoned="true"
removeAbandonedTimeout="120"
logAbandoned="true"
testOnBorrow="true"
defaultReadOnly="false"
defaultAutoCommit="false"
validationQuery="SELECT 1"
timeBetweenEvictionRunsMillis="10000"
minEvictableIdleTimeMillis="1800000"
testWhileIdle="true"
numTestsPerEvictionRun="3"
poolPreparedStatements="true"
maxOpenPreparedStatements="1200"
provideDataStore="true" --> tried this to build spatialindex table
/>
I added the provideDataStore
parameter according to this section. Actually it looks like it must go into the /config-db/jndi-postgres-postgis.xml
file, but this is rejected by the application.
I adapted some configuration in the /config-db/jndi-postgres-postgis.xml
file as mentioned here:
<bean id="jdbcDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:/comp/env/jdbc/geonetwork"/>
<property name="cache" value="true"/>
<property name="exposeAccessContext" value="false"/>
</bean>
<bean id="jpaVendorAdapterDatabaseParam" class="java.lang.String">
<constructor-arg value="POSTGRESQL"/>
</bean>
With this configuration, I was able to switch the database connection to JNDI.
Build spatialindex into Postgres
But nevertheless, it does not build the spatialindex into Postgres.
I tried:
- Restarting tomcat
- Harvesting new datasets
- Playing around with the
provideDataStore
parameter - Creating the table
spatialindex
myself to make GeoNetwork use it on restart
The table is defined according to the definition from the 2.10 branch's create-db-postgis.sql file:
CREATE TABLE spatialindex
(
fid int not null,
id varchar(250),
primary key(fid)
);
CREATE INDEX spatialindexNDX1 ON spatialindex(id);
SELECT AddGeometryColumn('spatialindex', 'the_geom', 4326, 'MULTIPOLYGON', 2 );
CREATE INDEX spatialindexNDX2 on spatialindex USING GIST(the_geom);
But my spatialindex.shp
file in the data directory still gets altered instead of the database table.
Is there anything else neccessary to make GeoNetwork build the spatialindex
table in Postgres?