java.lang.IllegalStateException: Async result for handler [public <HIDDEN>] was not set during the specified timeToWait=0

Spring JIRA | Dan Parrella | 2 years ago
  1. 0

    When running controller tests against endpoints that are asynchronous and using the {{PrintResultHandler}}, my tests always fail because the {{PrintResultHandler}} seems to attempt to print the result before it is available. When the endpoint is asynchronous, I would expect that we wait to print until {{asyncDispatch(mvcResult)}} gets called or waiting some period of time before the result becomes available. h4. Example Code {code:java} final MvcResult mvcResult = getMockMvc().perform(post(<ASYNC_ENDPOINT>)) .andExpect(request().asyncStarted()) .andExpect(request().asyncResult(instanceOf(WebResponse.class))) .andReturn(); getMockMvc().perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()); {code} h4. Stack Trace {noformat} java.lang.IllegalStateException: Async result for handler [public <HIDDEN>] was not set during the specified timeToWait=0 at org.springframework.util.Assert.state(Assert.java:385) at org.springframework.test.web.servlet.DefaultMvcResult.getAsyncResult(DefaultMvcResult.java:143) at org.springframework.test.web.servlet.result.PrintingResultHandler.printAsyncResult(PrintingResultHandler.java:131) at org.springframework.test.web.servlet.result.PrintingResultHandler.handle(PrintingResultHandler.java:79) at org.springframework.test.web.servlet.MockMvc.applyDefaultResultActions(MockMvc.java:176) at org.springframework.test.web.servlet.MockMvc.perform(MockMvc.java:146) {noformat}

    Spring JIRA | 2 years ago | Dan Parrella
    java.lang.IllegalStateException: Async result for handler [public <HIDDEN>] was not set during the specified timeToWait=0
  2. 0

    When running controller tests against endpoints that are asynchronous and using the {{PrintResultHandler}}, my tests always fail because the {{PrintResultHandler}} seems to attempt to print the result before it is available. When the endpoint is asynchronous, I would expect that we wait to print until {{asyncDispatch(mvcResult)}} gets called or waiting some period of time before the result becomes available. h4. Example Code {code:java} final MvcResult mvcResult = getMockMvc().perform(post(<ASYNC_ENDPOINT>)) .andExpect(request().asyncStarted()) .andExpect(request().asyncResult(instanceOf(WebResponse.class))) .andReturn(); getMockMvc().perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()); {code} h4. Stack Trace {noformat} java.lang.IllegalStateException: Async result for handler [public <HIDDEN>] was not set during the specified timeToWait=0 at org.springframework.util.Assert.state(Assert.java:385) at org.springframework.test.web.servlet.DefaultMvcResult.getAsyncResult(DefaultMvcResult.java:143) at org.springframework.test.web.servlet.result.PrintingResultHandler.printAsyncResult(PrintingResultHandler.java:131) at org.springframework.test.web.servlet.result.PrintingResultHandler.handle(PrintingResultHandler.java:79) at org.springframework.test.web.servlet.MockMvc.applyDefaultResultActions(MockMvc.java:176) at org.springframework.test.web.servlet.MockMvc.perform(MockMvc.java:146) {noformat}

    Spring JIRA | 2 years ago | Dan Parrella
    java.lang.IllegalStateException: Async result for handler [public <HIDDEN>] was not set during the specified timeToWait=0
  3. 0

    Exception after upgrading to 1.2.0.RELEASE from 1.1.9.RELEASE

    GitHub | 2 years ago | mtm0riah
    org.springframework.beans.factory.BeanDefinitionStoreException: Failed to load bean class: ; nested exception is java.lang.IllegalStateException: Error processing condition on org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration$SolrHealthIndicatorConfiguration
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    ThymeleafAutoConfiguration throws "IllegalStateException: Cannot find template location" even when controller method returns ResponseEntity

    GitHub | 2 years ago | ceefour
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafViewResolverConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.thymeleaf.spring4.SpringTemplateEngine org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafViewResolverConfiguration.templateEngine; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafDefaultConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private final java.util.Collection org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafDefaultConfiguration.templateResolvers; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$DefaultTemplateResolverConfiguration': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Cannot find template location: class path resource [templates/] (please add some templates or check your Thymeleaf configuration)
  6. 0

    IllegalStateException: Registration is null when migrating RC3 -> RC4

    GitHub | 3 years ago | tkruse
    java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]

  1. tvrmsmith 2 times, last 2 weeks ago
  2. tvrmsmith 4 times, last 1 month ago
  3. schoetty 8 times, last 7 months ago
  4. Александр Пастухов 1 times, last 7 months ago
48 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.IllegalStateException

    Async result for handler [public <HIDDEN>] was not set during the specified timeToWait=0

    at org.springframework.util.Assert.state()
  2. Spring Core
    Assert.state
    1. org.springframework.util.Assert.state(Assert.java:385)
    1 frame
  3. Spring TestContext
    MockMvc.perform
    1. org.springframework.test.web.servlet.DefaultMvcResult.getAsyncResult(DefaultMvcResult.java:143)
    2. org.springframework.test.web.servlet.result.PrintingResultHandler.printAsyncResult(PrintingResultHandler.java:131)
    3. org.springframework.test.web.servlet.result.PrintingResultHandler.handle(PrintingResultHandler.java:79)
    4. org.springframework.test.web.servlet.MockMvc.applyDefaultResultActions(MockMvc.java:176)
    5. org.springframework.test.web.servlet.MockMvc.perform(MockMvc.java:146)
    5 frames