• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Datasource configuration in Tomcat

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I am trying to configure the Datasource in Tomcat 6.0 using a context.xml file.
I am using Oracle 10g as Database.
I have placed the below changes inside /META-INF/context.xml

<Context>
<Resource auth="Container" name="jdbc/loginApp" type="javax.sql.DataSource"
description="Login Application" driverClassName="oracle.jdbc.OracleDriver"
maxActive="100" maxIdle="10" maxWait="10000" password="l0g1napp"
url="jdbc:oracle:thin:@localhost:1521:xe" username="loginapp" />
</Context>

In My application, I am trying to do lookup using the below code for lookup name as "loginApp".


Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:/comp/env");
DataSource ds = (DataSource) envContext.lookup("jdbc/" + streamName);

But, When I run the application, I get the below error

java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
at com.myapp.Utilities.Datastreams.getConnection(Datastreams.java:16)
at com.myapp.Controller.LoginController.ValidateLogin(LoginController.java:68)
at com.myapp.Controller.LoginController.doPost(LoginController.java:49)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

What more configurations should I follow such that my application picks up the context.xml. Should I add any reference to context.xml in my Web.xml?

-Regards
Srikant Mantha
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to add the Oracle driver JAR file in either your application's lib folder, or in Tomcat's lib folder.
 
Srikant Venkata
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, It works now when I added the jar file in Tomcat Server Libs. Earlier I had added only to the Application's Build path.

-Regards
Srikant Mantha
 
Rob Spoor
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic