开发者社区> 问答> 正文

使用Session监听器无法监听到,各位大神帮帮忙

screenshot
错误代码
严重: Error configuring application listener of class com.fh.listener.SessionListener
javax.naming.NamingException: Cannot create resource instance
at org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceEnvFactory.java:115)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
at org.apache.naming.NamingContext.lookup(NamingContext.java:842)
at org.apache.naming.NamingContext.lookup(NamingContext.java:167)
at org.apache.catalina.core.DefaultInstanceManager.lookupFieldResource(DefaultInstanceManager.java:557)
at org.apache.catalina.core.DefaultInstanceManager.processAnnotations(DefaultInstanceManager.java:449)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:135)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:116)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4933)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5531)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

展开
收起
a123456678 2016-03-10 11:57:03 4196 0
1 条回答
写回答
取消 提交回答
  • Web容器启动的时候就是通过监听来管理Bean的。在监听HttpSessionListener是还未完成Bean的注入,可以使用
    WebApplicationContext wb =WebApplicationContextUtils.getWebApplicationContext(arg0.getSession().getServletContext());
    userService = (UserService)wb.getBean("userService");
    来获取bean

    2019-07-17 18:57:23
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载