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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:41:35+00:00 2026-06-02T12:41:35+00:00

I use vaadin + spring IOC + google guava eventbus. Resources recommends to use

  • 0

I use vaadin + spring IOC + google guava eventbus. Resources recommends to use guava eventbus as singleton. But when I do that I have the following problem;

  • Let’s say I run the application on 3 different browsers at the same time, so I have 3 different instances of my application.

  • then for example when an I press a button on one browser and fire an event, I notice that my related listener method with the @subscribe annotation gets called 3 times!

Is this is a normal behaviour I would expect because I use eventbus as singleton? If not what is going on here? MainController is a spring managed bean with a a custom Vaadin Application Scope

class MainController{
  public MainController() throws DAOException, Exception {
    EventBusFactory.getEventBusInstance().register(this);
  }

  @Subscribe
  public void addFacetEvent(FacetAddedEvent event) throws DAOException {
    getTreeTableView().addToList(event.getData());
  }
} 

class EventBusFactory{
  public static EventBus getEventBusInstance() {
        if(eventBus==null){
            eventBus=new EventBus();
        }
        return eventBus;
    }
}

P.s I also hesitate in Vaadin should I to use guava eventbus or guava gwt event bus?

Thanks

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

    Short answer: It’s normal and expected behaviour in this configuration (you have three Vaadin Applications and hence three MainController instances managed with single EventBus).


    By custom Vaadin Application Scope did you mean scope from this Vaadin addon?

    Anyway, it’s simple to reproduce your situation having prototype-scoped MainController bean and Vaadin App like this:

    public class SandpitApplication extends Application {
      private static final long serialVersionUID = 1L;
      private static final Logger log = Logger.getLogger(SandpitApplication.class);
    
      // https://vaadin.com/wiki/-/wiki/Main/Spring%20Integration#section-Spring+Integration-SpringContextHelperClass
      private SpringContextHelper ctx;
    
      @Override
      public void init() {
        // vaadin stuff
        setTheme("common");
        final Window mainWindow = new Window("Vaadin Sample Application");
        setMainWindow(mainWindow);
    
        // get your bean from spring
        log.info("start SandpitApplication@" + Integer.toHexString(hashCode()));
        ctx = new SpringContextHelper(this);
        // create application-wide bean
        final MainController mainController = ctx.getBean("mainController");
    
        mainWindow.addComponent(new Button("click to post", new Button.ClickListener() {
          @Override public void buttonClick(final ClickEvent event) {
            log.info("click on button");
            EventBusFactory.getEventBusInstance().post(
                new FacetAddedEventImpl("click-"
                    + new SimpleDateFormat("HH:mm:ss").format(new Date())));
            log.info(mainController);
          }
        }));
      }
    }
    

    and MainController class:

    class MainController {
      private static final Logger log = Logger.getLogger(MainController.class);
    
      public MainController() {
        log.info("creating MainController@" + Integer.toHexString(hashCode()));
        EventBusFactory.getEventBusInstance().register(this);
      }
    
      @Subscribe
      public void addFacetEvent(final FacetAddedEvent event) {
        final String signature = "MC@" + Integer.toHexString(hashCode()) + ": ";
        log.info("addFacetEvent in " + signature + event);
        // getTreeTableViewBuilder returns extended ArrayList with fancy add
        getTreeTableViewBuilder().addFacetToList(signature + event.getData());
      }
    
      // plus other stuff like toString etc.
    }
    

    When you do the following:

    1. Start the vaadin app in your browser (App#1).
    2. Click the App1#button.
    3. Start another app (App#2).
    4. Click the App2#button
    5. Go back to tab with App#1.
    6. Click the App1#button.

    you’ll get the following output:

    start SandpitApplication@75a5555a
    creating MainController@2e98f864
    click on button // #1
    addFacetEvent in MC@2e98f864: FacetAddedEventImpl@6b527dc6{data: click-13:42:45}
    MainController@2e98f864{treeTableViewBuilder: [MC@2e98f864: click-13:42:45]}
    start SandpitApplication@3f9e529
    creating MainController@2f8d604f
    click on button // #2
    addFacetEvent in MC@2e98f864: FacetAddedEventImpl@36c1fc67{data: click-13:42:47}
    addFacetEvent in MC@2f8d604f: FacetAddedEventImpl@36c1fc67{data: click-13:42:47}
    MainController@2f8d604f{treeTableViewBuilder: [MC@2f8d604f: click-13:42:47]}
    click on button // #1
    addFacetEvent in MC@2e98f864: FacetAddedEventImpl@42d32028{data: click-13:42:49}
    addFacetEvent in MC@2f8d604f: FacetAddedEventImpl@42d32028{data: click-13:42:49}
    MainController@2e98f864{treeTableViewBuilder: [MC@2e98f864: click-13:42:45, MC@2e98f864: click-13:42:47, MC@2e98f864: click-13:42:49]}

    You should now see that singleton EventBus is managing two application-wide MainController beans and each is recieving event (because it’s resolved by global EventBus).

    Trying to guess what do you want to achieve, I’d say that you need create application-wide event bus bean:

    <bean id="eventBus" class="com.google.common.eventbus.EventBus"
        scope="vaadinApplication" />
    

    About P.S.: We use standard Guava in our Vaadin project extensively, no need for GWT version.

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

Sidebar

Related Questions

I've installed Spring Roo (1.2.0.RELEASE [rev 39eb957]), but I am failed to install Vaadin
I have a vaadin table where I use certain filters for filtering, just like
I have an existing maven project, in which i started to use vaadin, by
I have a setup where I wan't to use a FormFieldFactory that returns a
I use Vaadin in my project, currently i'm having a problem with it. It's
I am planning to use vaadin to develop internal application, which will be used
Im trying to convert the Vaadin demo for JPAContainer to use hibernate instead of
use this website a lot but first time posting. My program creates a number
I have a Bean that looks like this Class Person{ private String name; private
I have few Vaadin tabs one of them is displaying an table and some

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.