Spring中 cl.loadClass("javax.inject.Provider") 报空指针错误

今天碰到一个错误折腾了很久.

org.springframework.beans.factory.support.DefaultListableBeanFactory.<clinit>(DefaultListableBeanFactory.java:104)
这里报空指针错误.

Spring中 cl.loadClass("javax.inject.Provider") 报空指针错误_第1张图片

错误堆栈
=================================================================
java.lang.ExceptionInInitializerError
at org.springframework.context.support.GenericApplicationContext.<init>(GenericApplicationContext.java:102)
at com.taobao.itest.spring.context.GenericXmlContextLoader.loadContext(GenericXmlContextLoader.java:36)
at com.taobao.itest.spring.context.SpringContextManager.loadApplicationContext(SpringContextManager.java:57)
at com.taobao.itest.listener.ITestSpringContextListener.prepareTestInstance(ITestSpringContextListener.java:61)
at com.taobao.itest.core.TestContextManager.prepareTestInstance(TestContextManager.java:100)
at com.taobao.itest.core.ITestJunit4ClassRunner.createTest(ITestJunit4ClassRunner.java:67)
at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:251)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:248)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at com.taobao.itest.core.statements.RunBeforeTestClass.evaluate(RunBeforeTestClass.java:49)
at com.taobao.itest.core.statements.RunAfterTestClass.evaluate(RunAfterTestClass.java:56)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
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: java.lang.NullPointerException
at org.springframework.beans.factory.support.DefaultListableBeanFactory.<clinit>(DefaultListableBeanFactory.java:104)
... 25 more


===============================================================

原因是,引入的父项目中的jar包,设置成了系统jar包导致的错误.
Spring中 cl.loadClass("javax.inject.Provider") 报空指针错误_第2张图片

去掉设置成系统jar包就可以了.
Spring中 cl.loadClass("javax.inject.Provider") 报空指针错误_第3张图片


类加载器知识补充:
http://blog.chenlb.com/2009/06/java-classloader-architecture.html

这个家伙也碰到类似的问题
http://blog.csdn.net/xiaoanian/article/details/6784371

你可能感兴趣的:(spring错误)