Jay
Jay

Reputation: 5043

How does tomcat 6 choose the order to deploy WAR files

I have a suite of web applications deployed as a number of WAR files. I have this code deployed to a number of VMs and is working well. My devops team created a new VM that is basically a copy of the others, and one of the web apps is throwing an exception at start time. The error is shown below. When comparing the environments, I noticed that VM with error is deploying the apps in a different order than the other servers. I think there may something there. How do I force tomcat deploy the webapps in a specified order, which happens to be alphabetic order on the other VMs?

Just for further edification, we are using Jenkins to build and deploy the code, so I am 100% certain this same code and libraries are working well in pretty much a duplicate Linux/Tomcat environment.

Feb 27, 2014 8:33:03 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 395 ms
Feb 27, 2014 8:33:03 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Feb 27, 2014 8:33:03 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.37
Feb 27, 2014 8:33:03 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive appmgmt20.war
Feb 27, 2014 8:33:05 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive ROOT.war
Feb 27, 2014 8:33:06 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive appmgmt10.war
Feb 27, 2014 8:33:07 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive lbprobe.war
Feb 27, 2014 8:33:07 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive travel.war
2014-02-27 08:33:08 ERROR ContextLoader:227 - Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Parser configuration exception parsing XML from ServletContext resource [/WEB-INF/classes/edu/cornell/finsys/webservices.xml]; nested exception is javax.xml.parsers.ParserConfigurationException: Unable to validate using XSD: Your JAXP provider [oracle.xml.jaxp.JXDocumentBuilderFactory@10987197] does not support XML Schema. Are you running on Java 1.4 with Apache Crimson? Upgrade to Apache Xerces (or Java 1.5) for full XSD support.
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:404)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
    at 
    ....
Feb 27, 2014 8:33:08 AM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Feb 27, 2014 8:33:08 AM org.apache.catalina.core.StandardContext start
SEVERE: Context [/travel] startup failed due to previous errors
Feb 27, 2014 8:33:08 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive cashreceipts.war
Feb 27, 2014 8:33:09 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive jems.war
Feb 27, 2014 8:33:09 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive paymentrequest.war
Feb 27, 2014 8:33:09 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive acctmgmt.war
Feb 27, 2014 8:33:09 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive appmgmtbulkldr.war
Feb 27, 2014 8:33:10 AM org.apache.catalina.core.StandardContext addApplicationListener
INFO: The listener "com.sun.faces.config.ConfigureListener" is already configured for this context. The   duplicate definition has been ignored.
Feb 27, 2014 8:33:10 AM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on localhost/127.0.0.1:8108
Feb 27, 2014 8:33:10 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/65  config=null
Feb 27, 2014 8:33:10 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 6897 ms

Upvotes: 1

Views: 594

Answers (2)

Jay
Jay

Reputation: 5043

It turns out my class loader was a red herring. I needed to add the following VM parameters

-Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl 
-Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl

I found this solution on another stack overflow issue: Parser configuration exception parsing XML from class path resource

Upvotes: 0

Cristian Meneses
Cristian Meneses

Reputation: 4041

Unfortunately, there's no such thing, as Tomcat has never supported a deploy order

There is no expected startup order. Neither the Servlet spec nor Tomcat define one. You can't rely on the apps starting in any particular order.

Anyways, there's a potential workaround by specifiyng a deploy order on your server.xml file. Please read this from Tomcat Wiki for details : http://wiki.apache.org/tomcat/FAQ/Miscellaneous#Q27

An alternate way to do this would be using Zeroconf as a service registration an discovery point, but that would change for all your apps.

Upvotes: 3

Related Questions