Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 114479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:52:02+00:00 2026-05-11T02:52:02+00:00

I’ve got a foo.war file from a third-party vendor. I’ve defined a context in

  • 0

I’ve got a foo.war file from a third-party vendor. I’ve defined a context in my Tomcat configuration by creating conf/Catalina/localhost/foo.xml that contains:

<Context docBase='/path/to/foo.war' ...> ... </Context> 

I want Tomcat to load up the foo context at startup. But the WEB-INF/web.xml (deployment descriptor) in the foo.war file does not include a <load-on-startup>, so Tomcat waits until the first request. I’d really rather not unpack the third-party foo.war to edit their web.xml. Plus, I’d have to do it every time the vendor releases a new version of their .war.

Is there any way within Tomcat configuration to tell Tomcat to load the foo context at startup? I know that within the <Context> element you can set parameters, env vars, etc without editing the web.xml. But I can’t find anything in the Tomcat docs about loading on startup.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T02:52:02+00:00Added an answer on May 11, 2026 at 2:52 am

    This is tricky. You’re limited by the conventions of Tomcat and other containers, so there’s no straightforward solution.

    You could use the global web.xml to initialize specific servlets and/or JSPs from the .war using the <load-on-startup> element. This is the only way I know of to force load-on-startup without modifying the .war file or the WEB-INF/web.xml inside it. Note that you may need to initialize the servlets and JSPs using different names/paths to avoid conflicts.

    Of course, doing it that way means you have to know enough about the .war to initialize the app, which might mean looking at its web.xml to determine what to load. This might defeat the purpose, since it’s not exactly a hands-off approach to loading just any .war on startup. But with a little extra work, you could write a script that extracts the necessary information from the .war file’s web.xml and adds it to your global web.xml automatically.

    Now, if you’re willing to consider script writing to modify the .war file, you could just write a script that extracts WEB-INF/web.xml from the .war file, adds <load-on-startup> child elements to all the <servlet> elements, and updates the .war with the new copy. I’m not sure what environment you’re using to run Tomcat, but here’s an example bash script that would do the job:

    #!/bin/sh  TEMPDIR=/tmp/temp$$ WARFILE=/path-to-tomcat/webapps/foo.war  mkdir -p $TEMPDIR/WEB-INF pushd $TEMPDIR unzip -qq -c $WARFILE WEB-INF/web.xml \     | sed 's#</servlet>.*#<load-on-startup>99</load-on-startup></servlet>#' \     > WEB-INF/web.xml zip -f $WARFILE WEB-INF/web.xml popd rm -rf $TEMPDIR 

    You could run this script or something similar as part of your Tomcat startup. Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 72k
  • Answers 72k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer I would use <link>http://www.nytimes.com/2009/04/10/technology/internet/10google.html?ref=technology</link> Then in the XSLT, create an… May 11, 2026 at 1:40 pm
  • added an answer I don't think you can. It should be: #SomeDropdown >option[value='a\'b]<p>']… May 11, 2026 at 1:40 pm
  • added an answer Pressing ctrl + ] should take you to the matching… May 11, 2026 at 1:40 pm

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.