Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

javax.servlet.ServletException: Cannot create JDBC driver of class '' for connect URL 'null'

Posted on 2005-04-29
10
Medium Priority
?
591 Views
Last Modified: 2008-01-09
I don't seem to be able to get to my database.  Thanks
for taking a look...


type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Cannot create JDBC driver of class '' for connect URL 'null'
      org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
      org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
      org.apache.jsp.index2_jsp._jspService(org.apache.jsp.index2_jsp:165)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
      org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:780)
      org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
      org.apache.jsp.index2_jsp._jspService(org.apache.jsp.index2_jsp:92)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.
0
Comment
Question by:padmasambhava
  • 5
  • 3
  • 2
10 Comments
 
LVL 92

Expert Comment

by:objects
ID: 13898457
check your driver is available
and that you have specified the correct connect url string
0
 
LVL 92

Expert Comment

by:objects
ID: 13898462
And that the driver class name is specified correctly.
0
 

Author Comment

by:padmasambhava
ID: 13899533
Here's the code that's giving me fits...

  Context iniCtx = new InitialContext();
  Context envCtx = (Context)    iniCtx.lookup("java:comp/env");
  DataSource ds =  (DataSource) envCtx.lookup("jdbc/something");
  Connection con = ds.getConnection();
  Statement  st = con.createStatement();

And here's the server.xml code as well...

        <Resource name="jdbc/something"
                  auth="Container"
                  type="javax.sql.DataSource"
                  driverClassName="org.postgresql.Driver"
                  url="jdbc:postgresql://127.0.0.1:5432/something"
                  username="something" password="password"
                  maxActive="20" maxIdle="10" maxWait="-1"/>
<!--
      
          <Resource name="jdbc/something" auth="Container"
                    type="javax.sql.DataSource">
          </Resource>

          <ResourceParams name="jdbc/something">
             <parameter>
               <name>factory</name>
               <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
             </parameter>

            <parameter>
              <name>removeAbandoned</name>
              <value>true</value>
            </parameter>

             <parameter>
               <name>driverClassName</name>
               <value>org.postgresql.Driver</value>
             </parameter>

             <parameter>
               <name>url</name>
               <value>jdbc:postgresql:something</value>
             </parameter>

             <parameter>
               <name>username</name>
               <value>something</value>
             </parameter>

             <parameter>
               <name>password</name>
               <value>password</value>
             </parameter>

             <parameter>
               <name>maxActive</name>
               <value>20</value>
             </parameter>

             <parameter>
               <name>maxIdle</name>
               <value>10</value>
             </parameter>

             <parameter>
               <name>maxWait</name>
               <value>-1</value>
             </parameter>
           </ResourceParams>
-->
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 92

Expert Comment

by:objects
ID: 13899643
WHere is your driver jar located?
0
 

Author Comment

by:padmasambhava
ID: 13900065
Hey objects,

I forgot to mention that I'm a newbie, so how do I tell where my driver jar is located?

Thanks!
0
 
LVL 92

Expert Comment

by:objects
ID: 13900071
You need to put the jar file containing the jdbc driver in either <tomcat>/common/lib or <webapp>/WEB-INF/lib
0
 

Author Comment

by:padmasambhava
ID: 13900119
Ok, the jar file was already there and I downloaded a newer version just to see if that
helped, but I still get the same error.

0
 
LVL 92

Expert Comment

by:objects
ID: 13900148
whats the error in the log say?
0
 
LVL 2

Accepted Solution

by:
patbin earned 500 total points
ID: 13901004
Context iniCtx = new InitialContext();
  Context envCtx = (Context)    iniCtx.lookup("java:comp/env");
  DataSource ds =  (DataSource) envCtx.lookup("jdbc/something");


instead of this try this soln

Context ic = new InitialContext();
       java.lang.Object objref =
          ic.lookup("java:comp/env/jdbc/something");

OR

private String dbName = "java:comp/env/jdbc/something";

InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup(dbName);

Connection con =  ds.getConnection();



0
 
LVL 2

Expert Comment

by:patbin
ID: 13915837
thanks for grade
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
Most folks would know the basics of how Dropbox works, so that’s not the purpose of this article. Security is what it’s all about, so here I’ll share how I choose to secure my Dropbox Account and the Data it contains.
Integration Management Part 2
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month21 days, 6 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question