IllegalStateException: BeanFactory not initialized or already closed - call 'refresh'

java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
    at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:172)
    at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1090)
    at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1064)
    at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010)
    at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:549)
    at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:143)
    at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:5014)
    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5659)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

    at java.lang.Thread.run(Thread.java:745)


这是我使用cxf与spring时出现的错误:

应该是没有读取到配置文件吧

解决方案:

   




希望有用!!



tomcat启动BeanFactory not initialized or already closed - call 'refresh' before ac

04-13

tomcat启动后报错rnjava.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContextrn at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:170)rn at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1006)rn at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:982)rn at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:934)rn at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:581)rn at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:116)rn at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4858)rn at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5474)rn at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:224)rn at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:159)rn at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)rn at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)rn at java.util.concurrent.FutureTask.run(FutureTask.java:266)rn at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)rn at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)rn at java.lang.Thread.run(Thread.java:745)rn请问大神这个是怎么回事,我的配置文件是写在web.xml中的 rn

java.lang.IllegalStateException: BeanFactory not initialized or already closed

12-14

在进行SSh整合时,启动服务器出现了很多异常,其中一个是Caused by: java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor,但是我已经添加了aopalliance-1.0.jar,还是找不到这个类,rn[code=java]严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListenerrnorg.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [applicationContext.xml]; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptorrn at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:413)rn at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)rn at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)rn at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)rn at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:216)rn at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:187)rn at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)rn at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)rn at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)rn at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:540)rn at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:454)rn at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)rn at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)rn at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)rn at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4210)rn at org.apache.catalina.core.StandardContext.start(StandardContext.java:4709)rn at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)rn at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)rn at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:583)rn at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)rn at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)rn at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)rn at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)rn at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)rn at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)rn at org.apache.catalina.core.StandardHost.start(StandardHost.java:822)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)rn at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)rn at org.apache.catalina.core.StandardService.start(StandardService.java:525)rn at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)rn at org.apache.catalina.startup.Catalina.start(Catalina.java:595)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)rn at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)rnCaused by: java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptorrn at java.lang.ClassLoader.defineClass1(Native Method)rn at java.lang.ClassLoader.defineClass(ClassLoader.java:621)rn at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)rn at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2854)rn at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159)rn at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)rn at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)rn at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)rn at org.springframework.transaction.config.AnnotationDrivenBeanDefinitionParser$AopAutoProxyConfigurer.configureAutoProxyCreator(AnnotationDrivenBeanDefinitionParser.java:127)rn at org.springframework.transaction.config.AnnotationDrivenBeanDefinitionParser.parse(AnnotationDrivenBeanDefinitionParser.java:84)rn at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:74)rn at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1424)rn at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1414)rn at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:187)rn at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:141)rn at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:110)rn at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:508)rn at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)rn ... 37 morernCaused by: java.lang.ClassNotFoundException: org.aopalliance.intercept.MethodInterceptorrn at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)rn at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)rn at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)rn ... 55 morern2014-12-14 16:30:43 org.apache.catalina.core.StandardContext startrn严重: Error listenerStartrn2014-12-14 16:30:43 org.apache.catalina.core.StandardContext startrn严重: Context [/ssh] startup failed due to previous errorsrn2014-12-14 16:30:43 org.apache.catalina.core.ApplicationContext logrn信息: Closing Spring root WebApplicationContextrn2014-12-14 16:30:43 org.apache.catalina.core.StandardContext listenerStoprn严重: Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListenerrnjava.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContextrn at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:170)rn at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:921)rn at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:895)rn at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:841)rn at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:579)rn at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:115)rn at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4249)rn at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4890)rn at org.apache.catalina.core.StandardContext.start(StandardContext.java:4754)rn at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)rn at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)rn at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:583)rn at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)rn at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)rn at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)rn at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)rn at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)rn at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)rn at org.apache.catalina.core.StandardHost.start(StandardHost.java:822)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)rn at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)rn at org.apache.catalina.core.StandardService.start(StandardService.java:525)rn at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)rn at org.apache.catalina.startup.Catalina.start(Catalina.java:595)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)rn at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)[/code]rnrn求救,已经搞了半个下午了

求助错误,BeanFactory not initialized or already closed

10-17

[b]rnjunit4测试报错[/b]rnrnjava.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContextrn at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:153)rn at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:880)rn at com.test.testUserService.testAdd(testUserService.java:16)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at junit.framework.TestCase.runTest(TestCase.java:164)rn at junit.framework.TestCase.runBare(TestCase.java:130)rn at junit.framework.TestResult$1.protect(TestResult.java:110)rn at junit.framework.TestResult.runProtected(TestResult.java:128)rn at junit.framework.TestResult.run(TestResult.java:113)rn at junit.framework.TestCase.run(TestCase.java:120)rn at junit.framework.TestSuite.runTest(TestSuite.java:228)rn at junit.framework.TestSuite.run(TestSuite.java:223)rn at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)rn at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)rn at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)rnrnrnpackage com.test;rnrnimport junit.framework.TestCase;rnrnimport org.springframework.context.ApplicationContext;rnimport org.springframework.context.support.ClassPathXmlApplicationContext;rnrnimport com.model.User;rnimport com.service.UserService;(省略了包的导入)rnrnpublic class testUserService extends TestCase rnrn public void testAdd()rn ApplicationContext ctx = new ClassPathXmlApplicationContext();rn rn UserService service = (UserService)ctx.getBean("bean.xml");rn rn User user = new User();rn rn user.setName("a");rn user.setPassword("b");rn service.add(user);rn rnrnrnrnrnrn rn rn rnrn rn rn rnrn rnrn rnrn

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试

关闭