this error appear by 2 reason, your datasource resource configuration unregistered in tomcat container and the datasource name you invoked in code not found in tomcat container.
one of solution to solve this is:
1. please register your datasource resource inside <context> attribute on /conf/server.xml file
<services>
...
<engine>
...
<host>
<context>
for example here I have
- web app context name: myApp
- JNDI datasource name: jdbc/myAppDB
- jdbc driver : for oracle compliant: oracle.jdbc.OracleDriver
- db running at: localhost
<context path="/myApp" workdir="D:\apache-tomcat-5.5.20/webapps/myApp">
<resource auth="Container" name="jdbc/myAppDB" type="javax.sql.DataSource" driverclassname="oracle.jdbc.OracleDriver" password="passuserdb1" maxidle="2" maxwait="5000" validationquery="SELECT 1 FROM DUAL" username="userdb1" url="jdbc:oracle:thin:@localhost:1521:myappdb" maxactive="500">
</resource></context>
and dont forget to regestering the above resource name on your application descriptor /myApp/WEB-INF/web.xml
look like:
<resource-ref>
<description>Oracle Datasource</description>
<res-ref-name>jdbc/myAppDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Saturday, September 29, 2007
when u find out an error Cannot create JDBC driver of class '' for connect URL 'null' running on tomcat
Posted by
hira.sirojudin
at
1:01 AM
Friday, September 28, 2007
when u find out an error Cannot load JDBC driver class 'oracle.jdbc.OracleDriver' in tomcat web application container
you can solve this error doing the following steps:
1. download the oracle driver appropriately when you have not the driver
2. copy the driver at ${CATALINA_HOME}/common/lib
3. (optional) remove any oracle driver which placed in web application classpath (yourAppContext/WEB-INF/lib)
4. running tomcat
Posted by
hira.sirojudin
at
11:58 PM
Subscribe to:
Posts (Atom)
