Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Tomcat JDBC setup: DataSource invalid: "java.lang.NullPointerException"

Reply
Thread Tools

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

 
 
cwang66@gmail.com
Guest
Posts: n/a
 
      10-11-2005
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.QueryTa gSupport.getConnection(QueryTagSupport.java:276)
org.apache.taglibs.standard.tag.common.sql.QueryTa gSupport.doStartTag(QueryTagSupport.java:159)
org.apache.taglibs.standard.tag.el.sql.QueryTag.do StartTag(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.apac he.jsp.userReport_jsp:120)
org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.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.

 
Reply With Quote
 
 
 
 
Manish Pandit
Guest
Posts: n/a
 
      10-11-2005
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

 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      10-11-2005
On 10 Oct 2005 18:31:01 -0700, wrote or quoted :

>/localhost:1433;


do you have localhost defined in your hosts file?

See http://mindprod.com/jgloss/hosts.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
 
Reply With Quote
 
cwang66@gmail.com
Guest
Posts: n/a
 
      10-12-2005
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,

 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      10-12-2005
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.
 
Reply With Quote
 
Anonymous
Guest
Posts: n/a
 
      10-12-2005
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/tom...ces-howto.html

 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      10-13-2005
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.
 
Reply With Quote
 
Anonymous
Guest
Posts: n/a
 
      10-14-2005

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/tom...ces-howto.html


OK, I got it to work using DBCP and JTDS driver.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to parse the jdbc driver name from the jdbc .jar file Bruce Java 4 03-25-2006 12:01 PM
stand-alone JMS, other JDBC operations, and transactions ( ActiveMQ + JOTM + JDBC operations ) Jesus M. Salvo Jr. Java 2 02-11-2006 06:33 PM
oracle.jdbc.OracleDriver vs oracle.jdbc.driver.OracleDriver Betty Java 1 05-21-2005 05:15 PM
Tomcat 5.5 JDBC datasource config problem (MySQL) elektrophyte Java 3 01-30-2005 07:41 AM
Re: jdbc help:sun.jdbc.odbc.JdbcOdbcDriver Keith Wansbrough Java 0 08-16-2004 07:31 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57