Tomcat JDBC setup: DataSource invalid: "java.lang.NullPointerException"

Discussion in 'Java' started by cwang66@gmail.com, Oct 11, 2005.

  1. Guest

    Hi,

    I am trying to configure JDBC connecting to MS SQL 2000 in Tomcat
    5.5.9. I have tried using JDBC drivers from both Microsoft and JTDS. I
    copied JDBC jar files to [Tomcat_home]shared\lib" in both cases.
    However, I am getting the following error message from both cases( I am
    using JSTL in my JSP page.):

    javax.servlet.jsp.JspException: Unable to get connection, DataSource
    invalid: "java.lang.NullPointerException"
    org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(QueryTagSupport.java:276)
    org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(QueryTagSupport.java:159)
    org.apache.taglibs.standard.tag.el.sql.QueryTag.doStartTag(QueryTag.java:85)
    org.apache.jsp.userReport_jsp._jspx_meth_sql_query_0(org.apache.jsp.userReport_jsp:307)
    org.apache.jsp.userReport_jsp._jspx_meth_c_when_0(org.apache.jsp.userReport_jsp:241)
    org.apache.jsp.userReport_jsp._jspx_meth_c_choose_0(org.apache.jsp.userReport_jsp:203)
    org.apache.jsp.userReport_jsp._jspService(org.apache.jsp.userReport_jsp:120)
    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)


    Below is my web.xml configuration when using JTDS driver:

    <?xml version="1.0" encoding="ISO-8859-1"?>

    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2.3.dtd">
    <web-app>
    <context-param>

    <param-name>
    net.sourceforge.jtds.jdbcx.JtdsDataSource
    </param-name>
    <param-value>
    jdbc:jtds:sqlserver://127.0.0.1:1433/testdb;user=xxx;password=xxx
    </param-value>

    </context-param>


    </web-app>


    Below is my web.xml configuration when using MS driver:

    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2.3.dtd">
    <web-app>
    <context-param>


    <context-param>
    <param-name>com.microsoft.jdbc.sqlserver.SQLServerDriver</param-name>

    <param-alue>jdbc:microsoft:sqlserver://localhost:1433;User=xxx;Password=xxx;DatabaseName=testdb</param-value>

    </context-param>

    </context-param>


    </web-app>



    Any help is appreciated.
    , Oct 11, 2005
    #1
    1. Advertising

  2. Try putting the jar files in your webapp's WEB-INF/lib folder as well.

    I had this problem too, and ended up using Apache DBCP instead of
    having a JNDI datasource via tomcat.

    -cheers,
    Manish
    Manish Pandit, Oct 12, 2005
    #2
    1. Advertising

  3. Roedy Green Guest

    Roedy Green, Oct 12, 2005
    #3
  4. Guest

    The hosts file is setup by default to have the localhost setup in it. I
    forgot to mention that I did get JDBC to work with mySQL (so I am
    guessing maybe it's naming convention I use for M$ SQL is wrong.). I
    am getting the same error message in another machine with the same
    setup.

    I will look into using DBCP as another solution. The frustrating part
    of this small coding project is that the error message is really not
    very meaningful for debugging purpose. Is there any way to configure
    JSTL to spit out more verbose error message?

    Thanks,
    , Oct 12, 2005
    #4
  5. Roedy Green Guest

    On 11 Oct 2005 18:09:40 -0700, wrote or quoted :

    >
    >I will look into using DBCP as another solution. The frustrating part
    >of this small coding project is that the error message is really not
    >very meaningful for debugging purpose. Is there any way to configure
    >JSTL to spit out more verbose error message?


    I notice a higher and higher proportion of questions are about
    configuring. Nobody can help unless they are familiar with that
    particular program.

    What we need is something akin to
    http://mindprod.com/jgloss/runerrormessages.html

    Where every time you make a mistake and figure out what you did wrong,
    you log the error message and the cause. That would give others who
    come after you, and yourself later encountering a similar problem a
    hint.

    The catch is I am not the one to do this. I am not using all these
    different tools. Further I find the syntax of these configuration
    files nauseating. And I go apoplectic reading the worse than useless
    documentation on how to set them up. I want nothing to do with them.

    Perhaps some masochist needs to write a book called
    "How to configure"

    a cookbook about configuring various popular tools, and the various
    tricks for getting your files to work even when the manuals read like
    Greek.

    It might even come with a program on CD that asks you questions and
    produces the configuration files. It had better be a JAWS app since
    it would be out of date before it hit the shelves.


    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Again taking new Java programming contracts.
    Roedy Green, Oct 12, 2005
    #5
  6. Anonymous Guest

    Anonymous, Oct 12, 2005
    #6
  7. Roedy Green Guest

    On Wed, 12 Oct 2005 01:51:27 GMT, Roedy Green
    <> wrote or quoted :

    >I notice a higher and higher proportion of questions are about
    >configuring. Nobody can help unless they are familiar with that
    >particular program.


    for my proposed solution to this problem, see
    http://mindprod.com/projects/configurator.html
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Again taking new Java programming contracts.
    Roedy Green, Oct 13, 2005
    #7
  8. Anonymous Guest

    Anonymous wrote:
    > Someone replied to my same question in JTDS forum in sourceforge.net.
    > He indicated that Tomcat DataSource configuration had changed since
    > 5.5. I am going to read the document through and see if I can
    > configure it to work:
    > http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-resources-howto.html


    OK, I got it to work using DBCP and JTDS driver.
    Anonymous, Oct 14, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dhek Bhun Kho
    Replies:
    0
    Views:
    2,234
    Dhek Bhun Kho
    Jul 9, 2003
  2. Victoria
    Replies:
    4
    Views:
    638
  3. elektrophyte
    Replies:
    3
    Views:
    4,951
    Daniel Rohe
    Jan 30, 2005
  4. Mr Smith
    Replies:
    7
    Views:
    13,568
    Mr Smith
    Feb 21, 2005
  5. Fahad
    Replies:
    1
    Views:
    584
    Andrew Thompson
    Aug 8, 2005
Loading...

Share This Page