File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javax.naming.NamingException- Cannot create resource instance

 
Ravikumar Jambunathan
Ranch Hand
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings,
i am getting this exception while i am trying to connect oracle database thru JNDI. The oracle jdbc driver is availavle in %CATALINA-HOME/common/lib as well as in my application context directory under WEB-INF(/lib).
I have given below my codings for reference.
This is my context in server.xml.
<!-- MyServlets Context-->
<Context path="/MyServlets" docBase="MyServlets" debug="0"
reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_MyServlets_log." suffix=".txt"
timestamp="true"/>
<Resource name="jdbc/test" auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/test">
<parameter><name>user</name><value>scott</value></parameter>
<parameter><name>password</name><value>tiger</value></parameter>
<parameter><name>driverClassName</name>
<value>jdbc racle:thin:@localhost:1521:test</value></parameter>
<parameter><name>driverName</name>
<value>oracle.jdbc.driver.OracleDriver</value></parameter>
</ResourceParams>
</Context>
<!-- End of MyServlets Context -->
My application web.xml.
<resource-ref>
<res-ref-name>jdbc/test</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
and this is my JDBC connection part of my code,
try{
InitialContext ctx= new InitialContext();
DataSource ds=(DataSource) ctx.lookup("java:comp/env/jdbc/test");
conn=ds.getConnection();
}
anybody could help me out to solve this problem?.
thanks in advance.
regards,
ravi.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
value tag jdbc racle:thin:@localhost:1521:test
i feel it should be
"jdbc: oracle:thin:@localhost:1521:test"
[ August 29, 2003: Message edited by: Pradeep Bhat ]
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pradeep, he probably only forgot to check the "disable smilies in this post" checkbox...
 
Ravikumar Jambunathan
Ranch Hand
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks pradeep for your reply,
for your info, it is only a spelling mistake while editing my post, sorry for that.The url is given correctly as you said.
expecting your suggestions.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try adding a resource factory parameter (just guessing here...) as follows:

[ August 29, 2003: Message edited by: Lasse Koskela ]
 
Ravikumar Jambunathan
Ranch Hand
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks lasse,
i tried out by adding the factory parameter as you suggested, but the server could not find the resource factory. The state of exception is,
javax.naming.NamingException- Could not create resource factory ClassNotFoundException.
i have taken out oracleDriver.class by unzipping classes12.zip and converted it into a jar file, since tomcat does not load zip files. Is that the right way? or
Is there anything related to classpath settings?
awating your reply,
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i tried out by adding the factory parameter as you suggested, but the server could not find the resource factory. The state of exception is,
javax.naming.NamingException- Could not create resource factory ClassNotFoundException.

Didn't the stack trace indicate which class was not found? If it's the commons resource factory class that's missing, then you must be running Tomcat 3.x? I assumed that you're using 4.x when suggesting the factory class entry... Then again, if it's the Oracle driver class that's missing, you need to put classes12.zip into "TOMCAT_HOME/lib" or "WEB-INF/lib".
i have taken out oracleDriver.class by unzipping classes12.zip and converted it into a jar file, since tomcat does not load zip files.

I haven't heard of this before. A .jar file is basically a .zip file which includes a META-INF/MANIFEST.MF file and the manifest file doesn't need to contain anything special so most products read .zip files just as well as .jar files.
 
Ravikumar Jambunathan
Ranch Hand
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
quote:
---------------------------------------------------------------------------
I haven't heard of this before. A .jar file is basically a .zip file which includes a META-INF/MANIFEST.MF file and the manifest file doesn't need to contain anything special so most products read .zip files just as well as .jar files.
---------------------------------------------------------------------------
Lasse, for your information i have given these few lines from tamcat-docs(jndi-datasource-howto.html availbale in TOMCAT-HOME/tomcat-docs)and that is why i decided to convert the zip files into jar files.
" Firstly by default, Tomcat will only use *.jar files installed in $CATALINA_HOME/common/lib therefore classes111.zip or classes12.zip will need to be renamed with a .jar extension. Since jarfiles are zipfiles, there is no need to unzip and jar these files - a simple rename will suffice. Also, you should be aware that some (early) versions of Tomcat 4.0 when used with JDK 1.4 will not load classes12.zip unless you unzip the file, remove the javax.sql.* class heirarchy and rejar."
and in the tomcat docs itself they have mentioned only jar files.
http://jakarta.apache.org/tomcat/tomcat-4.0-doc/jndi-resources-howto.html
and yes i am using tomcat4.1 as well.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic