• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[Tomcat] Dynamic Context?

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Recently, I've changed the way I do development with Tomcat a bit. I used to write Ant deploy/undeploy/redeploy tasks and those worked great. What stunk was when I was stuck doing a bunch of JSP work and having to do a redeploy for every little CSS/Javascript change.

What I do now, is I create a context that points to my working project which is layed out just like a real deployed application. Works great with the context reloadable set to true. Problem is that when I start working on a different project, I have to go comment the context and create or uncomment the other one.

Is there anyway that I can tell tomcat to use a context on startup or something so I don't have to keep editing my server.xml? Utalizing the tomcat/conf/catalina/localhost/appname.xml context file doesn't help either. I have to go rename the context's that I want Tomcat to ignore and then rename the one I want Tomcat to load.

Thanks.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not quite following. What prevents you from having multiple contexts, each with their own context xml file, and all laid out in the way you describe?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You shouldn't have to edit server.xml at all.
Starting with version 5, Tomcat supports context fragment files which are just the context tag stored in a file named after your application.
These files are stored in {tomcat-install}/conf/Catalina/localhost.

If you remove this file for a particular application, Tomcat will undeploy that app. Likewise, putting it back, will re-deploy it.
[ December 18, 2006: Message edited by: Ben Souther ]
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
I'm not quite following. What prevents you from having multiple contexts, each with their own context xml file, and all laid out in the way you describe?


Nothing, except I don't need to load 5 applications while I am working on one. You know, memory usage and all. ;)
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ben Souther:
You shouldn't have to edit server.xml at all.
Starting with version 5, Tomcat supports context fragment files which are just the context tag stored in a file named after your application.
These files are stored in {tomcat-install}/conf/Catalina/localhost.

If you remove this file for a particular application, Tomcat will undeploy that app. Likewise, putting it back, will re-deploy it.

[ December 18, 2006: Message edited by: Ben Souther ]



Originally posted by Gregg Bolinger:
Utalizing the tomcat/conf/catalina/localhost/appname.xml context file doesn't help either. I have to go rename the context's that I want Tomcat to ignore and then rename the one I want Tomcat to load.


which I suppose I could create a script to do this and launch Tomcat, thus creating a dynamic context loader, in a sense. Just thought there might be something a bit more built in.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Missed that, sorry
[ December 18, 2006: Message edited by: Ben Souther ]
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would still like to be able to load a context or specify a context at runtime with Tomcat. I know that has to be possible because when you use Intellij's IDEA webapp deployment features, I believe it does this with the exploded directory for your webapp.

So if anyone has any ideas...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic