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

  • SEARCH
  • Home
  • 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 7862623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:12:32+00:00 2026-06-02T23:12:32+00:00

I want to start a daemon mail service thread on tomcat server startup. So,

  • 0

I want to start a daemon mail service thread on tomcat server startup. So, I have annotated a method with @Async annotation.

I have a class which implements a ApplicationListener interface. When I call my async method from this class, it never starts asynchronously and blocks the current thread. And When I call my async method from a spring controller class, It never blocks and starts asynchronously.

Why async method executed successfully from one class and not from the other class?

What am I doing wrong and How can I execute my async method on server startup??

Thanks in advance.

Edit: I tried using the InitializingBean interface, @PostConstruct, init-method approach to call my async method, but it never executed. Then I realized, my default lazy-init is true, So I make the lazy-init to false for my InitializingBean. Now it execute my asnyc method, but it blocks the current thread and now one more issue, I am facing is that My server didn’t stop gracefully, but I have to stop my server forcefully.

  • 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-02T23:12:34+00:00Added an answer on June 2, 2026 at 11:12 pm

    First of all You don’t need to implement ApplicationListener interface. You are working with Spring – Application context is enough.

    Second you are talking about Spring @Async, it means that your task should be started from Application Context and Controller bean is a part of it.

    You need to make sure that you have <annotation-driven> in your spring xml file.

    You can start your task on @PostConstruct function:

    @Component
    public class SampleBeanImpl implements SampleBean {
    
      @Async
      void doSomething() { … }
    }
    
    
    @Component
    public class SampleBeanInititalizer {
    
      @Autowired
      private final SampleBean bean;
    
      @PostConstruct
      public void initialize() {
        bean.doSomething();
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use run_erl to start up a daemon version of my release,
I have a situation like this: start(); <Some code> end(); I want start() function
I want to start a new thread using a C function, not an objective-C
I want to start my daemon with my application. In the command line, I
I have a daemon that I'm starting along with the server using an initializer
I have a remote Music Player Daemon(MPD) server running on a linux machine. I
I try to start thinking sphinx on my server but it doesn't want to
I have an application which i want to run as service on MacOS X.
I want to start a background process in a Java EE (OC4J 10) environment.
I want to start coding in Python or Ruby. Since I own a Lego

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.