• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

JNDI with Tomcat

 
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can some one please tell me how to config tomcat 5.5 or 6 (with eclipse dynamic web project) for use JNDI look ups.

I have gone throgh some articles but didnt help me.

in this site webpage i have found this,



and in here ,




why type attribute mentioned in two diferent ways..

Thank You.

 
Saloon Keeper
Posts: 28392
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The "type" is the classname of the DataSource class that will be instantiated by Tomcat when the resource is created. One is the generic DataSource, one is an Oracle-specific one, and if you'll notice, there's also a factory classname given for that one, meaning that Tomcat will use the factory instead of simply constructing the Oracle DataSource using "newInstance()".

WebSphere also has one or 2 vendor-specific datasource classes, and I'm sure that there a quite a few others out there as well. The ability to specify a custom DataSource type allows you to take advantage of DataSources whose capabilities maximize vendor-specific advantages of a particular DBMS. In particular, you might expect to find both XA and non-XA type datasources available.
 
Harshana Dias
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank You Tim for the answer. by the way if you mind can you specify what steps actually need to configure tomcat successfully with JNDI. I have try several ways but end up with "Cannot get connection: javax.naming.NameNotFoundException: Name xyz is not bound in this Context"

I have found tomcat web site article bit complex and more steps than this article. I hope the latter article also correct right..but it didnt work..but i think that article didnt explain it with eclipse because it says "Add the below webapps/jdbc/META-INF/context.xml file" where i dont find a context.xml file under WebContent/META-INF in eclipse project file structure. can you please answer.

Thank You.
 
Tim Holloway
Saloon Keeper
Posts: 28392
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another reason why we're not real excited when people use an IDE to build their projects. An IDE can be a big assist, but it's no substitute for actually knowing what's going on.

Every deployed Tomcat webapp has a context. The context defines the base URL for the app, where to find the application's codebase, and additional defined resources, if/as needed, including the Connection Pool (DataSource) definition. If you don't explictly define a context, one will be created for any WAR found in the TOMCAT_HOME/webapps directory, where the context name will be "warname" and the codeBase will be "TOMCAT_HOME/webapps/warname" or "TOMCAT_HOME/webapps/warname.war", depending on whether or not the WAR is exploded.

You can define a context yourself and put it in one of 3 places.

1. As a file named "context.xml" in the META-INF directory of your WAR.

2. As a file whose extension is ".xml" in the TOMCAT_HOME/conf/Catalina/localhost directory (will override #1).

3. As an XML entry in the TOMCAT_HOME/conf/server.xml file (But please don't do this!).

The full documentation on the format of the Context element and its children is on the Tomcat documentation site. Your DataSource definition would be one of those children.
 
Harshana Dias
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank Tim..i have successfuly did it..
one question please..now what i did was adding <Resource> in context.xml in tomcat (under eclipse) and add <resource-ref> for web..xml in my project....But is there a way to do all settings in server not in project web.xml..i mean the <resource-ref>.. i know its stupid question but there is a project that existing code should not touch..so try to minimize the changes in web.xml..you got the point sir..
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic