You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mike Cronin <mi...@fax.com> on 2007/09/01 03:21:29 UTC

Please help...

Hi all,

 

I am having a problem setting up a connection-pool via JNDI on Tomcat 6.0.14
utilizing Oracle 10g. Currently I have a <Resource> for my DataSource
referenced within a <Context> element within the server.xml file. The
classes12.jar file which contains the Oracle Driver, exists within the
$CATLINA-HOME/lib. I am able to successfully access my tables outside of the
connection pool so I know that I am getting to the driver.

 

Problem: When attempting to connect via the connection pool, I encounter the
following message.

 

org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of
class '' for connect URL 'null'

 

I have spent the last two days trying to figure this one out, and it has me
stumped. There are plenty of references to this problem on Google, but
nothing yet has led me to a solution. Please note that I am NOT receiving
this error in reference to a "No suitable driver" SQLException.

 

The following <Resource> element exists within a <Context>.

            

<Resource name="jdbc/OracleDS" auth="Container"

            type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"

            url="jdbc:oracle:thin:@xxxx.xxxx.com:9999:XXXXXX"

username="user" password="pass" maxActive="20" maxIdle="10"

maxWait="-1"/>

 

The following exists within my web.xml file located in the WEB-INF folder
within the <Host>'s appBase path.

 

            <resource-ref>

                    <description>Oracle DataSource</description>

                    <res-ref-name>jdbc/OracleDS</res-ref-name>

                    <res-type>javax.sql.DataSource</res-type>

                    <res-auth>Container</res-auth>

            </resource-ref>

 

 

Thanks in advance for your assistance!

 

Best regards,

 

Mike Cronin

 

Fax.com

"The New Way To Fax!"

 <http://www.fax.com/> www.fax.com

 

Confidential: This electronic message and all contents contain information
from Fax.com, Inc. which may be privileged, confidential or otherwise
protected from disclosure. The information is intended to be for the
addressee(s) only.  If you are not an addressee, any disclosure, copy,
distribution or use of the contents of this message is prohibited.  If you
have received this electronic message in error, please notify the sender by
reply e-mail and destroy the original message and all copies. Thank you.

 


RE: Please help...

Posted by Mike Cronin <mi...@fax.com>.
Brian, Hassan and Charles; did I happen to mention that you guys ROCK! Your
responses assisted me in coming to the conclusion that the problem had
nothing to do with the <Resource> element at all. It turns out that I had
referenced this resource within the wrong <Context> (the default <Context>
was actually being called). Silly mistake on my part, and it really helped
out immensely to have some knowledgeable guys around to bounce this one off
of.

Thanks again for responding!

Best regards,

Mike
 
Fax.com
"The New Way To Fax!"
www.fax.com
 
Confidential: This electronic message and all contents contain information
from Fax.com, Inc. which may be privileged, confidential or otherwise
protected from disclosure. The information is intended to be for the
addressee(s) only.  If you are not an addressee, any disclosure, copy,
distribution or use of the contents of this message is prohibited.  If you
have received this electronic message in error, please notify the sender by
reply e-mail and destroy the original message and all copies. Thank you.

-----Original Message-----
From: Brian Munroe [mailto:brian.e.munroe@gmail.com] 
Sent: Sunday, September 02, 2007 10:18 AM
To: Tomcat Users List
Subject: Re: Please help...

On 9/2/07, Caldarale, Charles R <Ch...@unisys.com> wrote:

>
> Correct.  It appears that "Container" is the default, but setting it
> explicitly certainly won't hurt.
>

Gotcha, thanks.

-- brian

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Please help...

Posted by Brian Munroe <br...@gmail.com>.
On 9/2/07, Caldarale, Charles R <Ch...@unisys.com> wrote:

>
> Correct.  It appears that "Container" is the default, but setting it
> explicitly certainly won't hurt.
>

Gotcha, thanks.

-- brian

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Please help...

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Brian Munroe [mailto:brian.e.munroe@gmail.com] 
> Subject: Re: Please help...
> 
> After digesting that, it seems like auth="Container" is what should be
> used when doing connection pooling, since Tomcat will be managing the
> resources?

Correct.  It appears that "Container" is the default, but setting it
explicitly certainly won't hurt.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Please help...

Posted by Brian Munroe <br...@gmail.com>.
On 9/2/07, Caldarale, Charles R <Ch...@unisys.com> wrote:

> Not really.  The Realm configuration documents how clients login to
> applications, not how Tomcat (or your app) login to external resources.
> The Security Manager describes how to place limits on what application
> code can do within Tomcat.  Neither are relevant here.
>

Ok, how about "JNDI Resources HOW-TO", which then links to the
Resource definition [1]  ;)

