Assert.state() has thrown an IllegalStateException

java.lang.IllegalStateException
Javadoc
Signals that a method has been invoked at an illegal or inappropriate time. In other words, the Java environment or Java application is not in an appropriate state for the requested operation. @author Jonni Kanerva @since JDK1.1
at org.springframework.util.Assert.state
Source

Typical Exception Messages

  1. Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
  2. Cannot load driver class: com.mysql.jdbc.Driver
  3. Unable to configure LocalContainerEntityManagerFactoryBean from @EntityScan, ensure an appropriate bean is registered.
  4. Can't set AsyncWebRequest with concurrent handling in progress
  5. Cannot find changelog location: class path resource [db/changelog/db.changelog-master.yaml] (please add changelog or check your Liquibase configuration)
  6. A type to convert the input into is required.
  7. Cannot find template location: classpath:/templates/ (please add some templates, check your Velocity configuration, or set spring.velocity.checkTemplateLocation=false)
  8. Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration)
  9. Could not find current request via RequestContextHolder
  10. Could not find current request via RequestContextHolder. Is this being called from a Spring MVC handler?

Specific cases

We have seen this error pattern in the following webpages (227)

  1. Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.mysql.jdbc.Driver
  2. zbmwmxvia GitHub5 days ago
    Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
  3. Cannot load driver class: com.mysql.jdbc.Driver
  4. xscorpio972via GitHub2 weeks ago
    Error creating bean with name 'org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration$LiquibaseConfiguration': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Cannot find changelog location: class path resource [db/changelog/db.changelog-master.yaml] (please add changelog or check your Liquibase configuration)
  5. ouyangjjvia Stack Overflow2 weeks ago
    Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/abroad-service-api]]
  6. Johnvia Stack Overflow3 weeks ago
    Request URI does not contain a valid hostname: http://user_microservice/api/user/599f877c8e365c0001cec8d1
  7. Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.mysql.jdbc.Driver
  8. Error creating bean with name 'b' defined in cz.berger.safechat.SafechatApplication: Invocation of init method failed; nested exception is java.lang.IllegalStateException: TokenServices are required
  9. Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: oracle.jdbc.OracleDriver
  10. Failed to load ApplicationContext