X

Spatial Visualization - technical tips, best practices, and news from the product team

  • December 6, 2015

Using a container datasource in Tomcat with MapViewer 12.2.1

Jayant Sharma
Sr. Director, Product Mgmt

Using a container data source in MapViewer (12.2.1) deployed on  Tomcat requires a modification to the usual process of defining a JNDI resource in Tomcat. To get the container datasource to work with MapViewer you need to prefix the string "java:comp/env/" to the container_ds name in the <map_data_source> entry in mapViewerConfig.xml.

That is, your entry should look like:

  <map_data_source name="mvdemo_container_ds"
                   container_ds="java:comp/env/jdbc/mvdemo"
                   number_of_mappers="4"
                   allow_jdbc_theme_based_foi="false"
                   editable="false"
   />

Do this after following the standard steps for defining a JNDI resource in Tomcat which uses the Oracle JDBC driver. That is,

  • the Oracle jdbc driver related classes (e.g. ojdbc6-12.10.jar, ora18n-12.1.0.jar) should be in TOMCAT_HOME/lib
  • Add the resource description to MapViewer's context.xml, i.e. mapviewer_home/META-INF/context.xml should contain an entry similar to:
    <Resource name="jdbc/mvdemo"
               auth="Container"
               type="javax.sql.DataSource"
               driverClassName="oracle.jdbc.OracleDriver"
                url="jdbc:oracle:thin:@host:port:SID"
               username="mvdemo"
               password="pwd4mvdemo"
              validationQuery="SELECT 1 FROM DUAL"
              validationInterval="30000"
              timeBetweenEvictionRunsMillis="30000"
              maxActive="100"
              minIdle="10"
              maxIdle="100"
              maxWait="10000"
              initialSize="10"
              removeAbandonedTimeout="60"
              removeAbandoned="true"
              logAbandoned="true"
             accessToUnderlyingConnectionAllowed="true"
        />


  • Add the resource description to MapViewer's web/xml (mapviewer_home/WEB-INF/web.xml). It should be similar to:
    <resource-ref>
     <description>Oracle Datasource example</description>
     <res-ref-name>jdbc/mvdemo</res-ref-name>
     <res-type>oracle.jdbc.pool.OracleDataSource</res-type>
     <res-auth>Container</res-auth>
    </resource-ref>

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.