Sorry, just realized the title should have read "JDBC driver disappears when using mod_webapp".
From: "Soefara Redzuan" <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: JDBC Driver disappears when using Mod_jk !
Dear Sirs,
This is truly bizarre. I've been runing Apache+mod_webapp in front of one of our websites for quite a time now and it has worked fine for serving up JSP pages. So, the Apache->mod_webapp->Tomcat communication seems to be working OK.
I recently added a JNDI datasource to the Tomcat web application. The datasource is configured perfectly, as proven with the useful servlet (below) which we always use to test JNDI datasource connections. ie. http://www.oursite.com:8080/ourapp/TestDb?jndi=jdbc/dbname
reports that we successfully created a database connection from the JNDI datasource.
However, when we now try to access via mod_webapp ie. http://www.oursite.com/ourapp/TestDb?jndi=jdbc/dbname
it reports an error message "Cannot load JDBC driver class 'null'"
How can this be ??? Apache+mod_webapp has been proven to be configured properly since we've been serving up JSP from this webapp for months. When connecting directly to Tomcat on port 8080, the JNDI resource does indeed exist and we can create the connection so the JDBC driver must exist too (and it does) !
Why does the JDBC driver seem to disappear when using mod_webapp???
I hope somebody can shed some light on this.
Thank you in advance,
Soefara.
ps. here's the servlet we use for testing JNDI datasource connections, maybe some of you will find it useful.
------------------------------------------------------------------
import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; import java.sql.*; import javax.sql.*; import javax.naming.*;
public class DbHandlerDebug extends HttpServlet {
public void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Connection conn = null;
String jndiName = request.getParameter("jndi");
response.setContentType("text/html");
PrintWriter out = new PrintWriter(response.getOutputStream() );
out.println("<html><body><h3>Test JNDI</h3>");
Context ctx = null;
DataSource ds = null;
if (jndiName == null) {
out.println("<font color=#0000ff><p>Usage : send argument 'jndi'. <br> eg. /servlet/TestDB?jndi=jdbc/ourdb");
}
try {
ctx = new InitialContext();
Context envCtx = (Context) ctx.lookup("java:/comp/env/");
out.println("<li>Retrieved Context");
ds = (DataSource) envCtx.lookup(jndiName);
out.println("<li>Obtained Datasource");
conn = ds.getConnection();
out.println("<li>Got Connection");
out.println("<h3>OK :-)</h3>");
}
catch (NamingException e) {
out.println("Failed to get datasource from context : " + e.getMessage());
}
catch (SQLException e) {
out.println("Failed to get DB connection : " + e.getMessage());
}
catch (Exception e) {
out.println("Unexpected error : " + e.getMessage());
}
out.flush();
}
} ----------------------------------------------------------------
_________________________________________________________________
Download ringtones, logos and picture messages from MSN Malaysia http://www.msn.com.my/mobile/ringtones/default.asp
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
_________________________________________________________________ Are you in love? Find a date on MSN Personals http://match.msn.com.my/
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
