• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

adding a Datasource to tomcat jndi

 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is i got error

here is my context.xml in tomcat/conf



here is my server.xml


here is my application code
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should only put the datasource in server.xml if you intend to make it available to multiple webapps as a common definition. Otherwise, set up a context xml file in CATALINA_HOME/conf/Catalina/localhost for the specific webapp that uses it. Alternatively, you can create a META-INF/context.xml file and store it in your WAR.

Here's one I have embedded in an application Context:


I have a web.xml entry to go with it - and that may be what you're missing.


I then use the JDNI key java:/comp/env/jdbc/myDS to locate it.
 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here i change my project as below.now my classes are like these.

web.xml file in my application.



Server.xml file at tomcat/conf


context.xml at tomcat/conf



The error i got
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You did not specify a context path or docBase in your Context xml file. Without them, there's no way for the server to match a specific webapp with a specific context definition.
 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you please tell me the what should i include in context file.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This will make the web application "myapp" be addressable by the URL http://myserver/myapp and use the exploded WAR directory /home/timh/workspace/myapp/target/myapp
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic