IDEA模块中web.xml找不到监听器

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/innovate1989/article/details/83478474

我在做品优购项目的时候module名称写错了,改了一下后,发现web.xml中的监听器颜色变红了。删除module后重新建立还是这个样子,在网上查了一下这种情况是由于缺少了spring相关的jar包导致的。有两种思路可以添加缺失的jar包。

1.在模块依赖界面

使用快捷键Ctrl+shift+Alt+S进入到Project Structure界面,找到相关的module后,点击该模块,在module的右边选择dependencies选项卡后,点击右边的+号添加缺失的jar包。
https://img-blog.csdnimg.cn/20181028210424537.png

2.在iml文件

以前没有注意module生成之后的iml文件,在这个文件中添加我们需要的jar更方便一些。前提是我们知道我们需要什么jar或者依赖过什么module。我的方法是先看一下我们的module依赖了那些module,然后再看看除了这些module外还依赖了哪些jar包。先将依赖的module的iml文件打开找到相应的maven依赖的jar复制到我们的iml文件中,再将其他的jar包依赖写到我们的iml文件中就OK了。
https://img-blog.csdnimg.cn/20181028211428893.png

展开阅读全文

spring+hibernate+flex中的web.xml监听器错误

06-21

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListenerrnorg.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [biz.Mybiz] for bean with name 'mybiz' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: Bad version number in .class filernCaused by: java.lang.UnsupportedClassVersionError: Bad version number in .class filern at java.lang.ClassLoader.defineClass1(Native Method)rn at java.lang.ClassLoader.defineClass(Unknown Source)rn at java.security.SecureClassLoader.defineClass(Unknown Source)rn at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1817)rn at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:872)rn at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1325)rn at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)rn at org.springframework.util.ClassUtils.forName(ClassUtils.java:201)rn at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:327)rn at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1066)rn at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:282)rn at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)rn at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244)rn at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187)rn at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)rn at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3830)rn at org.apache.catalina.core.StandardContext.start(StandardContext.java:4337)rn at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)rn at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)rn at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)rn at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)rn at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)rn at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)rn at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)rn at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)rn at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)rn at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)rn at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)rn at org.apache.catalina.core.StandardService.start(StandardService.java:516)rn at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)rn at org.apache.catalina.startup.Catalina.start(Catalina.java:566)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)rn at java.lang.reflect.Method.invoke(Unknown Source)rn at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)rn at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) 论坛

web.xml加入监听器出现异常

11-02

