Using tomcat 9.0.58 I have a propertiesfile supplied to my embedded tomcat which includes

   SGSSRVR_databasePort     = 5432
   SGSSRVR_databaseHost        = localhost

and in my app-specific web.xml I have

   <env-entry>
        <env-entry-name>databaseHost</env-entry-name>
   <env-entry-value>${SGSSRVR_databaseHost}</env-entry-value>
   <env-entry-type>java.lang.String</env-entry-type>
      </env-entry>
      <env-entry>
        <env-entry-name>databasePort</env-entry-name>
   <env-entry-value>${SGSSRVR_databasePort}</env-entry-value>
   <env-entry-type>java.lang.Integer</env-entry-type>
      </env-entry>

but at tomcat startup several warnings which confuse me and a fatal error:

   INFO: Starting service [Tomcat]
   Mar 10, 2022 8:34:32 AM org.apache.catalina.core.StandardEngine
   startInternal
   INFO: Starting Servlet engine: [Apache Tomcat/9.0.59]
   Mar 10, 2022 8:34:32 AM org.apache.tomcat.util.digester.Digester
   endElement
   WARNING: No rules found matching [Context/Context/Valve]
   Mar 10, 2022 8:34:32 AM org.apache.tomcat.util.digester.Digester
   endElement
   WARNING: No rules found matching [Context/Context]
   Mar 10, 2022 8:34:32 AM org.apache.catalina.startup.ContextConfig
   getDefaultWebXmlFragment
   INFO: No global web.xml found
   Mar 10, 2022 8:34:33 AM org.postgresql.util.PGPropertyUtil
   convertPgPortToInt
   WARNING: JDBC URL invalid port number:
   Mar 10, 2022 8:34:33 AM org.apache.tomcat.jdbc.pool.ConnectionPool init
   SEVERE: Unable to create initial connections of pool.
   java.sql.SQLException: Driver:org.postgresql.Driver@1ecfa525
   returned null for URL:jdbc:postgresql://localhost:5432:/tbar


The main surprise to me is the "invalid port number".  Am I correct in using the ${property-name} in web.xml?  The main() reads the properties file, for sure.


About context/context/value:  I have this context.xml. Is the value correctly inside the outer Context?

   <Context reloadable="true">

      <Resource
          name="jdbc/sgsdb/tbar"
          url="jdbc:postgresql://localhost:5432:/tbar"
          driverClassName="org.postgresql.Driver"
          type="javax.sql.DataSource"
          factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
          testWhileIdle="false"
          testOnBorrow="true"
          testOnReturn="false"
          validationInterval="30000"
          validationQuery="select 1"
          timeBetweenEvictionRunsMillis="30000"
          maxActive="50"
          initialSize="3"
          maxWait="10000"
          removeAbandonedTimeout="3600"
          removeAbandoned="true"
          minEvictableIdleTimeMillis="30000"
          minIdle="1"
          maxIdle="5"
          logAbandoned="true"
          username="shoc"
          password="password"
          />

      <Context>
        <Valve
        className="org.apache.catalina.valves.AccessLogValve"
        prefix="sgs_access"
        directory="${SGSSRVR_AccessLogDir}"
        maxDays="7">
        </Valve>
      </Context>
   </Context>


Reply via email to