After digesting that, it seems like auth="Container" is what should be
used when doing connection pooling, since Tomcat will be managing the
resources?

Am I getting any warmer here?

-- brian

[1] - http://tomcat.apache.org/tomcat-5.5-doc/config/context.html#Resource%20Definitions

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Please help...

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Brian Munroe [mailto:brian.e.munroe@gmail.com] 
> Subject: Re: Please help...
> 
> So I guess I should probably read the "Realm Configuration HOW-TO" and
> "Security Manager HOW-TO" on the Tomcat documentation page?

Not really.  The Realm configuration documents how clients login to
applications, not how Tomcat (or your app) login to external resources.
The Security Manager describes how to place limits on what application
code can do within Tomcat.  Neither are relevant here.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Please help...

Posted by Brian Munroe <br...@gmail.com>.
On 9/2/07, Caldarale, Charles R <Ch...@unisys.com> wrote:

>
> The auth attribute is the equivalent of <res-auth> element inside a
> web.xml <resource-ref> setting, as defined in the servlet spec.  The
> valid values are Application or Container.
>

Chuck:

So I guess I should probably read the "Realm Configuration HOW-TO" and
"Security Manager HOW-TO" on the Tomcat documentation page?

-- brian

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Please help...

Posted by Hassan Schroeder <ha...@gmail.com>.
On 9/2/07, Caldarale, Charles R <Ch...@unisys.com> wrote:

> I take it you've noticed there's not a whole lot of documentation on
> <Resource>...

Oh, yeah, I've noticed. :-)

> Looking at the code, the default is indeed Container, which would be the
> typical usage.

Thanks for the clarification!

-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Please help...

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Hassan Schroeder [mailto:hassan.schroeder@gmail.com] 
> Subject: Re: Please help...
> 
> OK, in a resource-ref, res-auth is a mandatory element. What does
> that imply about leaving it out of a Resource in a Tomcat config?
> 
> What's the default?

I take it you've noticed there's not a whole lot of documentation on
<Resource>...

Looking at the code, the default is indeed Container, which would be the
typical usage.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Please help...

Posted by Hassan Schroeder <ha...@gmail.com>.
On 9/2/07, Caldarale, Charles R <Ch...@unisys.com> wrote:

> The auth attribute is the equivalent of <res-auth> element inside a
> web.xml <resource-ref> setting, as defined in the servlet spec.  The
> valid values are Application or Container.

OK, in a resource-ref, res-auth is a mandatory element. What does
that imply about leaving it out of a Resource in a Tomcat config?

What's the default?

-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Please help...

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Brian Munroe [mailto:brian.e.munroe@gmail.com] 
> Subject: Re: Please help...
> 
> Yea when I was originally struggling with getting connection pooling
> working, I was crafting my <Resource> and was googling like mad trying
> to find some reference to what that attribute meant.

The auth attribute is the equivalent of <res-auth> element inside a
web.xml <resource-ref> setting, as defined in the servlet spec.  The
valid values are Application or Container.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Please help...

Posted by Brian Munroe <br...@gmail.com>.
On 9/2/07, Hassan Schroeder <ha...@gmail.com> wrote:

>
> To be honest, I can't find any other documentation on that -- what
> alternative values might be, or their effect. And I just gave it a quick
> try with no setting and LambdaProbe's data sources page shows a
> blank for "Auth" -- but accessing that resource still works.
>

Yea when I was originally struggling with getting connection pooling
working, I was crafting my <Resource> and was googling like mad trying
to find some reference to what that attribute meant.  Intuition tells
me that it is letting the tomcat container handle authorization to the
resource?  Since I ended up configuring the pool at the local
application level, I assumed I didn't need to worry about it since no
other apps could use the defined resource?  That is my guess at least.

> Perhaps someone else can shed some light on this.
>
> But otherwise, your suggested config looks OK to me :-)

Thanks for your help!  I just posted about 1 minute previous to your
email - it worked fine in Tomcat  6.

-- brian

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Please help...

Posted by Hassan Schroeder <ha...@gmail.com>.
On 9/1/07, Brian Munroe <br...@gmail.com> wrote:

> Ok, lend me a hand here, besides the incorrect statement about
> common/lib, does everything else look fine?

The only discrepancy from my own config is that per the examples
in the JNDI config notes
<http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html>
I use 'auth="Container".

To be honest, I can't find any other documentation on that -- what
alternative values might be, or their effect. And I just gave it a quick
try with no setting and LambdaProbe's data sources page shows a
blank for "Auth" -- but accessing that resource still works.

Perhaps someone else can shed some light on this.

But otherwise, your suggested config looks OK to me :-)

HTH,
-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Please help...

Posted by Brian Munroe <br...@gmail.com>.
Mike, just an FYI:

