Is Oracle driver (classes111.zip) visible to Tomcat.
I had to modify (in Linux) catalina.sh script to add driver's path to
the internal
CLASSPATH used by catalina.
Martin Miranda wrote:
>
> Hello
>
> Im having problems creating a DataSource in a StandAlone Tomcat 4.0.1
> with Windows XP. The InitialContext find the DataSource but it cames
> null
>
> This is the Code:
>
> <%
> InitialContext ctxinit = new InitialContext();
> %>
> <%= ctxinit.lookup("java:/comp/env/jdbc/testDB") %> << NULL
>
You get EnabledDataSource instance above so you have to cast.
May it's be better like this:
<% DataSource ds = (DataSource)
ctxinit.lookup("java:/comp/env/jdbc/testDB") %>
<%= ds %>
Also all examples doing this way:
Context ctx = new InitialContext();
Context envCtx = (Context)ctx.lookup("java:comp/env");
ds = (DataSource)envCtx.lookup("jdbc/testDB");
Try that just in case.
So your case must work!!
Though I don't advise you to use EnabledDataSource (Tyrex stuff) for
production - it doesn't provide
connection pool.
Use commons/dbcp.
I tested it - it works fine (besides Tomcat 4.0.4-b1 - nothing work
there).
> In the web application deployment descriptor (web.xml) i have this code:
>
> <resource-ref>
> <description>Resource reference to a factory for java.sql.Connection
> instances that may be used for talking to a particular database that is
> configured in the server.xml file.</description>
> <res-ref-name>jdbc/testDB</res-ref-name>
> <res-type>javax.sql.DataSource</res-type>
> <res-auth>Container</res-auth>
> </resource-ref>
>
> In the server.xml file:
>
> <Context path="/test" docBase="test/" debug="1" privileged="true"
> reloadable="true" useNaming="true">
>
> <Resource name="jdbc/testDB" auth="Container"
> type="javax.sql.DataSource" description="Default Database for
> Applications" />
>
> <ResourceParams name="jdbc/testDB">
> <parameter>
> <name>driverClassName</name>
> <value>oracle.jdbc.driver.OracleDriver</value>
> </parameter>
> <parameter>
> <name>driverName</name>
> <value>jdbc:oracle:thin:@dir</value>
> </parameter>
> <parameter>
> <name>user</name>
> <value>usuario1</value>
> </parameter>
> <parameter>
> <name>password</name>
> <value>password1</value>
> </parameter>
> </ResourceParams>
> </Context>
>
> When i use debug level 1 in the context the logs seems normal:
>
> XmlMapper: org.apache.catalina.core.StandardContext.setSessionTimeout(
> 30)
> XmlMapper: org.apache.catalina.core.StandardContext.addMimeMapping(
> html, text/html)
> XmlMapper: org.apache.catalina.core.StandardContext.addMimeMapping( txt,
> text/plain)
> XmlMapper: org.apache.catalina.core.StandardContext.addWelcomeFile(
> index.jsp)
> XmlMapper: org.apache.catalina.core.StandardContext.addWelcomeFile(
> index.html)
> XmlMapper: new null org.apache.catalina.deploy.ContextResource
> resource-ref ContextResource[name=null, scope=Shareable]
> XmlMapper: org.apache.catalina.deploy.ContextResource.setDescription(
> Resource reference to a factory for java.sql.Connection instances that
> may be used for talking to a particular database that is configured in
> the server.xml file.)
> XmlMapper: org.apache.catalina.deploy.ContextResource.setName(
> jdbc/testDB)
> 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/testDB, description=Resource reference to a
> factory for java.sql.Connection instances that may be used for talking
> to a particular database that is configured in the server.xml file.,
> type=javax.sql.DataSource, auth=Container, scope=Shareable]
> XmlMapper: pop resource-ref org.apache.catalina.deploy.ContextResource:
> ContextResource[name=jdbc/testDB, description=Resource reference to a
> factory for java.sql.Connection instances that may be used for talking
> to a particular database that is configured in the server.xml file.,
> type=javax.sql.DataSource, auth=Container, scope=Shareable]
>
>
>
> --
> To unsubscribe: <mailto:[EMAIL PROTECTED]>
> For additional commands: <mailto:[EMAIL PROTECTED]>
> Troubles with the list: <mailto:[EMAIL PROTECTED]>
--
Lev Assinovsky Peterlink Web
Programmer St. Petersburg, Russia
Tel/Fax: +7 812 3275343 197022 ul.Chapigina 7�
E-mail: [EMAIL PROTECTED]
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>