Deepak,


This '' and null error means that the Tomcat is not finding the JDBC JNDI resource.


This is how to fix this on Tomcat 5.5:

Make sure that you have a Resource element properly configured in your context.xml that is in $CATALINA_HOME/conf/ directory.

 <Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"
              maxActive="100" maxIdle="30" maxWait="10000"
              username="<someuser>" password="<somepassword>" driverClassName="<your 
driver>"
              url="<proper url for your db's jdbc conventions>"/>

</Context>




Make sure it is available to your web app, by setting the references in your web.xml.


 <resource-ref>
     <description>DB Connection</description>
     <res-ref-name>jdbc/TestDB</res-ref-name>
     <res-type>javax.sql.DataSource</res-type>
     <res-auth>Container</res-auth>
 </resource-ref>



Thank you,
Edmon
http://blogs.ittoolbox.com/eai/software

deepak suldhal wrote:

When I write a simple java class to get the driver and connection it works fine.
I am able to retrive row and print them.
But I am not able to get the same on Tomcat server.


Note: forwarded message attached.

------------------------------------------------------------------------
Do you Yahoo!?
The all-new My Yahoo! <http://my.yahoo.com> – What will yours do?
------------------------------------------------------------------------

Subject:
JDBC connection - Please help
From:
deepak suldhal <[EMAIL PROTECTED]>
Date:
Sun, 20 Feb 2005 22:22:48 -0800 (PST)
To:
tomcat users <[email protected]>

To:
tomcat users <[email protected]>


Please help me make my first JDBC connection
My web.xml


<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"> <description>MySQL Test App</description> <resource-ref> <description>DB Connection</description> <res-ref-name>jdbc/TestDB</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> </web-app> -------------------------------------------------------------------------------
In server.xml I have the following context ( trying to connect to Sybase database)
<Context path="/DBTest" docBase="DBTest" debug="5" reloadable="true" crossContext="true"> <Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="javauser" password="javadude" driverClassName="com.sybase.jdbc2.jdbc.SybDriver" url="jdbc:sybase:Tds:re2unx188:2025"/> </Context>
-------------------------------------------------------------------------------
I have copied the JDCB drive Jar under
commons/lib
I have a test.jsp as follows
------------------------------------------------------------------------------- <%@ taglib uri="http://java.sun.com/jsp/jstl/sql"; prefix="sql" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"; prefix="c" %>
<sql:query var="rs" dataSource="jdbc/TestDB">
select id, foo, bar from testdata
</sql:query>
<html>
<head>
<title>DB Test</title>
</head>
<body>
<h2>Results</h2>
<c:forEach var="row" items="${rs.rows}">
Foo ${row.foo}<br/>
Bar ${row.bar}<br/>
</c:forEach>
</body>
</html>
-------------------------------------------------------------------------------
My directory structue is as follows
webapps/DBTest/WEB-INF/web.mxl
/DBTest/test.jsp
-------------------------------------------------------------------------------
And when I try the url
http://localhost:8080/DBTest/test.jsp
I am getting the following errors
description The server encountered an internal error () that prevented it from fulfilling this request. exception javax.servlet.ServletException: Unable to get connection, DataSource invalid: "org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'"
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.test_jsp._jspService(test_jsp.java:82)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'"
org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(Unknown Source)
org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(Unknown Source)
org.apache.jsp.test_jsp._jspx_meth_sql_query_0(test_jsp.java:101)
org.apache.jsp.test_jsp._jspService(test_jsp.java:58)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802


