• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Deploying with context config file

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi people !

I am having difficulties with a supposedly simple task: I have a web application packed into a WAR file, and want to deploy it on our production server. The difficulty is that this application requires resources from the server (e.g. data source), which are defined in the context configuration files (conf/Catalina/... directory).
I could not find a simple way to deploy, and re-deploy the application, because at undeploying the context config file is removed, plus I found no way to specify the context config file at upload, and deploy.
Tried using the Manager application, ant tasks, so far no easy solutions.

Any suggestions, please ? Did I overlook something trivial ?

Thanks in advance:

-Gyula Klinszky
 
Gyula Klinszky
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hrm, no takers ?

I thought it was quite a common scenario, or is it just that the answer is so obvious ?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe you can specify the context fragment by putting it in your war's META-INF directory.

Also, the manager app has a field called "XML Configuration file URL". Did you try specifying it there?
 
Ranch Hand
Posts: 326
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A properly constructed war contains a context.xml in the META-INF directory. Tomcat, upon deployment, will copy the context.xml to conf and rename it to the name of the context.

Within the context.xml, define your datasource, then refer to it from the web.xml to expose it to the webapp.

Then, you can undeploy and redeploy and the datasource will be setup for you everytime.

in context.xml


in web.xml


in application
 
Gyula Klinszky
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the answers.
Yes, I was thinking about using the context.xml before, but shouldnt the site admin who installs the application provide these resources for the application instead of the application builder ? Meaning that the application builder possibly does not need to know the access data to e.g. the DB, just use it like in the example posted using JNDI, and the site admin could specify the installation's exact parameters.
Or is it too warped logic ?
 
Ray Stojonic
Ranch Hand
Posts: 326
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure, I'd guess that's the idea behind having the context.xml.

Let's say you've finished the app, and the admin has deployed it. The admin would have a copy of the war file. If the database information changed, the admin could: expand the war, edit the context.xml, recompress it and redeploy it with almost no effort.
 
Gyula Klinszky
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, makes sense i guess. Thanks for the replies !
 
I am mighty! And this is a mighty small ad:
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!