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 8055539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:25:19+00:00 2026-06-05T08:25:19+00:00

I have a JAR that suddenly needs to be re-packaged as a WAR (don’t

  • 0

I have a JAR that suddenly needs to be re-packaged as a WAR (don’t ask why). It’s going to be deployed on Tomcat. I’d like to know what the bare minimum set up is (in terms of the web.xml and any other conf files) to instruct Tomcat to deploy the application and run a method that is normally called by the JAR’s main(String[]) method:

public class AppDriver {
    public static void main(String[] args) {
        AppDriver app = new AppDriver();
        app.run();
    }

    // This is the method I need ran by Tomcat at deploy-time.
    public void run() {
        // ...
    }
}

Since I’m not using Spring or any other kind of MVC framework, and since there are no servlets or need for CDI/contexts, I would imagine that my web.xml can be pretty simple; but surprisingly, I can’t find anything explaining exactly what I need.

I also imagine I need to annotate the the run() method somehow, or make reference to it in web.xml. But that’s where I’m stuck. Thanks in advance.

  • 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. Editorial Team
    Editorial Team
    2026-06-05T08:25:21+00:00Added an answer on June 5, 2026 at 8:25 am

    You can implement ServletContextListener, in that case when tomcat deploys your application and starts it, your contextInialized method will be called, in that method you call your run method.

    Then in the web.xml you will add an entry for your class under listener tag.

    Above approach is for servlet spec upto 2.5

    If you are using Servlet Spec 3.0 you can simply add @ServletContextListener annotation to your class with no configuration required in web.xml, when your application is started, it will be invoked by your container.

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

Sidebar

Related Questions

I have a jar file that I would like to execute using PHP, but
I have an API in the form of a JAR that I would like
I have a custom tag, packaged into a library jar that is included in
I have a .jar file that I would like to be able to call
I ask because I have an unsigned jar that runs and a signed version
I have a jar file that I want to put in the shared lib
I have an executable jar Client.jar that requires jndi.properties file. Since the jndi properties
I have a 3rd party JAR that I have converted to an OSGI bundle
I have a java JAR file that is triggered by a SQL server job.
I have a dao jar file that contains all the domain objects and service

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.