Saving sessions with Spring Boot Sessions and Vaadin

Hi all,

I’m trying to rewrite our backend written with Vaadin and one the first things I’d like to be sure that works is saving sessions to a JDBC datastore. I’m using Vaadin 8.4.5 (also tried with Vaadin 10.0.2), last Java8 and Tomcat 9.0.10.

I’m trying to use Spring Boot Sessions to do so. The config is in place, following their manual [1]
, so far so good.

When I fire my sample Vaadin project (with Tomcat) I can see the corresponding tables being filled. The session is there. I’m saving in the session an integer value that I increase everytime the user hits the site and then I’m printing that in a Label. That works.

The problem I have is that Vaadin shows the Communication Problem Take a note of the unsaved data, and click here or press ESC to continue, even though I can see the value in the session increasing. If I restart the Tomcat instance, the server is able to restore the session and continue just fine. In Tomcat logs and don’t see anything special (I can paste them).

If I take out the Spring Boot Session artifact, the Communication Problem banner doesn’t show.

I tried with the debug flag (like localhost:8080/?debug. The suspicious message is:

148ms	Received xhr message: for(;;);[{"changes":{},"resources":{},"locales":{},"meta":{"appError":{"caption":"Communication problem","url":null,"message":"Take note of any unsaved data, and <u>click here</u> or press ESC to continue.","details":null}},"syncId":-1}]

149ms	Response didn't contain a server id. Please verify that the server is up-to-date and that the response data has not been modified in transmission.

How can I workaround that? I can paste the config files and the code somewhere.

Thanks,

Gustau

[1]
https://docs.spring.io/spring-session/docs/current/reference/html5/guides/boot-jdbc.html#httpsession-jdbc-boot-sample

I’ve got the same issue with an Vaadin 8.3.0. Entries appear in the spring_session and spring_session_attributes table as expected, but vaadin throws a “communication error” on every click.

Edit: Issue also reproducible with 8.4.x and 8.5.1 vaadin.

Curiously, it only sets the cookie SESSION, but not the cookie JSESSIONID which it does if i have the “org.springframework.session:spring-session-jdbc” artifact removed. Since I’m totally new to Vaadin, perhaps someone can shed some light on the issue?

Thats what ?debug prints for me:

2701ms	Starting application ROOT-2521314
2709ms	Using theme: amhome
2711ms	Vaadin application servlet version: 8.3.0
2725ms	Setting hearbeat interval to 300sec.
2735ms	JSON parsing took 3.2ms
2739ms	Handling message from server
2742ms	* Handling resources from server
2744ms	* Handling type inheritance map from server
2748ms	Handling type mappings from server
2752ms	Handling resource dependencies
2754ms	* Handling meta information
2758ms	* Creating connectors (if needed)
2789ms	Using Translate3DPosition for position
2895ms	* Updating connector states
2984ms	* Handling locales
2986ms	* Updating connector hierarchy
3009ms	* Sending hierarchy change events
3175ms	* Running @DelegateToWidget
3189ms	* Sending state change events
3464ms	* Passing UIDL to Vaadin 6 style connectors
3469ms	VMenuItem constructor
3470ms	* Performing server to client RPC calls
3472ms	Server to client RPC call: 21:com.vaadin.shared.data.DataCommunicatorClientRpc.reset([20]
)
3516ms	Server to client RPC call: 21:com.vaadin.shared.data.DataCommunicatorClientRpc.setData([0, [object Object]
,[object Object]
,[object Object]
,[object Object]
,[object Object]
,[object Object]
,[object Object]
,[object Object]
,[object Object]
,[object Object]
,[object Object]
,[object Object]
,[object Object]
,[object Object]
,[object Object]
,[object Object]
,[object Object]
,[object Object]
,[object Object]
,[object Object]
])
3564ms	* Unregistered 0 connectors
3566ms	handleUIDLMessage: 811 ms
3568ms	Starting layout phase
3636ms	Measured 3 non connector elements
3693ms	Pass 1 measured 152 elements, fired 0 listeners and did 2 layouts.
3701ms	Pass 2 measured 16 elements, fired 0 listeners and did 1 layouts.
3703ms	Did overflow fix for 1 elements
3706ms	Pass 3 measured 3 elements, fired 0 listeners and did 1 layouts.
3707ms	Pass 4 measured 1 elements, fired 0 listeners and did 0 layouts.
3709ms	Did overflow fix for 1 elements
3711ms	Pass 5 measured 1 elements, fired 0 listeners and did 0 layouts.
3712ms	No more changes in pass 6
3713ms	Total layout phase time: 145ms
3714ms	* Dumping state changes to the console
3714ms	UIDL: undefined
4009ms	First response processed 5552 ms after fetchStart
4010ms	Processing time was 1270ms
4010ms	Referenced paintables: 350
5055ms	Starting layout phase
5076ms	Measured 3 non connector elements
5200ms	Pass 1 measured 414 elements, fired 0 listeners and did 1 layouts.
5204ms	Pass 2 measured 2 elements, fired 0 listeners and did 1 layouts.
5206ms	Pass 3 measured 1 elements, fired 0 listeners and did 0 layouts.
5208ms	Did overflow fix for 1 elements
5211ms	Pass 4 measured 1 elements, fired 0 listeners and did 0 layouts.
5211ms	No more changes in pass 5
5212ms	Total layout phase time: 156ms
6081ms	Establishing push connection
6088ms	RPC invocations to be sent to the server:
6089ms	   0 (class com.vaadin.client.ui.ui.UIConnector) :
6089ms	      com.vaadin.shared.ui.ui.UIServerRpc.resize([1903, 866, 1903, 866]
)
6094ms	Sending xhr message to server: {"csrfToken":"799ab926-36a7-4968-8065-9ab4bc6ad074","rpc":[["0","com.vaadin.shared.ui.ui.UIServerRpc","resize",[1903,866,1903,866]
]],"syncId":0,"clientId":0,"wsver":"8.3.0"}
6117ms	Starting layout phase
6142ms	Measured 3 non connector elements
6157ms	Pass 1 measured 20 elements, fired 0 listeners and did 0 layouts.
6158ms	No more changes in pass 2
6160ms	Total layout phase time: 41ms
6166ms	Server visit took 73.6ms
6167ms	JSON parsing took 0.1ms
6168ms	Received xhr message: for(;;);[{"changes":{},"resources":{},"locales":{},"meta":{"appError":{"caption":"Communication problem","url":null,"message":"Take note of any unsaved data, and <u>click here</u> or press ESC to continue.","details":null}},"syncId":-1}]

6170ms	Response didn't contain a server id. Please verify that the server is up-to-date and that the response data has not been modified in transmission.
6170ms	Handling message from server
6171ms	* Handling resources from server
6173ms	* Handling type inheritance map from server
6173ms	Handling type mappings from server
6173ms	Handling resource dependencies
6175ms	* Handling meta information
6176ms	* Creating connectors (if needed)
6176ms	* Updating connector states
6176ms	* Handling locales
6177ms	* Updating connector hierarchy
6178ms	* Running @DelegateToWidget
6178ms	* Sending state change events
6178ms	* Passing UIDL to Vaadin 6 style connectors
6182ms	* Unregistered 0 connectors
6182ms	handleUIDLMessage: 6 ms
6183ms	Starting layout phase
6188ms	Measured 3 non connector elements
6234ms	Pass 1 measured 155 elements, fired 0 listeners and did 0 layouts.
6236ms	Did overflow fix for 1 elements
6240ms	Pass 2 measured 5 elements, fired 0 listeners and did 1 layouts.
6242ms	Did overflow fix for 1 elements
6245ms	Pass 3 measured 4 elements, fired 0 listeners and did 1 layouts.
6247ms	Pass 4 measured 1 elements, fired 0 listeners and did 0 layouts.
6248ms	Did overflow fix for 1 elements
6253ms	Pass 5 measured 1 elements, fired 0 listeners and did 0 layouts.
6253ms	No more changes in pass 6
6255ms	Total layout phase time: 71ms
6255ms	* Dumping state changes to the console
6256ms	UIDL: undefined
6267ms	Setting hearbeat interval to -1sec.
6267ms	Processing time was 97ms
6268ms	Referenced paintables: 350
6787ms	JSON parsing took 0ms
6787ms	Received push (undefined) message: for(;;);[{"changes":{},"resources":{},"locales":{},"meta":{"appError":{"caption":"Communication problem","url":null,"message":"Take note of any unsaved data, and <u>click here</u> or press ESC to continue.","details":null}},"syncId":-1}]

6788ms	Response didn't contain a server id. Please verify that the server is up-to-date and that the response data has not been modified in transmission.
6788ms	Ignored received message because application has already been stopped

And the console is filled with:

2018-08-09 15:48:29.996  WARN 37968 --- [nio-443-exec-10]
 c.v.server.ConnectorResourceHandler      : Ignoring connector request for no-existent root 0
2018-08-09 15:48:30.000  WARN 37968 --- [-nio-443-exec-2]
 c.v.server.ConnectorResourceHandler      : Ignoring connector request for no-existent root 0
2018-08-09 15:48:30.005  WARN 37968 --- [-nio-443-exec-9]
 c.v.server.ConnectorResourceHandler      : Ignoring connector request for no-existent root 0
2018-08-09 15:48:30.005  WARN 37968 --- [-nio-443-exec-5]
 c.v.server.ConnectorResourceHandler      : Ignoring connector request for no-existent root 0
2018-08-09 15:48:30.005  WARN 37968 --- [-nio-443-exec-7]
 c.v.server.ConnectorResourceHandler      : Ignoring connector request for no-existent root 0
2018-08-09 15:48:30.037  WARN 37968 --- [-nio-443-exec-3]
 c.v.server.ConnectorResourceHandler      : Ignoring connector request for no-existent root 0
2018-08-09 15:48:30.045  WARN 37968 --- [-nio-443-exec-1]
 c.v.server.ConnectorResourceHandler      : Ignoring connector request for no-existent root 0
2018-08-09 15:48:30.045  WARN 37968 --- [-nio-443-exec-4]
 c.v.server.ConnectorResourceHandler      : Ignoring connector request for no-existent root 0
2018-08-09 15:48:30.060  WARN 37968 --- [-nio-443-exec-6]
 c.v.server.ConnectorResourceHandler      : Ignoring connector request for no-existent root 0
2018-08-09 15:48:30.062  WARN 37968 --- [-nio-443-exec-8]
 c.v.server.ConnectorResourceHandler      : Ignoring connector request for no-existent root 0
2018-08-09 15:48:30.062  WARN 37968 --- [nio-443-exec-10]
 c.v.server.ConnectorResourceHandler      : Ignoring connector request for no-existent root 0
2018-08-09 15:48:30.084  WARN 37968 --- [-nio-443-exec-2]
 c.v.server.ConnectorResourceHandler      : Ignoring connector request for no-existent root 0
2018-08-09 15:48:30.097  WARN 37968 --- [-nio-443-exec-7]
 c.v.server.ConnectorResourceHandler      : Ignoring connector request for no-existent root 0
2018-08-09 15:48:30.097  WARN 37968 --- [-nio-443-exec-5]
 c.v.server.ConnectorResourceHandler      : Ignoring connector request for no-existent root 0
2018-08-09 15:48:30.139  WARN 37968 --- [-nio-443-exec-7]
 c.v.server.ConnectorResourceHandler      : Ignoring connector request for no-existent root 0
2018-08-09 15:48:30.152  WARN 37968 --- [-nio-443-exec-1]
 c.v.server.ConnectorResourceHandler      : Ignoring connector request for no-existent root 0
2018-08-09 15:48:30.152  WARN 37968 --- [-nio-443-exec-3]
 c.v.server.ConnectorResourceHandler      : Ignoring connector request for no-existent root 0
2018-08-09 15:48:30.156  WARN 37968 --- [-nio-443-exec-4]
 c.v.server.ConnectorResourceHandler      : Ignoring connector request for no-existent root 0
2018-08-09 15:48:30.158  WARN 37968 --- [-nio-443-exec-8]
 c.v.server.ConnectorResourceHandler      : Ignoring connector request for no-existent root 0

I am also facing the same issue. In my browser i am getting following response while I click on Login Button :

for(;;);[{“changes”:{},“resources”:{},“locales”:{},“meta”:{“appError”:{“caption”:“Communication problem”,“url”:null,“message”:“Take note of any unsaved data, and click here or press ESC to continue.”,“details”:null}},“syncId”:-1}]

I have added Redis Cache by adding below dependencies:

    <dependency>
		<groupId>org.springframework.session</groupId>
		<artifactId>spring-session-data-redis</artifactId>
	</dependency>

	<dependency>
		<groupId>io.lettuce</groupId>
		<artifactId>lettuce-core</artifactId>
		<version>5.0.5.RELEASE</version>
	</dependency>