aspose file tools*
The moose likes Tomcat and the fly likes adding a Datasource to tomcat jndi Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "adding a Datasource to tomcat jndi" Watch "adding a Datasource to tomcat jndi" New topic
Author

adding a Datasource to tomcat jndi

sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1194
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

Joined: Jun 25, 2001
Posts: 16134
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1194
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

Joined: Jun 25, 2001
Posts: 16134
    
  21

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

Joined: Nov 25, 2008
Posts: 1194
can you please tell me the what should i include in context file.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16134
    
  21



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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: adding a Datasource to tomcat jndi