aspose file tools*
The moose likes Tomcat and the fly likes Handling Tomcat Deployment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Handling Tomcat Deployment " Watch "Handling Tomcat Deployment " New topic
Author

Handling Tomcat Deployment

Avinash Bhat
Greenhorn

Joined: Feb 03, 2011
Posts: 12

what is the purpose of setting deployONStartUP to false ?

What is the procedure followed when deployONStartUP to false and deployONStartUP to true??

Because - when the deployOnStartup = true, the tomcat is deploying all the .war files and tomcat is getting started -== This is taking around 10 seconds to start tomcat.

But when the deployOnStartup=false, the tomcat is starting up first and then the depployment is happening/ == This is taknig around 20 seconds.

Any idea why this time gap? when the deploy<->startup and startup<->deploy sequence is interchanged by doing deployOnStartup=true/false???



For example:

I have given deployOnStartup=false (in <host> server.xml), I see the following logs:

29 Jan, 2014 12:16:13 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.6.0_24\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Perl\site\bin;C:\Perl\bin;C:\Program Files (x86)\RSA SecurID Token Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;;C:\Program Files (x86)\Subversion\bin;C:\Program Files\TortoiseSVN\bin;C:\Perl\bin;C:\apache-ant-1.8.4-bin\apache-ant-1.8.4\bin;C:\Python27;C:\Python27\Scripts;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\Java\jdk1.6.0_24\\bin;C:\Perl\bin;C:\apache-ant-1.8.4-bin\apache-ant-1.8.4\bin;
29 Jan, 2014 12:16:13 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
29 Jan, 2014 12:16:13 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 422 ms
29 Jan, 2014 12:16:13 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
29 Jan, 2014 12:16:13 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.37
29 Jan, 2014 12:16:13 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
29 Jan, 2014 12:16:13 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
29 Jan, 2014 12:16:13 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/16 config=null
29 Jan, 2014 12:16:13 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 100 ms
29 Jan, 2014 12:16:23 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor host-manager.xml
29 Jan, 2014 12:16:24 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor manager.xml
29 Jan, 2014 12:16:24 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor OMAgent.xml
29 Jan, 2014 12:16:25 PM org.apache.catalina.core.StandardContext addApplicationListener
INFO: The listener "org.apache.myfaces.webapp.StartupServletContextListener" is already configured for this context. The duplicate definition has been ignored.
29 Jan, 2014 12:16:28 PM com.nokia.j2ssp.comp.esymac.util.RMIServicePortAndIPBinding allocatePort
INFO: Port allocated for creating server socket: 0
29 Jan, 2014 12:16:28 PM com.nokia.j2ssp.comp.esymac.util.RMIServicePortAndIPBinding getServerSocketFactory
INFO: Server Scoket: null
29 Jan, 2014 12:16:28 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive NE3S.war






Now why its taking 15 seconds to start up and deploy?
Someone could please help me on this?

Best Regards,
Avinash Bhat
Avinash Bhat
Greenhorn

Joined: Feb 03, 2011
Posts: 12

Tomcat version is "6.0.37"
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16228
    
  21

When all else fails, read the manual:

http://tomcat.apache.org/tomcat-6.0-doc/deployer-howto.html

Note that a webapp doesn't HAVE to be located in the $CATALINA_BASE/webapps directory. In fact, many of mine are not. When testing, I run straight from my development directory, and I often have special production directories external to Tomcat that hold production WARs.

Beyond that, the actual deployOnStartup determines whether a Context will be created or installed for the webapps that are physically present in $CATALINA_BASE/webapps. And whether old WARs will be deleted and new WARs exploded when Tomcat starts up. As opposed to simply using previously-deployed WARs.

Normally I don't override the default value of deployOnStartup and I'm perfectly happy.


Customer surveys are for companies who didn't pay proper attention to begin with.
Avinash Bhat
Greenhorn

Joined: Feb 03, 2011
Posts: 12

Hi,

Thank you very much for the response.

I got your point. But in this case i wanted to set it as false

I have 2 tomcat running on the same machine. Procedure as follows:

1) Starting my application
2) Starting first tomcat on port 8080 which register with application
3) I start another instance of tomcat on the same PORT 8080. ---> THIS WILL REPLACE THE REGISTRATION DONE WITH FIRST TOMCAT, EXISTS BY THROWING PORT BIND EXCEPTION

This is because deployOnStartup is set to TRUE, where all the application war files getting deployed before tomcat startup. Its deploying and replaceing the first tomcat instance and throwing port bind.


So i wanted to set this to FALSE, So that deploy happens if tomcat starts up properly (In this case Port bind comes during startup only, so no way it goes to next step which is deployment -> This never replaces registration with application )

Time difference is totally different in both the cases:

deployOnStarup=true: --> Order deployment and tomcat startup.

Tomcat starts in 8 secs.

But:

deployOnStarup=false: --> Order Tomcat startup and Deployment.

Tomcat starts in 15 secs.


-----


Any idea why this time gap? Is there any specific deployment handling in case of deployOnStartup is set to false?


Regards,
Avinash Bhat

Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10262
    
168

To be honest, I don't know what you are trying to achieve. Why do you start two instances of Tomcat on the same port?

[My Blog] [JavaRanch Journal]
Avinash Bhat
Greenhorn

Joined: Feb 03, 2011
Posts: 12

Hi,

This is just a negative scenario. During testing we have come across. Entire application goes down if thats the case.

Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10262
    
168

So you mean, if Tomcat A is started on port 8080 and you start another instance on the same port then the applications deployed on Tomcat A are affected? I haven't heard of that before. What problems are you seeing with the deployed applications?

Playing with the deployOnStartup isn't going to achieve much in this case - how would you even handle this if it was some other server like JBoss which would try to start on the same port where Tomcat is already running.

Avinash Bhat
Greenhorn

Joined: Feb 03, 2011
Posts: 12

Hi,

Yes, When the Tomcat B is started on the same port Tomcat A is getting replaced in the application.

Tomcat A is replaced with B, where B gets closed because of Port Bind Exception.

The deployed application unregsitering the old Tomcat registered.

Regards,
Avinash Bhat
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10262
    
168

Where exactly are those web applications located?
Avinash Bhat
Greenhorn

Joined: Feb 03, 2011
Posts: 12



In Webapps folder <appBase>



Avinash Bhat
Greenhorn

Joined: Feb 03, 2011
Posts: 12

Any idea about this?

Could some one tell me the procedure followed when the deployOnStartup=false?

There is a detailed procedure for deployOnStartup=true in tomcat website. But i didn see the same for deployOnStartup=false.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16228
    
  21

There is a fundamental problem here.

Two applications cannot listen on the same TCP/IP port.

This is not a Tomcat problem. This is not a Java problem. This is a fundamental constraint of the TCP/IP architecture.

For any give OS instance one and ONLY one process can own a TCP/IP port. Attempts by any other process to open and listen on that port will fail. The OS will reject the open attempt.

In the case of Tomcat, Tomcat will not shut down if access is denied to a resource, but the resource will not be available for the life of the Tomcat JVM. Tomcat has no standard mechanism to go in later and acquire a listener port if it wasn't available at startup time. So the second Tomcat instance is effectively useless. At least in regard to any activity on port 8080.

Also, I think you are confusing "install" and "deploy". They are not the same thing.
Avinash Bhat
Greenhorn

Joined: Feb 03, 2011
Posts: 12

This problem is resolved...

The changes are:

backgroundProcessorDelay="4" ---> Which avoids deploying war file for sometime. (delay)




Thanks for the help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Handling Tomcat Deployment