I've created a database pool named clink which connects to a database
stored in a MySQL server. The database pool wizard indicated the
connection was successful. I'm encountering some difficulty using
the pool from within a JSP.
I'm using the following web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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/j2ee http://
java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>
index.jsp
</welcome-file>
</welcome-file-list>
<resource-ref>
<res-ref-name>jdbc/cl</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</web-app>
Within geronimo-web.xml I have the following:
<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1">
<environment>
<moduleId>
<artifactId>Included content</artifactId>
</moduleId>
<dependencies>
<dependency>
<groupId>console.dbpool</groupId>
<artifactId>cl</artifactId>
</dependency>
</dependencies>
</environment>
<context-root>/includes</context-root>
<resource-ref>
<ref-name>jdbc/cl</ref-name>
<resource-link>clink</resource-link>
</resource-ref>
</web-app>
Within my code I attempt to access the pool as follows:
InitialContext ctx = new InitialContext();
DataSource ds = ctx.lookup("java:comp/env/jdbc/cl");
Connection con = ds.getConnection();
When the page executes I receive the following errors:
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 12 in the jsp file: /demo/pooltest.jsp
Generated servlet error:
InitialContext cannot be resolved to a type
An error occurred at line: 12 in the jsp file: /demo/pooltest.jsp
Generated servlet error:
InitialContext cannot be resolved to a type
An error occurred at line: 12 in the jsp file: /demo/pooltest.jsp
Generated servlet error:
DataSource cannot be resolved to a type
Could someone tell me what I've done incorrectly? The process seems
straightforward, but I've done something incorrectly.
Thanks,
Bob