-------------------------------------------------------------------------------
My console server display is as follows
eb 20, 2005 10:31:08 PM org.apache.coyote.http11.Http11Protocol init INFO: Initializing Coyote HTTP/1.1 on http-8080 Feb 20, 2005 10:31:08 PM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 1422 ms Feb 20, 2005 10:31:09 PM org.apache.catalina.core.StandardService start INFO: Starting service Catalina Feb 20, 2005 10:31:09 PM org.apache.catalina.core.StandardEngine start INFO: Starting Servlet Engine: Apache Tomcat/5.0.28 Feb 20, 2005 10:31:09 PM org.apache.catalina.core.StandardHost start INFO: XML validation disabled Feb 20, 2005 10:31:10 PM org.apache.catalina.core.StandardHost getDeployer INFO: Create Host deployer for direct deployment ( non-jmx ) Feb 20, 2005 10:31:10 PM org.apache.catalina.core.StandardHostDeployer install INFO: Processing Context configuration file URL file:C:\jakarta-tomcat-5.0.28\conf\Catalina\localhost\admin.xml Feb 20, 2005 10:31:10 PM org.apache.struts.util.PropertyMessageResources <init> INFO: Initializing, config='org.apache.struts.util.LocalStrings', returnNull=true Feb 20, 2005 10:31:10 PM org.apache.struts.util.PropertyMessageResources <init> INFO: Initializing, config='org.apache.struts.action.ActionResources', returnNull=true Feb 20, 2005 10:31:11 PM org.apache.struts.util.PropertyMessageResources <init> INFO: Initializing, config='org.apache.webapp.admin.ApplicationResources', returnNull=true Feb 20, 2005 10:31:13 PM org.apache.catalina.core.StandardHostDeployer install INFO: Processing Context configuration file URL file:C:\jakarta-tomcat-5.0.28\conf\Catalina\localhost\balancer.xml Feb 20, 2005 10:31:14 PM org.apache.catalina.core.StandardHostDeployer install INFO: Processing Context configuration file URL file:C:\jakarta-tomcat-5.0.28\conf\Catalina\localhost\CurrencyConverter.xml Feb 20, 2005 10:31:14 PM org.apache.catalina.core.StandardHostDeployer install INFO: Processing Context configuration file URL file:C:\jakarta-tomcat-5.0.28\conf\Catalina\localhost\expressionLanguage.xml Feb 20, 2005 10:31:14 PM org.apache.catalina.core.StandardHostDeployer install INFO: Processing Context configuration file URL file:C:\jakarta-tomcat-5.0.28\conf\Catalina\localhost\Fin46.xml Feb 20, 2005 10:31:14 PM org.apache.catalina.core.StandardHostDeployer install INFO: Processing Context configuration file URL file:C:\jakarta-tomcat-5.0.28\conf\Catalina\localhost\Fupload.xml Feb 20, 2005 10:31:15 PM org.apache.catalina.core.StandardHostDeployer install INFO: Processing Context configuration file URL file:C:\jakarta-tomcat-5.0.28\conf\Catalina\localhost\Hangman.xml Feb 20, 2005 10:31:15 PM org.apache.catalina.core.StandardHostDeployer install INFO: Processing Context configuration file URL file:C:\jakarta-tomcat-5.0.28\conf\Catalina\localhost\helloworld.xml Feb 20, 2005 10:31:15 PM org.apache.catalina.core.StandardHostDeployer install INFO: Processing Context configuration file URL file:C:\jakarta-tomcat-5.0.28\conf\Catalina\localhost\Interactivehelloworld.xml Feb 20, 2005 10:31:15 PM org.apache.catalina.core.StandardHostDeployer install INFO: Processing Context configuration file URL file:C:\jakarta-tomcat-5.0.28\conf\Catalina\localhost\jstltest.xml Feb 20, 2005 10:31:15 PM org.apache.catalina.core.StandardHostDeployer install INFO: Processing Context configuration file URL file:C:\jakarta-tomcat-5.0.28\conf\Catalina\localhost\manager.xml Feb 20, 2005 10:31:15 PM org.apache.catalina.core.StandardHostDeployer install INFO: Processing Context configuration file URL file:C:\jakarta-tomcat-5.0.28\conf\Catalina\localhost\ServletExamples.xml Feb 20, 2005 10:31:15 PM org.apache.catalina.core.StandardHostDeployer install INFO: Processing Context configuration file URL file:C:\jakarta-tomcat-5.0.28\conf\Catalina\localhost\store.xml Feb 20, 2005 10:31:16 PM org.apache.catalina.core.StandardHostDeployer install INFO: Installing web application at context path /sample from URL file:C:/jakarta-tomcat-5.0.28/webapps/sample Feb 20, 2005 10:31:16 PM org.apache.catalina.core.StandardHostDeployer install INFO: Installing web application at context path /jsp-examples from URL file:C:\jakarta-tomcat-5.0.28\webapps\jsp-examples Feb 20, 2005 10:31:16 PM org.apache.catalina.core.StandardHostDeployer install INFO: Installing web application at context path from URL file:C:\jakarta-tomcat-5.0.28\webapps\ROOT Feb 20, 2005 10:31:16 PM org.apache.catalina.core.StandardHostDeployer install INFO: Installing web application at context path /servlets-examples from URL file:C:\jakarta-tomcat-5.0.28\webapps\servlets-examples Feb 20, 2005 10:31:16 PM org.apache.catalina.core.StandardHostDeployer install INFO: Installing web application at context path /tomcat-docs from URL file:C:\jakarta-tomcat-5.0.28\webapps\tomcat-docs Feb 20, 2005 10:31:17 PM org.apache.catalina.core.StandardHostDeployer install INFO: Installing web application at context path /webdav from URL file:C:\jakarta-tomcat-5.0.28\webapps\webdav Feb 20, 2005 10:31:17 PM org.apache.coyote.http11.Http11Protocol start INFO: Starting Coyote HTTP/1.1 on http-8080 Feb 20, 2005 10:31:17 PM org.apache.jk.common.ChannelSocket init INFO: JK2: ajp13 listening on /0.0.0.0:8009 Feb 20, 2005 10:31:17 PM org.apache.jk.server.JkMain start INFO: Jk running ID=0 time=10/40 config=C:\jakarta-tomcat-5.0.28\conf\jk2.properties Feb 20, 2005 10:31:17 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 8835 ms



__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com


------------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to