I'm getting the following error message during startup
SEVERE: Cannot register null bean for
[Tomcat:type=DataSource,host=localhost,context=/sgs,class=javax.sql.DataSource,name="jdbc/sgsdb"]
with sgs/META-INF/context.xml as
<Context reloadable="true">
<Resource
name="jdbc/sgsdb"
url="jdbc:postgresql://localhost:5432/version4007"
driverClassName="org.postgresql.Driver"
// a dozen attribute elided.
type="javax.sql.DataSource"
classname="org.apache.tomcat.dbcp.dbcp.datasources.PerUserPoolDataSource"
factory="org.apache.commons.dbcp2.datasources.PerUserPoolDataSourceFactory"
/>
</Context>
and sgs/WEB-INF/web.xml as
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>SGSaaS</display-name>
<context-param>
<description>Enable debugging for the application</description>
<param-name>debug</param-name>
<param-value>true</param-value>
</context-param>
<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>
<env-entry>
<env-entry-name>roleExtension</env-entry-name>
<env-entry-value>${SGSSRVR_roleExtension}</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
<env-entry>
<env-entry-name>expansionStep</env-entry-name>
<env-entry-value>${SGSSRVR_expansionStep}</env-entry-value>
<env-entry-type>java.lang.Integer</env-entry-type>
</env-entry>
<resource-ref>
<description>Pointer to context datasource</description>
<res-ref-name>jdbc/sgsdb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
Deep down in NamingContextListen
actualResource =envCtx.lookup(resource.getName());
fails, setting actualResource to null and resource.getName() is "jdbc/sgsdb"
I can get the env values (some of which are superfluous) in my app, but
I cannot get the DataSource I think because it isn't there.
I've tried (with castings removed for brevity)
ctx = initialContext.lookup("java:/comp/env");
dataSource = ctx.lookup("jdbc/sgsdb");
dataSource=initialContext.lookup("sgs/jdbc/sgsdb") //with and
without leading slash
and several permutations of these.
Where have a gone afoul of the XMLgod(s)?