Bug 5921 - Better error reporting for ConnectionTag and JNDI lookups
Summary: Better error reporting for ConnectionTag and JNDI lookups
Alias: None
Product: Taglibs
Classification: Unclassified
Component: DBTags Taglib (show other bugs)
Version: 1.0B1
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2002-01-18 06:20 UTC by Eric Kramer
Modified: 2004-11-16 19:05 UTC (History)
1 user (show)


Note You need to log in before you can comment on or make changes to this bug.
Description Eric Kramer 2002-01-18 06:20:41 UTC
When using the Connection tag to obtain connections from JNDI datasources, if 
a DataSource is not found at the specified JNDI context string, the system 
reports a NullPointerException with no other detail.  This can be confusing to 
troubleshoot as there is no indication in the error message as to why doEntTag 
should encounter said Exception.

In reviewing the source, there appears to be no check for a null return from 
JNDI inside the doEndTag method.  I would strongly recommend a few well-placed 
lines of additional code to provide better error reporting.

This Taglib is *awesome*!  :)  I used to use Cold Fusion but don't see any 
reason to go back now!
Comment 1 Morgan Delagrange 2002-04-15 04:21:30 UTC
Glad you like the tags.  :)

That JNDI support was contributed, and I don't really use it myself.  From the 
Javadocs on Context.lookup(String), it sounds like an incorrect context string 
should throw a specific NamingException , not a NullPointerException.  Isn't 
that the case?
Comment 2 Eric Kramer 2002-04-15 13:11:30 UTC
My read of the JavaDocs at 
(java.lang.String) didn't seem to indicate that a NamingException would 
necessarily be thrown if no object is found.  It seems that the 
NamingException is only thrown if a "naming exception is encountered" 
(whatever that *specfically* means... *smile*).

My guess is that the decision to either return null or thrown an exception may 
be up to the implementor.  Again, just my guess.

Either way, a check for null seems prudent (to me, having spent a few hours 
troubleshooting this under Tomcat one rainy weekend).  :)
Comment 3 Felipe Leme 2004-02-26 20:09:15 UTC
I will take a look on this bug later this week...
Comment 4 Felipe Leme 2004-02-28 02:22:14 UTC

The problem was not related to JNDI lookup, but with a DataSource object been
set in the JSP context. Here is the message you will get now:

org.apache.jasper.JasperException: Did not find a DataSource bean mamed myDS2