This morning I tried my little 'hello, world' recipe on Tomcat 6;
aside from having to place the driver jar file in $CATALINA/lib,
everything else works the same.

Hope it helps you

-- brian

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Please help...

Posted by Brian Munroe <br...@gmail.com>.
On 9/1/07, Brian Munroe <br...@gmail.com> wrote:
> On 9/1/07, Hassan Schroeder <ha...@gmail.com> wrote:
>
> >
> > If you're talking about TC6, there is no common/lib or shared/lib;
> > $CATALINA_HOME/lib is correct...
> >
>
> Oh crap, I was going off my 5.5 install!
>

Hassan:

Ok, lend me a hand here, besides the incorrect statement about
common/lib, does everything else look fine?

-- brian

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Please help...

Posted by Brian Munroe <br...@gmail.com>.
On 9/1/07, Hassan Schroeder <ha...@gmail.com> wrote:

>
> If you're talking about TC6, there is no common/lib or shared/lib;
> $CATALINA_HOME/lib is correct...
>

Oh crap, I was going off my 5.5 install!

Thanks!

-- brian

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Please help...

Posted by Hassan Schroeder <ha...@gmail.com>.
On 9/1/07, Brian Munroe <br...@gmail.com> wrote:

> "For Tomcat 6

> You mention that it is located it $CATALINA_HOME/lib [sic] - which
> I'll assume is a typo, but it leads to ambiguity - did you mean
> common/lib or shared/lib?  Definitely move it to common/lib.

If you're talking about TC6, there is no common/lib or shared/lib;
$CATALINA_HOME/lib is correct...

-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Please help...

Posted by Brian Munroe <br...@gmail.com>.
On 8/31/07, Mike Cronin <mi...@fax.com> wrote:

> I am having a problem setting up a connection-pool via JNDI on Tomcat 6.0.14
> utilizing Oracle 10g. Currently I have a <Resource> for my DataSource
> referenced within a <Context> element within the server.xml file. The
> classes12.jar file which contains the Oracle Driver, exists within the
> $CATLINA-HOME/lib. I am able to successfully access my tables outside of the
> connection pool so I know that I am getting to the driver.

Mike:

First thing I can tell you, quoting directly from the Tomcat Docs:

"For Tomcat 6, unlike Tomcat 4.x, it is NOT recommended to place
<Context> elements directly in the server.xml file. This is because it
makes modifing the Context configuration more invasive since the main
conf/server.xml file cannot be reloaded without restarting Tomcat."

Now that I've said that, I'll admit I struggled with connection
pooling about a month ago.  My problem was that I was trying to place
the driver jar file in either shared/lib or WEB-INF/lib.  This was
incorrect and it needed to be in $CATALINA_HOME/common/lib, where
Tomcat could manage it.  If you read the classloader section on
tomcat.apache.org it will make sense why this is.

You mention that it is located it $CATALINA_HOME/lib [sic] - which
I'll assume is a typo, but it leads to ambiguity - did you mean
common/lib or shared/lib?  Definitely move it to common/lib.

After trying to get my JDBC resources to work in
<GlobalNamingResource> without much luck.  I ended up placing my
<Resource> definitions in META-INF/context.xml.  I don't know if you
are trying to define a global pool for all your applications or can
live with a local app configuration, I made due with a local
configuration.

Regardless, here is my "hello, world" recipe:

In META-INF/context.xml file:

<Resource name="jdbc/XEDB"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:ghg/ghg@//192.168.1.14:1521/XE"
maxActive="100"
maxIdle="30"
maxWait="10000"
removeAbandoned="true"
removeAbandonedTimeout="60"
logAbandoned="true"
/>

I didn't mess around with setting username and password attributes, I
just provided them within the connection URL.

Finally, in a JSP, I have the following code:

(mind you this is just a 'hello, world' - I'd never actually recommend
this in real life)

<jsp:directive.page import="javax.naming.*" />
<jsp:directive.page import="java.sql.*" />
<jsp:directive.page import="javax.sql.*" />

<%

InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup("java:comp/env/jdbc/XEDB");
Connection conn = ds.getConnection();

Statement s = conn.createStatement();

ResultSet rs = s.executeQuery("select * from hello");

while(rs.next()) {
    out.println(rs.getString(1) + "<br/>");
}

s.close();
conn.close();

%>

I deleted, for example, <resource-ref>'s, and basically returned
conf/server.xml and WEB-INF/web.xml back to stock, which I had mucked
up from trying things googling had suggested I try.

Hopefully this works for you too!

BTW, classes12.jar is designed for JDK 1.2 and 1.3.  From what you
mentioned, it is working just fine with your non-pooling code, but you
can download [1] a newer version (odbc14.jar comes with Oracle XE).

-- brian

[1] - http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/jdbc_10201.html

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org