org.springframework.beans.factory.BeanCreationException

Could not inject field: protected static com.services.SchedulerService com.test.SchedulerControllerTest.schedulerServiceTest; nested exception is java.lang.IllegalStateException: The field protected static com.services.SchedulerService com.test.SchedulerControllerTest.schedulerServiceTest cannot have an existing value

Samebug tips2

If you're using boot 1.4.x you need to modify the @springBootTest annotation to @SpringBootTest(classes = DataFlowServerConfiguration.class). 1.3.8 doesn't have this problem as well.

Spring Boot 1.4 changed their annotation system a little. Try using the @SpringBootApplication annotation for better results.

Don't give up yet. Our experts can help. Paste your full stack trace to get a solution.

Solutions on the web19385

  • Could not inject field: protected static com.services.SchedulerService com.test.SchedulerControllerTest.schedulerServiceTest; nested exception is java.lang.IllegalStateException: The field protected static com.services.SchedulerService com.test.SchedulerControllerTest.schedulerServiceTest cannot have an existing value
  • Could not autowire field: protected java.lang.String org.broadleafcommerce.common.extensibility.jpa.JPAPropertiesPersistenceUnitPostProcessor.blPUHibernateHbm2ddlImport_files_sql_extractor; nested exception is java.lang.IllegalArgumentException
  • Could not autowire field: protected java.lang.String org.broadleafcommerce.common.extensibility.jpa.JPAPropertiesPersistenceUnitPostProcessor.blPUHibernateHbm2ddlImport_files_sql_extractor; nested exception is java.lang.IllegalArgumentException
  • Stack trace

    • org.springframework.beans.factory.BeanCreationException: Could not inject field: protected static com.services.SchedulerService com.test.SchedulerControllerTest.schedulerServiceTest; nested exception is java.lang.IllegalStateException: The field protected static com.services.SchedulerService com.test.SchedulerControllerTest.schedulerServiceTest cannot have an existing value at org.springframework.boot.test.mock.mockito.MockitoPostProcessor.inject(MockitoPostProcessor.java:409)[spring-boot-test-1.5.1.RELEASE.jar:1.5.1.RELEASE] at org.springframework.boot.test.mock.mockito.MockitoPostProcessor.inject(MockitoPostProcessor.java:393)[spring-boot-test-1.5.1.RELEASE.jar:1.5.1.RELEASE] at org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener.injectFields(MockitoTestExecutionListener.java:73)[spring-boot-test-1.5.1.RELEASE.jar:1.5.1.RELEASE] at org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener.injectFields(MockitoTestExecutionListener.java:62)[spring-boot-test-1.5.1.RELEASE.jar:1.5.1.RELEASE] at org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener.prepareTestInstance(MockitoTestExecutionListener.java:49)[spring-boot-test-1.5.1.RELEASE.jar:1.5.1.RELEASE] at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230)[spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228)[spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)[spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)[junit-4.12.jar:4.12] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)[spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247)[spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)[spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)[junit-4.12.jar:4.12] at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)[junit-4.12.jar:4.12] at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)[junit-4.12.jar:4.12] at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)[junit-4.12.jar:4.12] at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)[junit-4.12.jar:4.12] at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)[spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)[spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.junit.runners.ParentRunner.run(ParentRunner.java:363)[junit-4.12.jar:4.12] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)[spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)[.cp/:na] at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)[.cp/:na] at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)[.cp/:na] at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)[.cp/:na] at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)[.cp/:na] at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)[.cp/:na] Caused by: java.lang.IllegalStateException: The field protected static com.services.SchedulerService com.test.SchedulerControllerTest.schedulerServiceTest cannot have an existing value at org.springframework.util.Assert.state(Assert.java:392)[spring-core-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.boot.test.mock.mockito.MockitoPostProcessor.inject(MockitoPostProcessor.java:400)[spring-boot-test-1.5.1.RELEASE.jar:1.5.1.RELEASE] ... 26 more

    Write tip

    You have a different solution? A short tip here would help you and many other users who saw this issue last week.

    Users with the same issue

    2 times, 2 weeks ago
    26 times, 1 day ago
    18 times, 2 months ago
    Once, 4 months ago
    8 times, 5 months ago
    64 more bugmates