1. 程式人生 > >Junit4測試錯誤解決java.lang.IllegalStateException: Failed to load ApplicationContext

Junit4測試錯誤解決java.lang.IllegalStateException: Failed to load ApplicationContext

2013-09-22 15:51:42,000 ERROR (org.springframework.test.context.TestContextManager:315) - Caught exception while allowing TestExecutionListener [org.springframewor[email protected]1002a83] to prepare test instance [[email protected]]
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:157)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:313)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:288)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:284)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88)
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:71)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Association references unmapped class: com.roc.ppms.domain.NewsCol
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1486)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:589)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:106)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:57)
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:100)
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:248)
at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:124)
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:148)
... 24 more
Caused by: org.hibernate.MappingException: Association references unmapped class: com.roc.ppms.domain.NewsCol
at org.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinder.java:2503)
at org.hibernate.cfg.HbmBinder$CollectionSecondPass.secondPass(HbmBinder.java:2782)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:65)
at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1716)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1423)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1375)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:720)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:188)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483)

... 39 more

解決辦法

按照xml檔案載入順序查詢(例如ApplicationContext),最終找到是一個hbm.xml少寫了個屬性導致

相關推薦

Junit4測試錯誤解決java.lang.IllegalStateException: Failed to load ApplicationContext

2013-09-22 15:51:42,000 ERROR (org.springframework.test.context.TestContextManager:315) - Caught exception while allowing TestExecutionLi

java.lang.IllegalStateException: Failed to load ApplicationContext錯誤解決

java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.cache.DefaultCacheAwareContextLoa

java.lang.IllegalStateException: Failed to load ApplicationContext 解決辦法思考

一般情況出現這個情況  為xml配置錯誤 (分析在文章末尾)目前我的錯誤提示如下:注意看caused by 的具體內容java.lang.IllegalStateException: Failed to load ApplicationContextat org.spring

關於Spring提示java.lang.IllegalStateException: Failed to load ApplicationContext問題解決

學習中遇到了Spring報如下錯誤  java.lang.IllegalStateException: Failed to load ApplicationContext 細究其原因: Caused by: org.xml.sax.SAXParseException;

java.lang.IllegalStateException: Failed to load ApplicationContext

error for IT location method 錯誤 int pac 博客 java Spring AOP編寫MAVEN項目,編譯時出現錯誤提示如下: java.lang.IllegalStateException: Failed to load Applicat

java.lang.IllegalStateException: Failed to load ApplicationContext(2)

def tin TE lac ava .com nco tex 連接 錯誤提示:java.lang.IllegalStateException: Failed to load ApplicationContext Caused by: org.springframework

【application.yml配置問題】java.lang.IllegalStateException: Failed to load ApplicationContext

我在springboot中遇到的錯如下: java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.cache.DefaultCacheAw

maven單元測試java lang IllegalStateException Failed to load Ap

                從網上查了兩個原因: 1.報這個異常java.lang.IllegalStateExcepti

java.lang.IllegalStateException: Failed to load property source from location

在學習springcloud的config客戶端通過config服務端讀取github檔案時遇到了如下問題 2018-11-12 16:45:34.567 ERROR 1312 --- [on(2)-127.0.0.1] o.s.boot.SpringApplication

java.lang.IllegalStateException: Failed to load property source from location 'classpath:/application-dev.yml'

如果你的專案沒有配置錯誤,配置檔名稱也正常,還出現這個問題,那一定是你的yml檔案編碼的問題 先附上一張專案架構圖 當我啟動伺服器尋找配置檔案的時候,伺服器提示這樣的錯誤資訊 java.lang.IllegalStateException: Failed to load property so

IDEA 啟動報錯:java.lang.IllegalStateException: failed to create a child event loop 問題解決

遇到的問題 昨天電腦自動更新了,今天死活啟動不了專案,看到idea的提示是: idea日誌如下 根據提示說 檢視idea的啟動日誌: 2018-11-20 17:35:42,010 [ 46737] INFO - plication.impl.Applicat

Java 條碼生成庫 Barcode4J Maven 依賴缺失錯誤 java.lang.IllegalStateException: Failed to introspect Class

前段時間專案中需要生成商品條碼,使用 Barcode4J 庫實現的,直接使用了內部的 BarcodeServlet ,僅在 Spring MVC 的 Controller 裡簡單的封裝了下提供個訪問路徑,使用上沒有遇到任何問題。程式碼如下: import jav

Springboot jar 部署java.lang.IllegalStateException: Failed to get nested archive for entry BOOT-INF/li

Exception in thread "main" java.lang.IllegalStateException: Failed to get nested archive for entry BOOT-INF/lib/byte-buddy-1.7.11.jar at

Allocate exception for servlet springmvc java.lang.IllegalStateException: Failed to check the status

品優購異常資訊 嚴重: Allocate exception for servlet springmvc java.lang.IllegalStateException: Failed to check the status of the service com.pinyougou.pa

Android8.0 適配ContentResolver解決java.lang.SecurityException: Failed to find provider null for user 0;

對於沒有適配Android8.0+的裝置在使用ContenResolver時會出現java.lang.SecurityException: Failed to find provider null for user 0; expected to find a valid Co

用idea+maven編譯打包spark project core錯誤java.lang.RuntimeException: Unable to load a Suite class

ide exception 5-0 sco anon time arp create run Discovery starting. *** RUN ABORTED *** java.lang.RuntimeException: Unable to load a Su

netty使用epoll報錯:java.lang.UnsatisfiedLinkError: failed to load the required native library

Caused by: java.lang.UnsatisfiedLinkError: could not load a native library: netty_transport_native_epoll_x86_64 最近修改moquette程式碼, NettyAcc

解決IllegalStateException: Failed to load ApplicationContext 方法

at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)

暫時解決java.lang.IllegalStateException: It is invalid to call isReady() when the response has not been put into non-blocking mode

服務器 lose img () arguments it is 分享 exc 解決 環境: 本機-apache-tomcat-9.0.0.M21 服務器-apache-tomcat-9.0.0.M9 錯誤復盤: 最初不知道是tomcat版本解決的,實現了

解決java.lang.IllegalStateException: Not allowed to start service Intent xxxx app is in background u

問題描述 java.lang.IllegalStateException: Not allowed to start service Intent xxxx app is in background uid UidRecord 原因分析 Android 8.0 有以下調整: An