0

I have a problem concerning our GeoServer and implementing a datastore.

Regarding the docs https://docs.geoserver.org/latest/en/user/data/app-schema/property-interpolation.html it should be possible the use variables in the definition of a datastore. I am trying to get a Oracle NG connection to a database using the web-interface. When inserting normal values for the variables it is working. When I shutdown the GeoServer and change the parameter database to

${example.database} in the datastore and starting it back up it is not working, I just get a null value when trying to add a layer from that datastore in the web-interface. When I look inside the file via web-interface there is still the value ${example.database}

My App-Schema Properties resides in

/data/tomcat/webapps/geodata/WEB-INF/classes/app-schema.properties

In the Tomcat startup I defined:

-Dapp-schema.properties=/data/tomcat/webapps/geodata/WEB-INF/classes/app-schema.properties

inside app-schema.properties: example.database = databasename

I checked permission for folders and the file itself.

Do I need to create the datastore manually and not the way I am doing it currently via web-interface and then inserting the parameter with an editor?

Is there a problem because my webapp is not named GeoServer?

Or is there something I'm missing like renaming the app-schema.properties or placing it directly in the datastore folder?

This is the datastore.xml:

<dataStore>
  <id>DataStoreInfoImpl--78867253:1790e655e57:-7fff</id>
  <name>test_db</name>
  <description>test_db</description>
  <type>Oracle NG</type>
  <enabled>true</enabled>
  <workspace>
    <id>WorkspaceInfoImpl--4db88a07:1773e4d4c5e:-7fb8</id>
  </workspace>
  <connectionParameters>
    <entry key="Evictor run periodicity">300</entry>
    <entry key="Estimated extends">true</entry>
    <entry key="Max open prepared statements">50</entry>
    <entry key="fetch size">1000</entry>
    <entry key="Expose primary keys">false</entry>
    <entry key="validate connections">false</entry>
    <entry key="Connection timeout">20</entry>
    <entry key="Batch insert size">1</entry>
    <entry key="Metadata bbox">false</entry>
    <entry key="database">${example.database}</entry>
    <entry key="port">1521</entry>
    <entry key="passwd">the_passwort</entry>
    <entry key="min connections">1</entry>
    <entry key="host">variable from etc/hosts which is working</entry>
    <entry key="Loose bbox">true</entry>
    <entry key="dbtype">oracle</entry>
    <entry key="namespace">http://xxx/geoserver/allgemein</entry>
    <entry key="max connections">10</entry>
    <entry key="Evictor tests per run">3</entry>
    <entry key="Test while idle">true</entry>
    <entry key="user">the_user</entry>
    <entry key="Max connection idle time">300</entry>
  </connectionParameters>
  <__default>false</__default>
  <dateCreated>2021-05-11 07:36:25.152 UTC</dateCreated>
  <dateModified>2021-05-11 07:39:24.759 UTC</dateModified>
</dataStore>

The error when trying to create a feature out of this datastore:

Caused by: java.lang.RuntimeException: Unable to obtain connection: Cannot create PoolableConnectionFactory (Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
0

I was also struggling with this same issue where I could not add variables from .properties files inside data_dir configuration files even if app-schema.properties path was set as system variable.

Solution for me was to use environment variables that I could add on runtime environment. For example inside datastore.xml file I could reference environment variable like this:

<entry key="passwd">${DB_PASSWORD}</entry>

Geoserver would then replace the template value from environment variable.

NOTE! I used this on kartoza geoserver docker image where Geoserver system variable -DALLOW_ENV_PARAMETRIZATION was set to true.

NOTE! I dont know why this is not documented on official documentation that you can you environment variables. Perhaps the used custom docker container has some injection logic that im not were off.

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.