You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Parsons Technical Services <pa...@earthlink.net> on 2005/02/01 05:23:22 UTC

Re: Tomcat datasource not persisting across restarts

Johnny wrote:
> I'm confused by this. First, I found that to get the datasource to work at 
> all
> I had to use a context file with a docbase pointing to an exploded war 
> file
> rather than just installing a complete war file into Tomcat's webapps
> directory. Thinking that there might be other such occasions coming up, I
> invented a directory outside of the Tomcat tree to hold such context files 
> and
> exploded wars and chose /usr/local/webapps for that directory. My current
> application, APLRegistration, appears there, in the subdirectory
> aplregistration. In this location I have my context file and also the
> exploded war file in a directory named 'exploded'. I.e.,
>
> /usr/local/webapps/
>    aplregistration/
>        context.xml
>        exploded/
>            <a bunch of jsp files>
>            WEB-INF/
>               etc.
>
> That's why the context file points to that exploded directory. I tried
> your suggestion, but the app wouldn't work at all then.
>
> This brings up a more general question. Is there a way to use global
> datasources with just a war file? After several failed attempts, I finally 
> hit
> upon the scheme of using an exploded war file and a context file with the
> <ResourceLink> tag. I deploy using the web app manager page and giving
> a file: URL pointing to the context file.
>
> But this sounds crazy! Surely there should be some way to just deploy a 
> war
> file and still use a global datasource. But how?
>

Now I understand what you had done. And yes, you can just deploy the war 
file and use Global, I do it all the time.

First: For this to work the context.xml for you app must reside in the 
META-INF folder in the war. You should be able to create/edit it from the 
IDE.

Second: The doc base should point to the root of your app. Just make sure 
that the user Tomcat is running as, has full rights to that directory. 
Tomcat has to delete the files and folders during a deploy/redeploy.

docBase="/usr/local/webapps/aplregistration"

I went down one too many.

Third: The war is placed in "tomcathome"/webapps.

I believe what is causing you grief is the placement of you context.xml. 
During a restart Tomcat is not reading the file and thus not linking the 
resource. On a deploy you are pointing to the file and thus Tomcat is 
reading it. The app works otherwise during a restart based on the default 
context.

Don't sweat the web.xml entry. It is for container portability. I was basing 
it on the examples and it is possible they are wrong. For Tomcat it will 
work without the web.xml entry. According to the docs.

Doug




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org