Change the parameter name driverName to url
<parameter>
<name>url</name>
<value>jdbc:oracle:thin:@<ip>:1521:SID</value>
</parameter>
Manavendra Gupta wrote:
Hey Gurus,
any ideas what could be the problem? following are the settings (revised):
server.xml:
<Context path="/rti" docBase="rti" debug="4" reloadable="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="rti_log." suffix=".txt" timestamp="true" />
<Resource name="jdbc/rtidb" auth="CONTAINER" type="javax.sql.DataSource"
/>
<ResourceParams name="jdbc/rtidb">
<parameter> <name>user</name> <value>rti</value> </parameter>
<parameter><name>password</name><value>rti</value> </parameter>
<parameter> <name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value> </parameter>
<parameter><name>driverName</name>
<value>jdbc:oracle:thin:@rti:1521:rti</value></parameter>
</ResourceParams>
</Context>
web.xml:
<web-app>
........
<resource-ref>
<res-ref-name>jdbc/rtidb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
test.java
Context ctx = new InitialContext();
if(ctx == null )
throw new Exception("Boom - No Context");
Context envCtx = (Context) ctx.lookup("java:comp/env");
DataSource ds = (DataSource)envCtx.lookup("jdbc/rtidb");
System.out.println("DataSource: " + ds);
if (ds != null) {
Connection conn = ds.getConnection();
}
-> DataSource is always null.
(excerpt) thread dump of catalina:
XmlMapper: org.apache.catalina.deploy.ContextResource.setName( jdbc/rtidb)
XmlMapper: org.apache.catalina.deploy.ContextResource.setType(
javax.sql.DataSource)
XmlMapper: org.apache.catalina.deploy.ContextResource.setAuth( Container)
XmlMapper: Calling org.apache.catalina.core.StandardContext.addResource
ContextResource[name=jdbc/rtidb, type=javax.sql.DataSource, auth=Container,
scope=Shareable]
XmlMapper: pop resource-ref org.apache.catalina.deploy.ContextResource:
ContextResource[name=jdbc/rtidb, type=javax.sql.DataSource, auth=Container,
scope=Shareable]
Any clues?
TIA,
Manav.
----- Original Message -----
From: "Manavendra Gupta" <[EMAIL PROTECTED]>
To: "Manavendra Gupta" <[EMAIL PROTECTED]>
Sent: Wednesday, November 20, 2002 5:50 AM
Subject: Re: Oracle thin client DataSource configuration with tomcat
Sorry, forgot to attach the thread dump...
Thanks
manav
===========
javax.naming.NameNotFoundException: Name java:comp is not bound in this
Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:811)
at org.apache.naming.NamingContext.lookup(NamingContext.java:194)
at tmp.DBTest.init(DBTest.java:20)
at org.apache.jsp.test$jsp._jspService(test$jsp.java:60)
at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspSe
vlet.java:202)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:
82)
at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(App
icationFilterChain.java:247)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(Application
ilterChain.java:193)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapper
alve.java:243)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipelin
.java:566)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.ja
a:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContext
alve.java:201)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipelin
.java:566)
at
org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValv
.java:246)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipelin
.java:564)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.ja
a:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943
at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java
2344)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.
ava:164)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipelin
.java:566)
at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatch
rValve.java:170)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipelin
.java:564)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.
ava:170)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipelin
.java:564)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java
462)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipelin
.java:564)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.ja
a:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVa
ve.java:163)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipelin
.java:566)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.ja
a:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943
at
org.apache.catalina.connector.http.HttpProcessor.process(HttpProcess
r.java:1011)
at
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.j
va:1106)
at java.lang.Thread.run(Thread.java:536)
----- Original Message -----
From: "Manavendra Gupta" <[EMAIL PROTECTED]>
To: "Joel Sather" <[EMAIL PROTECTED]>
Sent: Wednesday, November 20, 2002 5:49 AM
Subject: Re: Oracle thin client DataSource configuration with tomcat
Hi,
Please find attached server.xml, web.xml, test.jsp and DBTest.java
...see
if
you can find something.
Thanks,
Manav.
----- Original Message -----
From: "Joel Sather" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, November 18, 2002 11:20 PM
Subject: Re: Oracle thin client DataSource configuration with tomcat
Just out of curiosity, but you do have direct connections working,
right? By this I mean building a JSP or servlet to access the
database
through normal JDBC calls vs. using the JNDI calls. Also, look in
your
log files to see if there are any additional messages (e.g. driver not
found, etc.). Let me know what you find. If it isn't an underlying
JDBC/driver problem, send me your server.xml and I can take a look.
-Joel
Joel Sather
email: [EMAIL PROTECTED]
phone: 651-649-5789
"Manavendra Gupta" <[EMAIL PROTECTED]> 11/18/02 11:18AM >>>
Hi,
Sorry to disturb you again, but I tried that too, but it doesn't work.
Could
you provide any clues/links on this?
Thanks,
Manav.
----- Original Message -----
From: "Joel Sather" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, November 18, 2002 10:05 PM
Subject: Re: Oracle thin client DataSource configuration with tomcat
Well this is what mine looks like in server.xml:
<DefaultContext debug="0" reloadable="true">
<Resource name="jdbc/MyDB" auth="CONTAINER"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/MyDB">
<parameter><name>user</name><value>username</value></parameter>
<parameter><name>password</name><value>password</value></parameter>
<parameter><name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value></parameter>
<parameter><name>driverName</name>
<value>jdbc:oracle:thin:@dbhostname:1521:DBNAME</value></parameter>
</ResourceParams>
</DefaultContext>
I place mine into the DefaultContext so that it is available to all
applications, but if you specify Contexts you can just place it
directly
there.
-Joel
Joel Sather
email: [EMAIL PROTECTED]
phone: 651-649-5789
"Manavendra Gupta" <[EMAIL PROTECTED]> 11/18/02 10:33AM >>>
Hi, thanks for the reply.
I'm not sure what you were trying to point out, but following is
what
i
could discern from the document:
1. Install driver - copy classesXXX.zip as classesXXX.jar to
$CATALINA_HOME/common/lib
2. declare resource requirements - update web.xml to have the
resource
references.
3. code the application usage - test JSP page accessing the
DataSource
4. configure tomcat's resource directory - update server.xml file.
The only change I did now was to ensure that my server.xml had :
<parameter>
<name>driverClassName</name>
<value>oracle.driver.OracleDriver</value>
</parameter>
<parameter>
<name>driverName</name>
<value>jdbc:oracle:thin:rti/rti@rti:1521:rti</value>
</parameter>
<parameter>
<name>URL</name>
<value>jdbc:oracle:thin:rti/rti@rti:1521:rti</value>
</parameter>
Doesn't work still.I tried with removing the "URL" section too.
What am i missing?
TIA,
Manav.
----- Original Message -----
From: "Joel Sather" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, November 18, 2002 8:58 PM
Subject: Re: Oracle thin client DataSource configuration with tomcat
Not sure if this is the answer to your problem so I'm not sending
this
to the list. You might want to check this:
http://jakarta.apache.org/tomcat/tomcat-4.0-doc/jndi-resources-howto.html
The JDBC JNDI configuration between the 4.0.X and 4.1.X series is
quite
different--you are using the 4.1.X configuration on an 4.0.X
server.
It
is basically URL should be driverName. Also you shouldn't need
anything
in your web.xml.
-Joel
Joel Sather
email: [EMAIL PROTECTED]
phone: 651-649-5789
[EMAIL PROTECTED] 11/18/02 09:29AM >>>
Hi,
I'm sure the gurus have discussed this issue a number of times and
probably
found a solution too, but after reading all the documents i found,
i
came to
a naught.
Its the same problem: server.xml and web.xml seem to have been
configured
properly, yet when i try to obtain a datasource i get nothing.
Here's the scenario:
setup: tomcat 4.0.3 LE, jdk1.4, RHL 7.3
server.xml
<!-- RTI Billing Context -->
<Context path="/rti" docBase="rti" debug="0"
reloadable="true" crossContext="true">
<Logger
className="org.apache.catalina.logger.FileLogger"
prefix="rti_log." suffix=".txt"
timestamp="true"/>
<Resource name="jdbc/RtiDB" auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/RtiDB">
<parameter>
<name>user</name>
<value>rti</value>
</parameter>
<parameter>
<name>password</name>
<value>rti</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>oracle.driver.OracleDriver</value>
</parameter>
<parameter>
<name>URL</name>
<value>jdbc:odbc:thin:@rti:1521:rti?user=rti;password=rti</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>20</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>10</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>-1</value>
</parameter>
</ResourceParams>
</Context>
web.xml
<!-- Resource references -->
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/RtiDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
DBTest.jsp
<%
String foo = "Not Connected";
String bar = "";
javax.naming.Context ctx = new javax.naming.InitialContext();
javax.naming.Context envCtx = (javax.naming.Context)
ctx.lookup("java:comp/env");
if(ctx == null )
throw new Exception("Boom - No Context");
javax.sql.DataSource ds =
(javax.sql.DataSource)envCtx.lookup("jdbc/RtiDB");
if (ds != null) {
java.sql.Connection conn = ds.getConnection();
out.println("got a connection");
}
out.println("no luck yet");
%>
And I never get the message "got a connection". Any clues?
Btw, I have not touched the "Realm" - I don't understand what that
is
meant
for. Not yet.
TIA,
Manav.
--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>