• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Web applications only deployed after restart of tomcat

 
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

I've configured Tomcat (5.5 on Gentoo) to allow per user web applications in ~user/public_html with the following additional listener in the server.xml config:

<Host
appBase="webapps"
name="localhost" unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">

<Listener className="org.apache.catalina.startup.UserConfig"
directoryName="public_html"
userClass="org.apache.catalina.startup.PasswdUserDatabase"/>
.....
</Host>

So far everything is working fine except applications aren't auto deployed or undeployed by tomcat! I've tried this with unpacked web applications and .WAR files but no applications are deployed or undeployed without restarting Tomcat.

After all information i found on the web i'm unsure if auto deployment in userdirs is even possible. Does anyone know how to fix this problem so i don't have to restart the server everytime i make changes to my applications under ~user/public_html/... ?

Thanks a lot!

Marco
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see the autoDeploy attribute in the Host entry that you posted.
Did you try setting that?

From: http://tomcat.apache.org/tomcat-5.5-doc/config/host.html


autoDeploy

This flag value indicates if new web applications, dropped in to the appBase directory while Tomcat is running, should be automatically deployed. The flag's value defaults to true. See Automatic Application Deployment for more information.



 
Marco Ehrentreich
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for this hint Ben, but i actually can see the autoDeploy attribute in my post


<Host
appBase="webapps"
name="localhost" unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">



So there has to be another reason. By the way auto deploying works fine for my "normal" apps but just not for those in my user dirs!
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Doh,

I shouldn't post to this forum before drinking my caffine.
 
Marco Ehrentreich
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After some testing i've gathered additional information what causes web applications files in a user dir to be automatically reloaded/refreshed.

When Tomcat starts up a context is created for every user directory which has a web directory in it like public_html for example.
With the admin application included in Tomcat i'm able to set the attribute "reloadable" to "true" for such a context and then everything works as expected. Every change in the user dir is noticed by tomcat and immediately visible in my browser.

But this solution doesn't work really well. First i have to set reloadable to true for every user context by hand. Furthermore changing this setting with the admin application leads to a static <Context> entry in my server.xml and i have to restart Tomcat at least once after changing this setting for all contexts.

I think what would really help me would be a possibility to tell Tomcat to create these contexts by itself with the reloadable attribute already set to true.

Any suggestions? Some other ideas? Thanks in advance!

Marco
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

When Tomcat starts up a context is created for every user directory which has a web directory in it like public_html for example.



I believe the requirement is that Tomcat finds a WEB-INF containing a valid web.xml, otherwise it ignores the directory.

Are you really trying to let users run arbitrary code and serve arbitrary html on your server? Sounds like a recipe for disaster to me.

Bill
 
Marco Ehrentreich
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry Bill, but it also doesn't work with a correct WEB-INF/ and web.xml!

And of course you're right, i wouldn't want everybody to be able to execute arbitrary code on my server!

In fact it's for an exam where every student has to develop a web application in his personal home directory. And at the moment nobody didn't get it to work with auto deployment, so the only solution is a cronjob which restarts Tomcat every few minutes. Of course this is very annoying because you have to wait some time until you can test the result. And i simply can't believe that there isn't a better solution to this problem ;)

Marco
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Are you setting up a separate host for each student?
If so shouldn't the appBase point to their home directory?
 
Marco Ehrentreich
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, it's just one host container with the config i posted above! And this host uses the "webapps" directory for all "ordinary" web applications.

The per user directories are only managed by the <Listener> element within this <Host> element:


<Listener className="org.apache.catalina.startup.UserConfig"
directoryName="public_html"
userClass="org.apache.catalina.startup.PasswdUserDatabase"/>



This is already working correctly! It get's the home directories from /etc/passwd on UNIX/Linux systems and searches for a "public_html" directory within these home directories.

Just auto deployment respectivly noticing changes in this directories doens't work automatically without restarting Tomcat.
An alternative way to achieve this is to just reload the context for a user directory from the manager application. But normal users don't have access to the manager app and in spite of everything i can't believe that it is not possible to achieve what i want without manual user intervention.

Is it really that unusual what i want to do? I didn't find useful information both by crawling the web and the Tomcat docs. In fact it seems i'm the only one using this setup

I'd still be very thankful for any kind of help!

Marco
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Is it really that unusual what i want to do?



Yes! Running web apps for weeks without change is probably the norm.

I recently tackled the problem of adding new HttpServlet handlers without restarting Tomcat - after a long strange trip through ClassLoaders I got something working but it may not be enough for what you are trying to do because it did not provide much for static content.

It is basically a REST style web service handler using a custom ClassLoader that can load a class implementing doGet and doPost as required. You have to use reflection to actually execute the methods.

Bill
 
If you two don't stop this rough-housing somebody is going to end up crying. Sit down and read this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic