`

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

阅读更多
今天碰到一个错误折腾了很久.

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



错误堆栈
=================================================================
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包导致的错误.


去掉设置成系统jar包就可以了.



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

这个家伙也碰到类似的问题
http://blog.csdn.net/xiaoanian/article/details/6784371
  • 大小: 48.7 KB
  • 大小: 171.6 KB
  • 大小: 23.5 KB
分享到:
评论

相关推荐

    javax.inject.Provider

    Spring 依赖的 javax.inject.Provider

    javax.enterprise.inject.spi.BeanManagerjar包

    javax.enterprise.inject.spi.BeanManager jar文件,jboss用到了,但是很烦,是javaee6 的东西,历经千辛万苦找到的

    javax-inject-1.0-201002241208.jar.zip

    在实际项目中,结合合适的依赖注入容器,如Guice或Spring,可以进一步发挥javax.inject的优势,实现更加高效和灵活的代码结构。同时,javax.inject与Hibernate的整合,让数据访问层的管理也变得更加简洁和规范。

    javax.persistence.jar

    javax.persistence.PostLoad.class javax.persistence.PostPersist.class javax.persistence.PostRemove.class javax.persistence.PostUpdate.class javax.persistence.PrePersist.class javax.persistence....

    javax.jms.jar下载

    javax.jms.BytesMessage.class javax.jms.Connection.class javax.jms.ConnectionConsumer.class javax.jms.ConnectionFactory.class javax.jms.ConnectionMetaData.class javax.jms.DeliveryMode.class javax.jms....

    javax.jms.jar

    Classes contained in javax.jms.jar: javax.transaction.xa.XAResource.class javax.jms.BytesMessage.class javax.jms.Message.class javax.jms.JMSException.class javax.jms.Destination.class javax.jms....

    javax.ejb.jar下载

    javax.ejb.AccessLocalException.class javax.ejb.AccessTimeout.class javax.ejb.ActivationConfigProperty.class javax.ejb.AfterBegin.class javax.ejb.AfterCompletion.class javax.ejb.ApplicationException....

    javax.servlet.jar下载

    Files contained in javax.servlet.jar: META-INF/MANIFEST.MF javax/servlet/http/LocalStrings.properties javax.servlet.http.HttpSessionBindingListener.class javax.servlet....

    java的ejb.jar包

    javax.ejb.AccessLocalException.class javax.ejb.CreateException.class javax.ejb.DuplicateKeyException.class javax.ejb.EJBContext.class javax.ejb.EJBException.class javax.ejb.EJBHome.class javax.ejb....

    官方jar包javax-inject.jar

    【标题】"官方jar包javax-inject.jar"指的是Java编程语言中的一个官方发布的库文件,主要包含`javax.inject`包下的类和接口。这个jar包是Java依赖注入(Dependency Injection,简称DI)的一个实现,主要用于简化对象...

    javax.ejb.rar

    javax.ejb.AccessLocalException.class javax.ejb.AccessTimeout.class javax.ejb.ActivationConfigProperty.class javax.ejb.AfterBegin.class javax.ejb.AfterCompletion.class javax.ejb.ApplicationException....

    javax.inject-1.jar

    支持注入,spring ,类别注入,很好用的jar包,还有原码和文档

    Unable to load class ‘javax.xml.bind.JAXBException‘(csdn).pdf

    在Android Studio中遇到"Unable to load class ‘javax.xml.bind.JAXBException‘"的错误,通常是由于Java运行时环境(JRE)或开发工具包(JDK)与项目的兼容性问题导致的。`javax.xml.bind.JAXBException`是Java的...

    javax.ejb.jar

    javax.ejb.AccessLocalException.class javax.ejb.AccessTimeout.class javax.ejb.ActivationConfigProperty.class javax.ejb.AfterBegin.class javax.ejb.AfterCompletion.class javax.ejb.ApplicationException....

    javax.jar 包免费下载

    javax.jar javax.jar javax.jar javax.jar javax.jar javax.jar javax.jar javax.jar javax.jar javax.jar javax.jar javax.jar javax.jar javax.jar javax.jar javax.jar javax.jar javax.jar javax.jar javax.jar ...

    com.springsource.javax.inject-0.9.0.PFD.jar

    jar包,官方版本,自测可用

    com.springsource.javax.inject-1.0.0.jar

    com.springsource.javax.inject-1.0.0.jar

    com.springsource.javax.inject_1.0.0.jar

    jar包,官方版本,自测可用

    java.lang.NoClassDefFoundError: javax/persistence/EntityListener

    `javax.persistence.EntityListener`是JPA中用于定义实体监听器的接口,它允许在实体生命周期的特定事件上执行操作,比如在保存或删除实体时。 在Java应用中,NoClassDefFoundError通常由以下原因引起: 1. **依赖...

    javax.el-api.jar/javax.el.jar

    在Java世界中,EL(Expression Language)是一种强大的脚本语言...在给定的文件列表中,`javax.el-2.2.4.jar`和`javax.el-api-2.2.4.jar`是EL 2.2版本的实现和API,可以被用来支持和增强Java EE应用中的EL表达式处理。

Global site tag (gtag.js) - Google Analytics