• 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

Error confguring multiple contexts/data sources in Tomcat 5

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello

I am using Tomcat 5.5.27. I have two web applications- App1 and App2. Below are some details-

  • App1 Data Source JNDI name - jdbc/DW_Pool
  • App1 web context name - tdwebapps
  • App2 Data Source JNDI name - jdbc/SQLPool_DW
  • App2 web context name - tdreports


  • My context.xml and server.xml are given at the end of this post.

    When I start Tomcat with these configurations and try to access my application, I see the following error in the log-

    Aug 25, 2009 10:14:12 PM org.eclipse.birt.report.data.oda.jdbc.JndiDataSource getConnection
    INFO: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
    Aug 25, 2009 10:14:12 PM org.eclipse.birt.data.engine.odaconsumer.ConnectionManager openConnection
    SEVERE: Cannot open connection.


    My questions are-
    1) Where am I going wrong? How to get rid of this exception?
    2) I referred to the Tomcat config documentation given at- http://tomcat.apache.org/tomcat-5.5-doc/config/index.html
    However, I have not been able to understand the significance of Context.xml file exactly. If we can configure contrexts, resources etc. in server.xml file, what purpose does the Context.xml file serve?

    My Context.xml file-


    My server.xml file-


     
    Saloon Keeper
    Posts: 28398
    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
    Context.xml allows you to define the context for a single webapp in a discrete file. Effectively, all the context files are merged into server.xml. But by physically separating them, you can redeploy a single webapp without changing server.xml itself, which would require restarting the entire server.

    As a fat-fingered user type, there's another benefit. If you damage server.xml, the entire Tomcat server may become unusable. So by editing only a single context file, you only put that particular webapp at risk.

    Use of a separate context file became the preferred way to define a webapp context starting in Tomcat 4 and continuing to the present day. You can also include a copy of the context as META-INF/context.xml (I may have that mis-capitalized) in your WAR, which allows you to make "drag and drop" WARs complete with JNDI and other container definitions that normally would be external to the war.
     
    Neelesh A Korade
    Greenhorn
    Posts: 26
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thank you Tim. That was helpful.

    Could someone help me out with the data source lookup exception I am seeing?
     
    Tim Holloway
    Saloon Keeper
    Posts: 28398
    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
    I didn't see anything obvious, although if you define it twice (once in context and once globally), that might cause problems.

    The only other thing is that you also have to define the resource in web.xml, if I'm not mistaken:

     
    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