You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Maciej Zabielski <MA...@tessel.pl> on 2009/10/08 13:40:50 UTC
Application gets started twice
Hi,
I couldn't find anything related to my configuration problem.
I have Alfresco application installed under webapps/alfresco. The host looks like this:
<Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="false" xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="/var/lib/tomcat5/webapps/alfresco"/>
<Alias>alfresco.mydomain.com</Alias>
</Host>
When I look at the application log, or catalina.out I can see, that the application is started twice.
(there are two "application started" entries)
That happens for each restart of Tomcat...
(alias is used for my Apache HTTPD connection, I use Tomcat5, Centos 5.3)
Thanks for your great support!
Mike
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Application gets started twice
Posted by Mikolaj Rydzewski <mi...@ceti.pl>.
Maciej Zabielski wrote:
> I have Alfresco application installed under webapps/alfresco. The host looks like this:
>
> <Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="false" xmlValidation="false" xmlNamespaceAware="false">
> <Context path="" docBase="/var/lib/tomcat5/webapps/alfresco"/>
> <Alias>alfresco.mydomain.com</Alias>
> </Host>
>
> When I look at the application log, or catalina.out I can see, that the application is started twice.
>
Application is started twice because:
1. Tomcat starts all webapps located within webapps directory
2. Tomcat starts all webapps specified by Context elements
Remove Context entry and restart tomcat. It's so easy :-)
If you - for any reason - need Context element, move webapp to folder
different than webapps and update docBase.
--
Mikolaj Rydzewski <mi...@ceti.pl>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Application gets started twice
Posted by Maciej Zabielski <MA...@tessel.pl>.
Yes, that sounds like a good idea.
For now I have tried something similar that has only one drawback - it is "visible" from outside.
Because I didn't want to mess with alfresco endpoints, I have moved alfresco to regular webapps folder,
Share site is under its own host.
Therefore Share site works directly like this share.domain.com
And for Alfresco I use alfresco.domain.com with auto rewrite to alfresco.domain.com/alfresco
That is rather fine with me.
Locally Alfresco is available under regular address localhost:8080/alfresco and Share application can access all the endpoints without any modifications.
Inside HTTPD virtual host for Alfresco I have added:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/alfresco/
RewriteRule ^/. http://alfresco.tessel.pl/alfresco/ [R]
Once more - big thanks for your support
Regards
Maciej
-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com]
Sent: Monday, October 12, 2009 3:19 PM
To: Tomcat Users List
Subject: RE: Application gets started twice
> From: Maciej Zabielski [mailto:MAZ@tessel.pl]
> Subject: RE: Application gets started twice
>
> My last problem is the possibility to make the localhost:8080 (used for
> mod_jk) also available under localhost:8080/app (as internal endpoints)
> Is there any legal/simple way to accomplish this?
Since you want this to be effective on port 8080 (httpd not involved), you can use the rewrite filter:
http://tuckey.org/urlrewrite/
Alternatively, you could install a dummy webapp at either ROOT or app that simply forwards all requests to the correct one.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Application gets started twice
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Maciej Zabielski [mailto:MAZ@tessel.pl]
> Subject: RE: Application gets started twice
>
> My last problem is the possibility to make the localhost:8080 (used for
> mod_jk) also available under localhost:8080/app (as internal endpoints)
> Is there any legal/simple way to accomplish this?
Since you want this to be effective on port 8080 (httpd not involved), you can use the rewrite filter:
http://tuckey.org/urlrewrite/
Alternatively, you could install a dummy webapp at either ROOT or app that simply forwards all requests to the correct one.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Application gets started twice
Posted by Maciej Zabielski <MA...@tessel.pl>.
Chuck, thank you for your advice and patience :)
I have found context element nested inside host element on some tutorial long time ago and that where all the troubles started (It was probably meant for "pre 5" Tomcat). Now, following your advice, I have chosen the ROOT approach to be "perfectly legal".
My last problem is the possibility to make the localhost:8080 (used for mod_jk) also available under localhost:8080/app (as internal endpoints)
Is there any legal/simple way to accomplish this?
Otherwise I will have put my application back to localhost:8080/app
And try to reconfigure mod_jk so that it will show it under mydomain.com instead of mydomain.com/app
Thanks,
Maciej
----------------------
[Chuck]
You probably don't want to get rid of the <Context> elements, but they really should not be in server.xml, at least not on Tomcat 5.0 or newer. Also, if you want a particular webapp to be the default webapp for a <Host>, it should be named ROOT, not anything else.
[Chuck]
Again, <Context> elements should not be in server.xml, and the default webapp for the <Host> should be named ROOT. Following standard practice makes things much easier; if you were to do that, you could eliminate the <Context> element altogether, and simply place your webapp in:
/usr/local/apache-tomcat-5.5.28/AlfrescoApp/ROOT.war
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Application gets started twice
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Maciej Zabielski [mailto:MAZ@tessel.pl]
> Subject: RE: Application gets started twice
>
> It is not that easy for me to get rid of Context element as when I do
> that, my mod_jk stops working
You probably don't want to get rid of the <Context> elements, but they really should not be in server.xml, at least not on Tomcat 5.0 or newer. Also, if you want a particular webapp to be the default webapp for a <Host>, it should be named ROOT, not anything else.
> Mikolaj wrote: "move webapp to folder different than webapps and update
> docBase"
> Well, that alone did not fix my problem, I believe What is needed
> additionally is
> deployOnStartup=false - does this option set to true deployes only to
> default location? (not the one specified in context?)
>
> Chuck wrote: "docBase should point to some directory or .war file
> directly *underneath* the appBase directory."
I wasn't clear in that I was referring to the docBase determined for the webapp, whether that be by explicit means, or derived from the location of the webapp. In your original setup, you ended up with both, but one of them was wrong.
> "When using automatic deployment, the docBase defined by an XML Context
> file should be outside of the appBase directory. If this is not the
> case difficulties may be experienced deploying the web application or
> the application may be deployed twice.
Which is exactly what you encountered.
> Taking all of that into account, I have created this HOST definition,
> and I copy unpacked WAR manually to docBase dir.
The manual unpacking is not necessary.
> <Context path="" docBase="/usr/local/apache-tomcat-
> 5.5.28/AlfrescoDocBase/alfresco"/>
Again, <Context> elements should not be in server.xml, and the default webapp for the <Host> should be named ROOT. Following standard practice makes things much easier; if you were to do that, you could eliminate the <Context> element altogether, and simply place your webapp in:
/usr/local/apache-tomcat-5.5.28/AlfrescoApp/ROOT.war
> <Context path="" docBase="/usr/local/apache-tomcat-
> 5.5.28/ShareDocBase/share"/>
Same comment as above; remove the <Context>, and place the webapp in:
/usr/local/apache-tomcat-5.5.28/ShareApp/ROOT.war
> <VirtualHost *:80>
> ServerName alfresco.domain.com
> DocumentRoot /usr/local/apache-tomcat-5.5.28/AlfrescoDocBase/alfresco
> #DirectoryIndex index.jsp
The above will need simplification, but I'm not an httpd person, so someone else will have to tell you what they should be.
> Can I be sure that applications will not get started twice now?
If you follow standard practice, the applications will not be started twice.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Application gets started twice
Posted by Maciej Zabielski <MA...@tessel.pl>.
Thank you for your time so far!
And sorry for a long mail this time :)
Because I had some other problems with missing libraries I have decided to get a new installation of Tomcat from apache.org - It solved many problems as compared to Centos yum installation. I have a script that will start it as a service under tomcat account.
It is not that easy for me to get rid of Context element as when I do that, my mod_jk stops working
I can use it like mydomain.com/alfresco but not mydomain.com
When I add Context element that points directly to alfresco, it works fine (mydomain.com).
Mikolaj wrote: "move webapp to folder different than webapps and update docBase"
Well, that alone did not fix my problem, I believe What is needed additionally is
deployOnStartup=false - does this option set to true deployes only to default location? (not the one specified in context?)
Chuck wrote: "docBase should point to some directory or .war file directly *underneath* the appBase directory."
I'm confused as documentation says:
"When using automatic deployment, the docBase defined by an XML Context file should be outside of the appBase directory. If this is not the case difficulties may be experienced deploying the web application or the application may be deployed twice.
Finally, note that if you are defining contexts explicitly, you should probably turn off automatic application deployment. Otherwise, your context will be deployed twice each, and that may cause problems for your app."
Taking all of that into account, I have created this HOST definition, and I copy unpacked WAR manually to docBase dir.
<Host name="localhost" debug="0" appBase="/usr/local/apache-tomcat-5.5.28/AlfrescoApp" unpackWARs="true" autoDeploy="false" xmlValidation="false" xmlNamespaceAware="false" deployOnStartup="false">
<Context path="" docBase="/usr/local/apache-tomcat-5.5.28/AlfrescoDocBase/alfresco"/>
<Alias>alfresco.domain.com</Alias>
</Host>
<Host name="share.tessel.pl" debug="0" appBase="/usr/local/apache-tomcat-5.5.28/ShareApp" unpackWARs="true" autoDeploy="false" xmlValidation="false" xmlNamespaceAware="false" deployOnStartup="false">
<Context path="" docBase="/usr/local/apache-tomcat-5.5.28/ShareDocBase/share"/>
<Alias>share.domain.com</Alias>
</Host>
My virtual host for Apache looks like this:
<VirtualHost *:80>
ServerName alfresco.domain.com
DocumentRoot /usr/local/apache-tomcat-5.5.28/AlfrescoDocBase/alfresco
#DirectoryIndex index.jsp
Alias /alfresco "/usr/local/apache-tomcat-5.5.28/AlfrescoDocBase/alfresco"
JkMount /* alfresco_wrk
JkUnMount /images/* alfresco_wrk
JkUnMount /css/* alfresco_wrk
JkUnMount /scripts/* alfresco_wrk
JkUnMount /yui/* alfresco_wrk
JkUnMount /*.gif alfresco_wrk
JkUnMount /*.jpg alfresco_wrk
JkUnMount /*.html alfresco_wrk
Options FollowSymLinks
<Directory /usr/local/apache-tomcat-5.5.28/AlfrescoDocBase/alfresco>
AllowOverride None
Allow from all
</Directory>
<Directory /usr/local/apache-tomcat-5.5.28/AlfrescoDocBase/alfresco/WEB-INF/>
AllowOverride None
deny from all
</Directory>
<Directory /usr/local/apache-tomcat-5.5.28/AlfrescoDocBase/alfresco/META-INF/>
AllowOverride None
deny from all
</Directory>
</VirtualHost>
Final questions:
Is this configuration reasonable, or is it a total mess? :)
Can I be sure that applications will not get started twice now?
Can you please suggest best solution so that application Alfresco that is now available under
http://localhost:8080/
would be at the same time available under
http://localhost:8080/alfresco
? This is needed for multiple endpoints that Share site refers to.
Thank you!
Maciej
-----Original Message-----
From: Mark Thomas [mailto:markt@apache.org]
Sent: Thursday, October 08, 2009 1:57 PM
To: Tomcat Users List
Subject: Re: Application gets started twice
Maciej Zabielski wrote:
> Hi,
> I couldn't find anything related to my configuration problem.
> I have Alfresco application installed under webapps/alfresco. The host looks like this:
>
> <Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="false" xmlValidation="false" xmlNamespaceAware="false">
> <Context path="" docBase="/var/lib/tomcat5/webapps/alfresco"/>
> <Alias>alfresco.mydomain.com</Alias>
> </Host>
deployOnStartup is deploying the affresco dir as "/alfresco" when Tomcat starts.
Set deployOnStartup to false or delete the above context element and rename
"/var/lib/tomcat5/webapps/alfresco" to "/var/lib/tomcat5/webapps/ROOT"
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Application gets started twice
Posted by Mark Thomas <ma...@apache.org>.
Maciej Zabielski wrote:
> Hi,
> I couldn't find anything related to my configuration problem.
> I have Alfresco application installed under webapps/alfresco. The host looks like this:
>
> <Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="false" xmlValidation="false" xmlNamespaceAware="false">
> <Context path="" docBase="/var/lib/tomcat5/webapps/alfresco"/>
> <Alias>alfresco.mydomain.com</Alias>
> </Host>
deployOnStartup is deploying the affresco dir as "/alfresco" when Tomcat starts.
Set deployOnStartup to false or delete the above context element and rename
"/var/lib/tomcat5/webapps/alfresco" to "/var/lib/tomcat5/webapps/ROOT"
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org