Skip to content

Configure database connection through JNDI

mbarto edited this page Nov 30, 2016 · 1 revision

It is possible to use a JNDI Resource as the GeoStore DataSource.

To do that you need to:

  • change the applicationContext.xml file in WEB-INF to include the following override bean:
    <bean id="geostoreDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
       <property name="jndiName" value="java:comp/env/jdbc/geostore"/>
    </bean>
  • change the geostore-datasource-ovr.properties in WEB-INF/classes to remove unneeded properties:
geostoreEntityManagerFactory.jpaPropertyMap[hibernate.hbm2ddl.auto]=update
geostoreEntityManagerFactory.jpaPropertyMap[hibernate.default_schema]=geostore
  • add a new Resource in the container conf/context.xml file:
    <Resource
       name="jdbc/geostore" auth="Container" type="javax.sql.DataSource"
       driverClassName="org.postgresql.Driver"
       url="jdbc:postgresql://localhost:5432/geostore"
       username="geostore" 
       password="geostore"
       maxActive="15" 
       numTestsPerEvictionRun="15"
       minIdle="0"
       maxIdle="10" 
       maxWait="1000"
       validationQuery="select 1"
       timeBetweenEvictionRunsMillis="300000"
       testWhileIdle="true"
       minEvictableIdleTimeMillis="600000"
    />