Note that there are some explanatory texts on larger screens.

plurals
  1. POSubsequent REST call is blocked until previous one is finished
    text
    copied!<p>I Have REST service</p> <pre><code>@Path("/rest") @Component public class MyRestService { @Inject private MyBean bean; @GET @Path("/do") public String start() { this.logger.info("Before do " + Thread.currentThread().getId()); String result = this.bean.do(); this.logger.info("After do " + Thread.currentThread().getId()); return result; } } </code></pre> <p>which calls method of injected Spring singleton bean (with some state inside)</p> <pre><code>@Service public class MyBean { public String do() { // do something big... } } </code></pre> <p>When I call ".../rest/do" in browser the first call goes as expected, but if I make same call in another tab this call waits until first is finished to process second call in same thread.</p> <p>If I do second call as ".../rest/do?async=true" it does not wait and processes second request in new thread, but if I do both requests as ".../rest/do?async=true" - second one again waits for the first one to finish.</p> <p>What could be the reason for such behavior? Is it actually expected?</p> <p>My web.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"&gt; &lt;welcome-file-list&gt; &lt;welcome-file&gt;index.html&lt;/welcome-file&gt; &lt;/welcome-file-list&gt; &lt;display-name&gt;My REst&lt;/display-name&gt; &lt;!-- spring configuration by annotations --&gt; &lt;context-param&gt; &lt;param-name&gt;contextClass&lt;/param-name&gt; &lt;param-value&gt;org.springframework.web.context.support.AnnotationConfigWebApplicationContext&lt;/param-value&gt; &lt;/context-param&gt; &lt;!-- spring configuration class --&gt; &lt;context-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt;app.Config&lt;/param-value&gt; &lt;/context-param&gt; &lt;!-- to return data according to extension --&gt; &lt;context-param&gt; &lt;param-name&gt;resteasy.media.type.mappings&lt;/param-name&gt; &lt;param-value&gt;json : application/json, xml : application/xml&lt;/param-value&gt; &lt;/context-param&gt; &lt;!-- this has to match with resteasy-servlet url-pattern --&gt; &lt;context-param&gt; &lt;param-name&gt;resteasy.servlet.mapping.prefix&lt;/param-name&gt; &lt;param-value&gt;/rest&lt;/param-value&gt; &lt;/context-param&gt; &lt;listener&gt; &lt;listener-class&gt;org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap&lt;/listener-class&gt; &lt;/listener&gt; &lt;!-- resteasy spring connector (to use DI in rest-resources) --&gt; &lt;listener&gt; &lt;listener-class&gt;org.jboss.resteasy.plugins.spring.SpringContextLoaderListener&lt;/listener-class&gt; &lt;/listener&gt; &lt;servlet&gt; &lt;servlet-name&gt;resteasy-servlet&lt;/servlet-name&gt; &lt;servlet-class&gt;org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher&lt;/servlet-class&gt; &lt;/servlet&gt; &lt;!-- this has to match with resteasy-servlet url-pattern --&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;resteasy-servlet&lt;/servlet-name&gt; &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;!-- Bind Jboss's TransactionManager (EntityManagerFactory) to JNDI --&gt; &lt;persistence-unit-ref&gt; &lt;persistence-unit-ref-name&gt;persistence/ReferenceDataDS&lt;/persistence-unit-ref-name&gt; &lt;persistence-unit-name&gt;ReferenceDataDS&lt;/persistence-unit-name&gt; &lt;/persistence-unit-ref&gt; &lt;/web-app&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload