Spring在类路径中定义名称为propertyPlaceholderConfigurer的bean创建时出错

时间:2010-08-27 15:57:08

标签: java spring

嗨专家

我们使用ClassPathXmlApplicationContext在类路径中使用xml文件加载bean。 它从类路径中查找并加载xml文件,但是在其中一个xml文件中,其中propertyPlaceholderConfigurer bean引用了类路径中的属性文件。它抛出空指针异常,无法创建propertyPlaceholderConfigurer bean。

不确定它是否读取属性文件,即使它是类路径,因为它可以读取其他xml文件? 财产文件是否存在数据损坏的可能性? 关于可能出现什么问题的任何线索?

Error creating bean with name 'propertyPlaceholderConfigurer' defined in class path resource [ws.xml]: Initialization of bean failed; nested exception is java.lang.NullPointerException
    at com.ibm.ejs.container.StatelessBeanO.initialize(StatelessBeanO.java:375)
    at com.ibm.ejs.container.BMStatelessBeanOFactory.create(BMStatelessBeanOFactory.java:45)
    at com.ibm.ejs.container.EJSHome.createBeanO(EJSHome.java:1031)
    at com.ibm.ejs.container.EJSHome.createBeanO(EJSHome.java:1141)
    at com.ibm.ejs.container.activator.UncachedActivationStrategy.atActivate(UncachedActivationStrategy.java:84)
    at com.ibm.ejs.container.activator.Activator.activateBean(Activator.java:599)
    at com.ibm.ejs.container.EJSContainer.preInvokeActivate(EJSContainer.java:3964)
    at com.ibm.ejs.container.EJSContainer.preInvoke(EJSContainer.java:3269)
    at com.ibm.websphere.scheduler.EJSRemoteStatelessMeFBatchHandler_fb00fe87.process(EJSRemoteStatelessMeFBatchHandler_fb00fe87.java:27)
    at com.ibm.websphere.scheduler._TaskHandler_Stub.process(_TaskHandler_Stub.java:269)
    at com.ibm.ws.scheduler.tasks.BeanTaskInfoWork.doWork(BeanTaskInfoWork.java:126)
    at com.ibm.ws.scheduler.AlarmListener.executeTaskWithNotification(AlarmListener.java:796)
    at com.ibm.ws.scheduler.AlarmListener.access$700(AlarmListener.java:121)
    at com.ibm.ws.scheduler.AlarmListener$TaskWork.doWork(AlarmListener.java:427)
    at com.ibm.ws.scheduler.AlarmListener$TaskWork.run(AlarmListener.java:213)
    at com.ibm.ws.asynchbeans.J2EEContext.run(J2EEContext.java:782)
    at com.ibm.ws.asynchbeans.ExecutionContextImpl.go(ExecutionContextImpl.java:86)
    at com.ibm.ws.scheduler.AlarmListener.fireTask(AlarmListener.java:1401)
    at com.ibm.ws.scheduler.AlarmListener.fired(AlarmListener.java:1319)
    at com.ibm.ws.asynchbeans.AlarmImpl.callListenerMethod(AlarmImpl.java:340)
    at com.ibm.ws.asynchbeans.timer.GenericTimer.run(GenericTimer.java:216)
    at com.ibm.ws.asynchbeans.J2EEContext.run(J2EEContext.java:1150)
    at com.ibm.ws.asynchbeans.AlarmImpl.runListenerAsCJWork(AlarmImpl.java:175)
    at com.ibm.ws.asynchbeans.am._Alarm.fireAlarm(_Alarm.java:333)
    at com.ibm.ws.asynchbeans.am._Alarm.run(_Alarm.java:230)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'propertyPlaceholderConfigurer' defined in class path resource [ws.xml]: Initialization of bean failed; nested exception is java.lang.NullPointerException
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:478)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    at java.security.AccessController.doPrivileged(AccessController.java:224)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:217)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:516)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:363)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)

2 个答案:

答案 0 :(得分:0)

新的ClassPathXmlApplicationContext(a.xml,b.xml,c.xml);

返回空指针异常 n,因为在c.xml中定义了propertyPlaceholderConfigurer bean,它引用了类路径中的属性文件。

答案 1 :(得分:0)

检查Spring库。如果它们具有混合/不匹配的版本,则删除旧版本的jar并替换为新版本的jar。