返回列表 发帖

shs第八章8.8实例配置问题

就是轻量级Java EE 企业应用实战那个地方,的第8章的,codes\08\8.8\booksys\WEB-INF\applicationContext.xml中加入如下代码,
  <!-- 配置事务增强处理Bean,指定事务管理器 -->
<tx:advice id="txAdvice"

transaction-manager="transactionManager">

<!-- 用于配置详细的事务定义 -->

<tx:attributes>

<!-- 所有以'get'开头的方法是read-only的 -->

<tx:method name="get*" read-only="true"/>

<!-- 其他方法使用默认的事务设置,指定超时时长为5秒 -->

<tx:method name="*" isolation="DEFAULT"

propagation="REQUIRED" timeout="5"/>

</tx:attributes>
</tx:advice>
<!-- AOP配置的元素 -->
<aop:config>

<!-- 配置一个切入点 -->

<aop:pointcut id="myPointcut" expression="bean(userService)"/>

<!-- 指定在myPointcut切入点应用txAdvice事务增强处理 -->

<aop:advisor advice-ref="txAdvice"

pointcut-ref="myPointcut"/>
</aop:config>


就会出现下面的错误
java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: Root WebApplicationContext: startup date [Fri Dec 02 14:56:45 CST 2016]; root of context hierarchy

at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:344)

at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:331)

at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:869)

at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:836)

at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:579)

at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:115)

at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:5124)

at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5786)

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.addChildInternal(ContainerBase.java:901)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)

at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)

at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:677)

at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1939)

at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)

at java.util.concurrent.FutureTask.run(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

十二月 02, 2016 2:56:46 下午 org.springframework.web.context.support.XmlWebApplicationContext doClose
警告: Exception thrown from LifecycleProcessor on context close
java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: Root WebApplicationContext: startup date [Fri Dec 02 14:56:45 CST 2016]; root of context hierarchy

at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:357)

at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:877)

at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:836)

at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:579)

at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:115)

at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:5124)

at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5786)

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.addChildInternal(ContainerBase.java:901)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)

at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)

at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:677)

at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1939)

at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)

at java.util.concurrent.FutureTask.run(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

十二月 02, 2016 2:56:46 下午 org.apache.catalina.core.StandardContext listenerStop
严重: Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener
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:170)

at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:908)

at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:884)

at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:836)

at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:579)

at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:115)

at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:5124)

at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5786)

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.addChildInternal(ContainerBase.java:901)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)

at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)

at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:677)

at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1939)

at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)

at java.util.concurrent.FutureTask.run(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

我用的是jdk1.7 64位的 tomcat也是tomcat7

JDK 用1.8
Tomcat也要用8,请参考光盘说明。
生命没有假期!
如果生命只剩下最后一秒,你可会想到我?

TOP

返回列表