init(VaadinRequest request) method is call twice

I am using Vaadin 7.5.5 , In a simple project If I put a break point in the debuger in the “protected void init(VaadinRequest request) " method then stops there twice, I got a System.out.println(” INIT " + new Date()); that is fire 2 times, If i take out the breakpoint then only fires once.

In another more complex project this happends also in runmode (not debug) when in the init calls a method that fills data from a mail service, then is also call twice.
the problem is that I am using some variables that determine what was the last data I read, and as in the first time that goes thru init , that variable is fill it, then the second time I get not data is that what finally is show in the container, then dependeing in how fast is resonding the service I got data or not.

It seems thats if Init(VaadinRequest request) doesn’t finnish quick enough his inside methods, then is call it again, How can i avoid this?

Are you sure it’s called twice for the same session. I’m just looking UI.class doInit method and it seems to check if it’s already initialized or part of another session already and throws an exception if so.

And what generates another session? If that is the case. I have only one browser (safari by example) open. I do:

  1. start tomcat and way until says “INFORMACIÓN: Server startup in 9325 ms”
  2. After a few seconds (checking that not ouput in console) I enter the URL in the browser and press enter
  3. I get the following output.( 2 INIT with just one second between them)

it seems there is 2 sessions a least this is what I get with :

protected void init(VaadinRequest request) {
idAgent = request.getParameter(“idAgent”);
idRole = getRole(idAgent);

System.out.println("INIT “+ new Date().toString() +” idAgent "+ idAgent + " idRole " + idRole + " session "+ request.getWrappedSession());

[/code]Print OUT —>
INIT Wed Sep 16 17:55:13 CEST 2015 idAgent 5 idRole 0 session com.vaadin.server.WrappedHttpSession@3822c1c5
INIT Wed Sep 16 17:55:14 CEST 2015 idAgent 5 idRole 0 session com.vaadin.server.WrappedHttpSession@36a0a0a9