Thanks, but i followed the examples on the tomcat site. I have removed the factory declaration from server.xml but this still doesnt help I'm still getting a Cannot create resource instance error, i have pasted the stack dump to offer more clarity.

Cheers,

Natasha
STACK DUMP
-----------
Error naming exception:
javax.naming.NamingException: Cannot create resource instance
at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:142) at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:787)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:134)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:775)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:147)
        at servlet.openConnection(Unknown Source)
        at servlet.init(Unknown Source)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:888) at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:621) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:163) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152) at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:300) at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:374) at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:743) at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:675) at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:866) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
        at java.lang.Thread.run(Thread.java:539)
Cannot create resource instance









David Smith wrote:

Then I would point you to

http://tomcat.apache.org/tomcat-4.1-doc/jndi-resources-howto.html
and
http://tomcat.apache.org/tomcat-4.1-doc/jndi-datasource-examples-howto.html

for some excellent information on setting up this stuff. I don't think you have to spec a resource factory as the built-in one for datasources is a slightly refactored (package rename only) version of DBCP. Also, the JDBC driver needs to be stored in common/lib of the tomcat installation. Lastly, unless you are directly using the commons-dbcp package or the commons-pool package in your code, the commons-dbcp-xx.xx.jar and commons-pool.jar are not necessary in WEB-INF.

--David

Natasha N Wright wrote:

I am using Tomcat version 4. with JDK 1.4 (quite old i know!)

David Smith wrote:

Before we can offer any relevant advice, please let us know which version of tomcat you are working with. There are configuration differences between 5.0.x and 5.5.x.

--David

Natasha N Wright wrote:

Hi,

I am trying to create a servlet which connects to a oracle database. My servlet is called from an HTML form. When it is called i recieve a javax naming exception Cannot create resource instance error. Please can someone advise me what I need to configure? I get no tomcat errors on startup.
Thankyou

i am calling the db connection with the following java:
---------------------------------
Context initial = new InitialContext();
Context envContext = (Context)initial.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/maindb");
tcon = ds.getConnection();

server.xml (within <context>)
--------------------------
<Resource name="jdbc/maindb" auth="Container" type="javax.sql.DataSource" />
 <ResourceParams name="jdbc/maindb">
<parameter>
    <name>driverClassName</name>
    <value>oracle.jdbc.driver.OracleDriver</value>
</parameter>
<parameter>
    <name>factory</name>
    <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
    <name>url</name>
    <value>jdbc:oracle:[EMAIL PROTECTED]:1512:maindb</value>
</parameter>
<parameter>
    <name>user</name>
    <value>nnw03u</value>
</parameter>
<parameter>
    <name>password</name>
    <value>******</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>

web.xml
------------------
<resource-ref>
    <res-ref-name>jdbc/maindb</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

Jar files in WEB-INF/lib
---------------------------
classes12.jar
jasper-compiler.jar
commons-collections-3.1.jar
jasper-runtime.jar
commons-dbcp-1.2.1.jar
jsp-api.jar
commons-dbcp-1.2.jar mysql-connector-java-3.1.8-bin.jar
commons-el.jar
naming-factory-dbcp.jar
commons-pool-1.3.jar
naming-java.jar
jasper-compiler-jdt.jar

This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.




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



This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.


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

Reply via email to