Strange behavior of triggering JAX-RS client request within UI


I implemented a buttonClick listener, and tried to issue a http client request to my custom VaadinServlet when button clicked. I tried to use JAX-RS/RESTEasy client to do that. The codes looked like:

public void buttonClick( Button.ClickEvent event ) {
Client client = ClientBuilder.newClient();
try {
WebTarget target = basePath )
.queryParam( “command”, “resetpassword” );
Invocation invoker = target.request().buildGet();
Future< Response > future = invoker.submit();
Response response = future.get( 10, TimeUnit.SECONDS );
String result = response.readEntity( String.class );
catch ( TimeoutException e ) {

I used my IDE debuggging mode to monitor the the execution, and found some wierd results. When the button clicked, the invoker.submit() got executed, but no response got back. After 10 seconds, the timeout exception got caught and executed, and THEN my VaadinServlet received the client request and started to process the command. The question is that, event thought my VaadinServlet could successfully process the command, the UI could not get the response because the exception was already fired. I am wondering where I might go wrong. Please kindly advise.

Many thanks,


I did some further investigation on this issue, and found a possible cause. My scenario is that I have a custom RequestHandler registered to my VaadinSession. In my UI, I have a button. Within my button click event routine, I invoked a JRX-RS client request to that custom RequestHandler for some server processing. However, the request didn’t reach that RequestHandler until the client request timeout excetion occurred and the button clickevent routine finished. It seems to me that the button clickevent gets the VaadinSession locked, so that my client request won’t reach the ReqquestHandler until the button clickevent get finished abnormally, and the session gets unlocked. Is there any ways that I can go around the session lock issue to have my scenario done well. Please kindly advise.

Best regards,