[code=Java]rnpackage com.myListener;rnimport javax.servlet.http.HttpSessionEvent;rnimport javax.servlet.http.HttpSessionListener;rnrnpublic class SessionListener implements HttpSessionListenerrn static private int activeSession;rn rn public static int getActiveSession()rn return activeSession;rn rn rn public void sessionCreated(HttpSessionEvent se)rn activeSession++;rn rn rn public void sessionDestroyed(HttpSessionEvent se)rn activeSession--;rn rnrn[/code]rnrn[code=Java]rnpackage com.myServlet;rnrnimport java.io.IOException;rnimport java.io.PrintWriter;rnimport javax.servlet.ServletException;rnimport javax.servlet.http.HttpServlet;rnimport javax.servlet.http.HttpServletRequest;rnimport javax.servlet.http.HttpServletResponse;rnimport javax.servlet.http.HttpSession;rnimport com.myListener.SessionListener;rnrnpublic class DispHttpSession extends HttpServlet rn public void doGet(HttpServletRequest request, HttpServletResponse response)rn throws ServletException, IOException rnrn response.setContentType("text/html;charset=gb2312");rn PrintWriter out = response.getWriter();rn out.println("");rn out.println(" myServlet");rn out.println(" ");rn out.println(" 测试监听会话个数");rn HttpSession session = request.getSession();rn out.println(SessionListener.getActiveSession());rn out.println(" ");rn out.println("");rn out.println("");rn out.println(" ");rn out.println("");rn out.flush();rn out.close();rn rnrn public void doPost(HttpServletRequest request, HttpServletResponse response)rn throws ServletException, IOException rn doGet(request,response);rn rnrn[/code]rn[code=Java]rnpackage com.myServlet;rnimport java.io.IOException;rnimport java.io.PrintWriter;rnimport javax.servlet.ServletException;rnimport javax.servlet.http.HttpServlet;rnimport javax.servlet.http.HttpServletRequest;rnimport javax.servlet.http.HttpServletResponse;rnimport javax.servlet.http.HttpSession;rnimport com.myListener.SessionListener;rnrnpublic class OverHttpSession extends HttpServlet rnrn public void doGet(HttpServletRequest request, HttpServletResponse response)rn throws ServletException, IOException rnrn response.setContentType("text/html;charset=gb2312");rn PrintWriter out = response.getWriter();rn out.println("");rn out.println(" outServlet");rn out.println(" ");rn out.println(" 会话结束");rn HttpSession session = request.getSession();rn session.invalidate();rn out.println(SessionListener.getActiveSession());rn out.println(" ");rn out.println("");rn out.flush();rn out.close();rn rnrn public void doPost(HttpServletRequest request, HttpServletResponse response)rn throws ServletException, IOException rn doGet(request,response);rn rnrn[/code]rnweb.xmlrn[code=Java]rnrnrn rn rn This is the description of my J2EE componentrn This is the display name of my J2EE componentrn DispHttpSessionrn com.myServlet.DispHttpSessionrn rn rn This is the description of my J2EE componentrn This is the display name of my J2EE componentrn OverHttpSessionrn com.myServlet.OverHttpSessionrn rnrn rn DispHttpSessionrn /servlet/DispHttpSessionrn rn rn OverHttpSessionrn /servlet/OverHttpSessionrn rn rn index.jsprn rnrnrn[/code]rnrn在web.xml加入rn com.myServlet.SessionListenerrn rn就出现异常rn[code=Java]rnweblogic.application.ModuleException: Failed to load webapp: 'ServletExample'rn at weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:387)rn at weblogic.application.internal.flow.ScopedModuleDriver.prepare(ScopedModuleDriver.java:176)rn at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93)rn at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:387)rn at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)rn Truncated. see log file for complete stacktracernjava.lang.ClassNotFoundException: com.myServlet.SessionListenerrn at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:283)rn at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)rn at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:54)rn at java.lang.ClassLoader.loadClass(ClassLoader.java:307)rn at java.lang.ClassLoader.loadClass(ClassLoader.java:252)rn Truncated. see log file for complete stacktracern> rn[/code]rn请问如何解决? 论坛

web.xml配置org.springframework.web.context.ContextLoaderListener监听器出错

12-28

我在web.xml里面加入了监听器(这个工程是用的myeclipse5.5的 struts1.2 + spring2.0 +hibernate 3.0)rnrn org.springframework.web.context.ContextLoaderListenerrnrn但是启动tomcat的时候回出现以下错误rn2007-12-28 14:16:40 org.apache.catalina.core.StandardHost startrn信息: XML validation disabledrnlog4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester).rnlog4j:WARN Please initialize the log4j system properly.rn2007-12-28 14:16:58 org.apache.catalina.core.StandardContext startrn严重: Error listenerStartrn2007-12-28 14:16:58 org.apache.catalina.core.StandardContext startrn严重: Context [/b2b.china315.com] startup failed due to previous errorsrn2007-12-28 14:16:59 org.apache.catalina.core.ApplicationContext logrn信息: org.apache.webapp.balancer.BalancerFilter: init(): ruleChain: 。。。。。。。。。。。。。。。。。。rnrn请高手指教,我的applicationContex.xml分成了applicationContext-actions.xml 、applicationContext-common.xml和applicationContext-managers.xml 下面我把各个文件粘贴下来rn================================================rnapplicationContex.xml :内容如下rn===========================================rnrnrnrnrnrn rnrn===================================rnapplicationContext-common.xml内容如下rn====================================rnrnrnrnrn rn classpath:hibernate.cfg.xml rn rnrnrnrnrn rn rn rnrnrnrnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rnrn rnrnrn rn rnrn rnrn======================================rnapplicationContext-managers.xml 内容如下rn======================================rnrnrnrnrnrnrnrn 论坛

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