• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 398
  • Last Modified:

Need multiple /webapps folders for different users on my site's tomcat server

Hi!

I am desperately trying to have multiple /webapps folders for different users on my site's tomcat server. Is there any way to do this ?

Currently I have this place to store my webapps ->  /www/website.com/webapps/

And I'd like to have something like this :    

/www/website.com/users/john/webapps/
 /www/website.com/tom/webapps/
 /www/website.com/mike/webapps/
...

I don't want people storing all their webapps in the same directory. But I 'd like the same tomcat server running them all.

0
firewired44
Asked:
firewired44
  • 9
  • 6
1 Solution
 
ramazanyichCommented:
I think you should read carefully this documentation
http://tomcat.apache.org/tomcat-5.5-doc/config/host.html#User%20Web%20Applications
It describes web applications per user configuration
0
 
firewired44Author Commented:
Sorry this is not enough to help me out
0
 
ramazanyichCommented:
If you use tomcat5.5 then In your $tomcat_home/conf/server.xml put following config as child of  <Host ... > element:
      <Listener className="org.apache.catalina.startup.UserConfig"
            directoryName="webapps"
            homeBase="www/website.com"
            userClass="org.apache.catalina.startup.HomesUserDatabase"/>

Under www.website.com directory create directories user_name/webapps for every user who will create his directories (replace user_name by real usernames like tom, mike)

put user's web applications in user_name/webapps and now you should be able to access users web applications in format website.com/~username/webappname


for example you have user tom.
you created /www/website.com/tom/webapps dir.
user tom puts his webaaplication test.war to this directory and it is accessible as
http://website.com/~tom/test

0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
firewired44Author Commented:
Thanks, it seems to be partly resolving the problem,

Now when I go in my tomcat 5.5's manager I see    /~tom  listed in the applications path. In fact all the usernames that have a webapps folder containing .war files are listed.

But when even though I can access http://website.com/~tom/test.war
the jsp compiler generates an error. (this does not happen if I put the .war in the root webapps folder.
I tried extracting the war into a folder in webapps but it still can't compile the code.

Any ideas what I'm doing wrong.. ?
0
 
ramazanyichCommented:
you should not requestr test.war as URL because test.war will be unpacked to test directory under tom/webapps/ directory by Tomcat itself then URL: http://website.com/~tom/test will be called.

So remove .war from your URL and it should be ok
0
 
firewired44Author Commented:
I tried what you said but it just gives me a jsp error, I tried several different war files and they all have the same result.

Here's my server.xml, I added the line you told me about at the end.


<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.core.AprLifecycleListener"/>
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
&#8722;
      <GlobalNamingResources>
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml"/>
</GlobalNamingResources>
&#8722;
      <Service name="Catalina">
<Connector port="8080" maxHttpHeaderSize="8192" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true"/>
<Connector port="8009" enableLookups="false" redirectPort="8443" protocol="AJP/1.3"/>
&#8722;
      <Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
&#8722;
      <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">

<Listener className="org.apache.catalina.startup.UserConfig" directoryName="webapps" homeBase="/www/mywebsite.ch/users" userClass="org.apache.catalina.startup.HomesUserDatabase"/>

</Host>
</Engine>
</Service>
</Server>
0
 
ramazanyichCommented:
And what is inside test.war file ?
0
 
firewired44Author Commented:
I'm using the war that you can find on this page for testing http://homepage.ntlworld.com/richard_c_atkinson/jfreechart/

the charts generated by the war are displayed fine when the war is located in root webapps, but when it's in a user's  webapps folder I just get a
org.apache.jasper.JasperException (couldn't compile, etc..)

0
 
ramazanyichCommented:
Strange, but indeed if you put WAR file into user howe it is not unpacked by tomcat(even if unpackWARs=true in Host element).
But if I unpack on my PC  test.war into /www/website.com/tom/webapps/test directory then it works.
Could you try also unpack it on your system ?
Maybe it is a bug (or feature ?!) in tomcat - that it doesn't unpack war files in users home directories.
0
 
firewired44Author Commented:
Thanks a lot for spending all this time trying to solve my problem.

That's true it does seem strange that it never unpacks them when located in the user home directories.

Arg.. will the tomcat errors never end !? I unpacked the WAR into a /www/mywebsite.ch/users/tom/webapps/test/ folder
then typed http://mywebsite.ch/~tom/test/

I've been trying to get this thing to work for days and still no luck,

Here is what I got (java is installed in french on this pc, but most of the error text is in english anyway)



27 nov. 2006 14:31:57 org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: "Servlet.service()" pour la servlet jsp a généré une exception
org.apache.jasper.JasperException: Impossible de compiler la classe pour la JSP

Erreur de servlet générée:
Only a type can be imported. org.jfree.chart.demo.servlet.WebHitChart resolves to a package

Erreur de servlet générée:
Only a type can be imported. org.jfree.chart.demo.servlet.WebHitDataSet resolves to a package

Une erreur s'est produite à la ligne: 10 dans le fichier jsp: /jfreechart/pie_chart.jsp
Erreur de servlet générée:
WebHitChart cannot be resolved

Une erreur s'est produite à la ligne: 10 dans le fichier jsp: /jfreechart/pie_chart.jsp
Erreur de servlet générée:
WebHitDataSet cannot be resolved


      at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
      at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
      at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
      at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
      at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
      at java.lang.Thread.run(Thread.java:595)
0
 
ramazanyichCommented:
have the same issue with deploymeny of your war file on my system. Probably bug in Tomcat :(
0
 
firewired44Author Commented:
But isn't there a way to work around this problem... ? :-(

0
 
firewired44Author Commented:
Can someone help me out with this problem please.. ?
0
 
firewired44Author Commented:
Is there only one tomcat expert here . . .?
0
 
firewired44Author Commented:
Sorry but I'm not impressed by the service offered here.. I'm cancelling my subscription.
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

  • 9
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now