Here is my config to get a JNDI datasource. It works for me but I am
not sure if all of it is actually required.
***context.xml***
<Context path="/" docBase="root">
<ResourceLink name="jdbc/ssdb" type="javax.sql.DataSource"
global="jdbc/ssdb"/>
</Context>
***web.xml snippet from inside <web-app>***
<resource-ref>
<description>Connection Pool</description>
<res-ref-name>jdbc/ssdb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
***server.xml snippetr from inside <GlobalNamingResources>***
<Resource
name="jdbc/ssdb"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
password="password"
maxIdle="5"
maxWait="3000"
username="username"
url="jdbc:oracle:thin:@192.168.0.1:1521:ssdb"
maxActive="50"/>
Matt
-----Original Message-----
From: David Tonhofer, m-plify S.A. [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 10, 2005 6:21 AM
To: [email protected]
Subject: Tomcat 5.5.7. server.xml doc may be buggy...is it bugzilla
time?
Hello,
Question regarding Tomcat 5.5.7 and the JNDI Datasource:
It seems like either the web documentation for Tomcat 5.5 or the
implementation is incorrect regarding the use of JNDI Datasources.
In this page:
<http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-example
s-howto.html>
the "Resource" element configuring the DataSource is put inside the
"Context" element.
However, I have tried to set up a DataSourceRealm that is configured
using said "Resource"
00>Exception performing authentication
01> **** javax.naming.NameNotFoundException: Name jdbc is not bound in
01> this Context
02> **** at
org.apache.naming.NamingContext.lookup(NamingContext.java:769)
03> **** at
org.apache.naming.NamingContext.lookup(NamingContext.java:152)
04> **** at
org.apache.catalina.realm.DataSourceRealm.open(DataSourceRealm.java:406)
05> **** at
org.apache.catalina.realm.DataSourceRealm.authenticate(DataSourceRealm.j
ava:277)
06> **** at
org.apache.catalina.authenticator.BasicAuthenticator.authenticate(BasicA
uthenticator.java:181)
07> **** at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authenticator
Base.java:446)
08> **** at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
:126)
09> **** at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
:105)
10> **** at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.
java:107)
11> **** at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:1
48)
12> **** at
org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:306)
13> **** at
org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:385)
14> **** at
org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:745)
15> **** at
org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:
675)
16> **** at
org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:868)
17> **** at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool
java:684)
18> **** at java.lang.Thread.run(Thread.java:595)
Out of luck? Bugs related to other Tomcat versions helped out:
<http://issues.apache.org/bugzilla/show_bug.cgi?id=24723>
<http://issues.apache.org/bugzilla/show_bug.cgi?id=24836>
I put the "Resource" element inside the "GlobalNamingResources" element,
described here:
<http://jakarta.apache.org/tomcat/tomcat-5.5-doc/config/globalresources.
html>
..and it worked!
Maybe the documentation should tell people to set up the "Resources" in
the "GlobalNamingResources"? Probably not though -- there might be some
other reason why it didn't work. I tried "useNaming=true" for the
"Context" according to
<http://jakarta.apache.org/tomcat/tomcat-5.5-doc/config/context.html>
but no go :-((
Additionally:
The 'factory' attribute of the 'Resource' element is mentioned
nowhere... o_O which is **BAD** because w/o the factory value the Realm
Authentication seems to reduce to 'Access All Areas' - you don't get no
error in the catalina log either.
<Resource name="jdbc/lousydatabase"
auth="Container"
type="javax.sql.DataSource"
HERE ---->
factory="org.apache.commons.dbcp.BasicDataSourceFactory"
driverClassName="com.mysql.jdbc.Driver"
validationQuery="SELECT 1"
loginTimeout="10"
username="waateenbordel"
password="tudjeu!!"
testOnBorrow="true"
url="jdbc:mysql://127.0.0.1/lousy?autoReconnect=true&connectTimeout=
5000&socketTimeout=30000&useUsageAdvisor=true"
/>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]