2016-03-25 4 views
0

Я пытаюсь начать работу с проектом Spring. Это старый проект и должен работать. Когда я пытаюсь пройти тесты, все это сходит. Он всегда возвращает: IllegalStateException: Не удалось загрузить ApplicationContext Я не знаю, что такое ошибка, но она должна работать.Не удалось загрузить ApplicationContext (JUnit Spring)

Я использую Tomcat 8.0 Server Eclipse: Mars.2 Release (4.5.2)

трассировки одного из ошибок: (полный след: here)

java.lang.IllegalStateException: Failed to load ApplicationContext 
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124) 
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83) 
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:117) 
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83) 
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:228) 
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:217) 
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:276) 
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) 
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:278) 
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:236) 
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:87) 
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) 
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) 
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) 
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) 
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) 
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) 
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) 
at org.junit.runners.ParentRunner.run(ParentRunner.java:309) 
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180) 
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) 
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) 
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) 
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) 
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) 
+2

Восстановите FULL трассировку стека. Никаких пастебиновых связей, которые в конечном итоге гниют и сделают этот вопрос бесполезным. Убедитесь, что в общей трассе стека выделено 4 пробела. –

+0

В вашей трассировке стека: 'IllegalArgumentException: ссылка на круглое место хранения 'hibernate.hbm2ddl.auto' в определениях свойств –

+0

Полная трассировка превышает лимит сообщений Stackoverflow, поэтому я решил использовать пастик. Сожалею. – JorgeDLuffy

ответ

1

Как всегда , основной причиной является в нижней части трассировки стека:

Caused by: java.lang.IllegalArgumentException: Circular placeholder reference 'hibernate.hbm2ddl.auto' in property definitions 
    at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:141) 
    at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:162) 
    at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:126) 
    at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:204) 
    at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:178) 
    at org.springframework.core.env.AbstractPropertyResolver.resolveNestedPlaceholders(AbstractPropertyResolver.java:195) 
    at org.springframework.core.env.PropertySourcesPropertyResolver.getProperty(PropertySourcesPropertyResolver.java:87) 
    at org.springframework.core.env.PropertySourcesPropertyResolver.getProperty(PropertySourcesPropertyResolver.java:60) 
    at org.springframework.core.env.AbstractEnvironment.getProperty(AbstractEnvironment.java:511) 
    at config.PersistenceConfig.entityManagerFactory(PersistenceConfig.java:51) 
    at config.PersistenceConfig$$EnhancerBySpringCGLIB$$c115ef53.CGLIB$entityManagerFactory$1(<generated>) 
    at config.PersistenceConfig$$EnhancerBySpringCGLIB$$c115ef53$$FastClassBySpringCGLIB$$d280a0b5.invoke(<generated>) 
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) 
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:318) 
    at config.PersistenceConfig$$EnhancerBySpringCGLIB$$c115ef53.entityManagerFactory(<generated>) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:497) 
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) 
    ... 82 more 

То есть, ваш метод config.PersistenceConfig.entityManagerFactory(PersistenceConfig.java:51) пытается выглядеть до свойства hibernate.hbm2ddl.auto, значение которого определяется заполнителем, который ссылается на себя.

+0

Это строка: properties.put ("hibernate.hbm2ddl.auto", environment.getProperty ("hibernate.hbm2ddl.auto")); – JorgeDLuffy

+0

Это вы прочитали свойство, но проблема в том, где определено значение для этого свойства. – meriton

+0

Значение этого свойства определено в pom.xml и оно правильно настроено. Я до сих пор не понимаю, откуда исходит ошибка, но это не может быть из самого проекта (кода) – JorgeDLuffy

Смежные вопросы