title: How singleton is javax.ejb.Singleton in a clustered environment?
body: <p>I need to maintain a simple counter that is unique within the application, for all users and all nodes in a clustered environment.
  I thought about using the singleton session bean annotation javax.ejb.Singleton like so:</p>
  
  <pre><code>package foo;
  
  import javax.ejb.Singleton;
  
  @Singleton
  public class Bean {
      private int counter;
      [...]
  }
  </code></pre>
  
  <p>This looks simple, but I could not find an answer if this works as desired in a clustered environment. Would every node of the cluster have it's own instance or not?</p>
  
  <p>Of course I could persist the bean in a database, but it's really only a counter and doing so would be overkill. Also, I want the counter to reset on application crash or restart, so persisting it would create more problems than it solves.</p>