Im working at dockering an app with tomcat 7 and some problem with context.xml file where i define string connection db, that value is taken like string and dont variable.
Output console:
Cannot create JDBC driver of class 'org.postgresql.Driver' for connect URL 'jdbc:postgresql://${db}'
Here is context.xml file config `
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
<Manager pathname="" />
<!-- Uncomment this to enable Comet connection tacking (provides events
on session expiration as well as webapp lifecycle) -->
<!--
<Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
-->
<Environment name="debug" value="true" type="java.lang.String" override="false"/>
<Resource auth="Container" defaultAutoCommit="false" driverClassName="org.postgresql.Driver" logAbandoned="true"
factory="org.apache.commons.dbcp.BasicDataSourceFactory"
maxActive="100" maxIdle="30" maxWait="30000" name="jdbc/iurixSalta" password="${db_pass}" removeAbandoned="true"
removeAbandonedTimeout="60" type="javax.sql.DataSource"
url='jdbc:postgresql://${db}' username="${db_user}"/>
`
- Already read this post: Tomcat 8 - context.xml use Environment Variable in Datasource
- I try without quote, single quote, etc and nothing
The cmd start app:
docker run -p 8880:8080 -e DB="192.168.60.230:5432/test" -e DB_USER="factory" -e DB_PASS="test" -e JAVA_OPTS="${JAVA_OPTS} -server -Xms4524M -Xmx5024M -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/tomcat7 -XX:MaxPermSize=192m -XX:MaxNewSize=256m -XX:NewSize=256m -Xss228k -XX:+UseG1GC -XX:-UseGCOverheadLimit -XX:MaxGCPauseMillis=250 -XX:GCTimeRatio=9 -XX:+PerfDisableSharedMem -XX:+ParallelRefProcEnabled -XX:G1HeapRegionSize=8m -XX:InitiatingHeapOccupancyPercent=75 -XX:+UseLargePages -XX:+AggressiveOpts -Dsolr.autoSoftCommit.maxTime=1000 -Ddb:${DB} -Ddb_user:${DB_USER} -Ddb_pass:${DB_PASS}" test:v1.1
I try set environmet value at context file