[GeoNetwork-users] [GeoNetwork-devel] Server-specific configuration without changing WAR file

Hi Daren,

First you could try without the startup variables to check that your
overrides config works fine.
In WEB-INF/config-overrides.xml defined the override to use
<overrides>
<override>/WEB-INF/config-overrides-darren.xml</override>
</overrides>

I've never tried the replace/add but for sure replaceXML will work
fine for setting resources
<replaceXML xpath="resources">
      <resource enabled="true">
        <name>main-db</name>
        <provider>jeeves.resources.dbms.ApacheDBCPool</provider>
        <config>
          <user>${db.user}</user>
          <password>${db.pass}</password>
          <driver>${db.driver}</driver>
          <url>${db.url}</url>
          <poolSize>30</poolSize>
          <minIdle>10</minIdle>
          <maxIdle>30</maxIdle>
          <maxWait>1000</maxWait>
          <validationQuery>SELECT 1</validationQuery>
        </config>
      </resource>
    </replaceXML>

Cheers.

Francois

2013/7/18 Darren Hardy <drh@anonymised.com>:

Hi Francois,

I've tried the overrides -- for the database connection -- but I haven't had any luck with them. GN doesn't appear to load the overrides and instead tries to use the default H2 database rather than my Oracle connection. Below is my setup and error message.

I'm running on Tomcat 6.0.24 and GN 2.8.0. I deploy the WAR file into Tomcat and pass the following system properties to the java command that runs Tomcat:

  java ...
  -Dgeonetwork.dir=/var/geonetwork/2.8.0/data
  -Djeeves.configuration.overrides.file=/var/geonetwork/2.8.0/etc/config-overrides.xml
  ... org.apache.catalina.startup.Bootstrap start

I'm using a data directory that's identical to the GN 2.8 WAR file's WEB-INF/data right now. The /var/geonetwork/2.8.0/etc/config-overrides.xml is as follows, based on the Configuration override documentation:

<?xml version="1.0"?>
<overrides>
  <file name=".*WEB-INF/config\.xml">
    <removeXML xpath="resources"/>
    <addXML xpath="">
      <!-- BEGIN -->
      <resources>
        <resource enabled="true">
          <name>main-db</name>
          <provider>jeeves.resources.dbms.ApacheDBCPool</provider>
          <config>
            <user>MyUser</user>
            <password>MyPassword</password>
            <driver>oracle.jdbc.driver.OracleDriver</driver>
            <url>jdbc:oracle:thin:@MyHost:MyPort:MyDatabase</url>
            <poolSize>5</poolSize>
            <validationQuery>SELECT 1 FROM DUAL</validationQuery>
            <testWhileIdle>true</testWhileIdle>
            <minEvictableIdleTimeMillis>60000</minEvictableIdleTimeMillis>
            <timeBetweenEvictionRunsMillis>900000</timeBetweenEvictionRunsMillis>
            <numTestsPerEvictionRun>4</numTestsPerEvictionRun>
          </config>
        </resource>
      </resources>
      <!-- END -->
    </addXML>
    <replaceText xpath="general/uploadDir">/var/tmp</replaceText>
    <replaceText xpath="general/debug">false</replaceText>
    <replaceText xpath="general/maxUploadSize">250</replaceText>
  </file>
</overrides>

GN then dies with the following error (trying to start the wrong H2 database):

2013-07-18 12:49:08,972 INFO [jeeves.apphand] - Initializing GeoNetwork 2.8.0.0 ...
2013-07-18 12:49:08,974 WARN [geonetwork.data.directory] - - Data directory initialization: /var/geonetwork/2.8.0/data
2013-07-18 12:49:08,975 INFO [jeeves.apphand] - Data directory: /var/geonetwork/2.8.0/data/
2013-07-18 12:49:08,976 INFO [jeeves.apphand] - jeeves.xml.catalog.files property set to /usr/share/tomcat6/webapps/geonetwork/WEB-INF/oasis-catalog.xml;/var/geonetwork/2.8.0/data/config/schemaplugin-uri-catalog.xml
2013-07-18 12:49:08,976 INFO [jeeves.apphand] - mime-mappings property set to /usr/share/tomcat6/webapps/geonetwork/WEB-INF/mime-types.properties
2013-07-18 12:49:11,382 ERROR [jeeves.apphand] - Failed to open database connection, Check config.xml db file configuration.
2013-07-18 12:49:11,384 ERROR [jeeves.apphand] - org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory
(IO Exception: "java.io.FileNotFoundException: /usr/share/tomcat6/geonetwork.lock.db (Permission denied)"; "/usr/share/tomcat6/geon
etwork.lock.db" [90031-152])

Thanks,
-Darren

--
Darren Hardy
drh@anonymised.com
GIS Software Engineer
Digital Library Systems & Services
Stanford University Libraries

On Jul 17, 2013, at 10:30 PM, Francois Prunayre <fx.prunayre@anonymised.com> wrote:

Hi Darren,

2013/7/18 Darren Hardy <drh@anonymised.com>:

Hi,

Is there a convention for added server-specific configuration (e.g., database resources, etc.) without having to alter the WAR file?

I'm trying to do a deployment across a few headless Linux servers, and right now, I have to replace the WEB-INF/config*.xml files. I'm able to do a command-line installation using the installer .jar, *but* that doesn't provide customizations for database resources, white-list hosts, etc. that are in web.xml and config*.xml.

You should look into overrides for the config:
http://geonetwork-opensource.org/manuals/trunk/eng/users/admin/advanced-configuration/index.html#configuration-override
and probably use a custom data directory
http://geonetwork-opensource.org/manuals/trunk/eng/users/admin/advanced-configuration/index.html#geonetwork-data-directory

Overrides config could be stored outside the webapp and will be
applied to config*.xml.

Cheers.

Francois

What is the recommended way to deploy server-specific configurations?

Thanks,
-Darren
--
Darren Hardy
drh@anonymised.com
GIS Software Engineer
Digital Library Systems & Services
Stanford University Libraries

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
GeoNetwork-devel mailing list
GeoNetwork-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geonetwork-devel
GeoNetwork OpenSource is maintained at http://sourceforge.net/projects/geonetwork