请问监听器为什么没起到效果?
C:\apache-tomcat-8.5.37-windows-x64\apache-tomcat-8.5.37\bin\catalina.bat run [2019-07-13 01:08:34,400] Artifact webapp: Waiting for server connection to start artifact deployment... Using CATALINA_BASE: "C:\Users\Jun\.IntelliJIdea2018.1\system\tomcat\Unnamed_User_MybatisPro" Using CATALINA_HOME: "C:\apache-tomcat-8.5.37-windows-x64\apache-tomcat-8.5.37" Using CATALINA_TMPDIR: "C:\apache-tomcat-8.5.37-windows-x64\apache-tomcat-8.5.37\temp" Using JRE_HOME: "C:\Program Files\Java\jdk1.8.0_161" Using CLASSPATH: "C:\apache-tomcat-8.5.37-windows-x64\apache-tomcat-8.5.37\bin\bootstrap.jar;C:\apache-tomcat-8.5.37-windows-x64\apache-tomcat-8.5.37\bin\tomcat-juli.jar" 13-Jul-2019 01:08:35.751 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.5.37 13-Jul-2019 01:08:35.754 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Dec 12 2018 12:07:02 UTC 13-Jul-2019 01:08:35.754 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.5.37.0 13-Jul-2019 01:08:35.754 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 10 13-Jul-2019 01:08:35.754 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 10.0 13-Jul-2019 01:08:35.754 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64 13-Jul-2019 01:08:35.754 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\Java\jdk1.8.0_161\jre 13-Jul-2019 01:08:35.754 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_161-b12 13-Jul-2019 01:08:35.754 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation 13-Jul-2019 01:08:35.754 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\Jun\.IntelliJIdea2018.1\system\tomcat\Unnamed_User_MybatisPro 13-Jul-2019 01:08:35.755 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\apache-tomcat-8.5.37-windows-x64\apache-tomcat-8.5.37 13-Jul-2019 01:08:35.755 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\Jun\.IntelliJIdea2018.1\system\tomcat\Unnamed_User_MybatisPro\conf\logging.properties 13-Jul-2019 01:08:35.755 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager 13-Jul-2019 01:08:35.755 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote= 13-Jul-2019 01:08:35.755 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099 13-Jul-2019 01:08:35.755 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false 13-Jul-2019 01:08:35.756 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.authenticate=false 13-Jul-2019 01:08:35.756 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1 13-Jul-2019 01:08:35.756 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048 13-Jul-2019 01:08:35.756 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources 13-Jul-2019 01:08:35.756 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs= 13-Jul-2019 01:08:35.756 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\Jun\.IntelliJIdea2018.1\system\tomcat\Unnamed_User_MybatisPro 13-Jul-2019 01:08:35.756 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\apache-tomcat-8.5.37-windows-x64\apache-tomcat-8.5.37 13-Jul-2019 01:08:35.756 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\apache-tomcat-8.5.37-windows-x64\apache-tomcat-8.5.37\temp 13-Jul-2019 01:08:35.757 淇℃伅 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library [1.2.19] using APR version [1.6.5]. 13-Jul-2019 01:08:35.757 淇℃伅 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true]. 13-Jul-2019 01:08:35.757 淇℃伅 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true] 13-Jul-2019 01:08:35.762 淇℃伅 [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.1a 20 Nov 2018] 13-Jul-2019 01:08:35.895 淇℃伅 [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"] 13-Jul-2019 01:08:35.913 淇℃伅 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read 13-Jul-2019 01:08:35.927 淇℃伅 [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"] 13-Jul-2019 01:08:35.930 淇℃伅 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read 13-Jul-2019 01:08:35.931 淇℃伅 [main] org.apache.catalina.startup.Catalina.load Initialization processed in 707 ms 13-Jul-2019 01:08:35.970 淇℃伅 [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina] 13-Jul-2019 01:08:35.970 淇℃伅 [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.37 13-Jul-2019 01:08:35.983 淇℃伅 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"] 13-Jul-2019 01:08:36.000 淇℃伅 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"] 13-Jul-2019 01:08:36.004 淇℃伅 [main] org.apache.catalina.startup.Catalina.start Server startup in 72 ms Connected to server [2019-07-13 01:08:36,092] Artifact webapp: Artifact is being deployed, please wait... [2019-07-13 01:08:36,504] Artifact webapp: Artifact is deployed successfully [2019-07-13 01:08:36,504] Artifact webapp: Deploy took 412 milliseconds 13-Jul-2019 01:08:45.989 淇℃伅 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\apache-tomcat-8.5.37-windows-x64\apache-tomcat-8.5.37\webapps\manager] 13-Jul-2019 01:08:46.058 淇℃伅 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\apache-tomcat-8.5.37-windows-x64\apache-tomcat-8.5.37\webapps\manager] has finished in [68] ms
package com.damu.listener; import com.damu.utils.SqlSessionFactoryUtils; import javax.servlet.ServletContextAttributeListener; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.annotation.WebListener; @WebListener public class SqlSessionListener implements ServletContextListener { // 容器初始化方法 public void contextInitialized(ServletContextEvent servletContextEvent) { System.out.println("容器启动中..."); // 初始化SqlSessionFactory对象 SqlSessionFactoryUtils.InitSqlSessionFactory(); } // 容器销毁方法 public void contextDestroyed(ServletContextEvent servletContextEvent) { System.out.println("容器销毁中..."); // 关闭SqlSession对象 SqlSessionFactoryUtils.close(); } }
0
收起
正在回答
8回答
同学可以着重看Cased by后边的信息哦。
如果我的回答解决了你的疑惑,请采纳!祝学习愉快!
JavaNice
2019-07-13 18:16:54
13-Jul-2019 17:57:30.208 涓ラ噸 [RMI TCP Connection(4)-127.0.0.1] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [com.damu.listener.SqlSessionListener] org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession. ### The error may exist in SQL Mapper Configuration ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource db.properties at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:80) at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:64) at com.damu.utils.SqlSessionFactoryUtils.InitSqlSessionFactory(SqlSessionFactoryUtils.java:35) at com.damu.listener.SqlSessionListener.contextInitialized(SqlSessionListener.java:16) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5278) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1736) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:483) at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:432) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468) at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76) at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309) at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401) at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:361) at sun.rmi.transport.Transport$1.run(Transport.java:200) at sun.rmi.transport.Transport$1.run(Transport.java:197) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:196) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource db.properties at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:120) at org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:98) at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:78) ... 48 more
JavaNice
2019-07-13 16:00:46
我更改了一些Tomcat的配置,然后能进行监听了,但是监听器自动销毁,也就意味着web容器自动关闭?
C:\apache-tomcat-8.5.37-windows-x64\apache-tomcat-8.5.37\bin\catalina.bat run [2019-07-13 03:49:12,267] Artifact webapp: Waiting for server connection to start artifact deployment... [2019-07-13 03:49:12,268] Artifact User_MybatisPro:war: Waiting for server connection to start artifact deployment... Using CATALINA_BASE: "C:\Users\Jun\.IntelliJIdea2018.1\system\tomcat\Unnamed_User_MybatisPro" Using CATALINA_HOME: "C:\apache-tomcat-8.5.37-windows-x64\apache-tomcat-8.5.37" Using CATALINA_TMPDIR: "C:\apache-tomcat-8.5.37-windows-x64\apache-tomcat-8.5.37\temp" Using JRE_HOME: "C:\Program Files\Java\jdk1.8.0_161" Using CLASSPATH: "C:\apache-tomcat-8.5.37-windows-x64\apache-tomcat-8.5.37\bin\bootstrap.jar;C:\apache-tomcat-8.5.37-windows-x64\apache-tomcat-8.5.37\bin\tomcat-juli.jar" 13-Jul-2019 15:49:13.579 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.5.37 13-Jul-2019 15:49:13.581 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Dec 12 2018 12:07:02 UTC 13-Jul-2019 15:49:13.581 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.5.37.0 13-Jul-2019 15:49:13.582 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 10 13-Jul-2019 15:49:13.582 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 10.0 13-Jul-2019 15:49:13.582 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64 13-Jul-2019 15:49:13.582 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\Java\jdk1.8.0_161\jre 13-Jul-2019 15:49:13.582 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_161-b12 13-Jul-2019 15:49:13.582 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation 13-Jul-2019 15:49:13.582 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\Jun\.IntelliJIdea2018.1\system\tomcat\Unnamed_User_MybatisPro 13-Jul-2019 15:49:13.582 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\apache-tomcat-8.5.37-windows-x64\apache-tomcat-8.5.37 13-Jul-2019 15:49:13.582 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\Jun\.IntelliJIdea2018.1\system\tomcat\Unnamed_User_MybatisPro\conf\logging.properties 13-Jul-2019 15:49:13.583 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager 13-Jul-2019 15:49:13.583 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote= 13-Jul-2019 15:49:13.583 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099 13-Jul-2019 15:49:13.583 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false 13-Jul-2019 15:49:13.583 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.authenticate=false 13-Jul-2019 15:49:13.583 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1 13-Jul-2019 15:49:13.583 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048 13-Jul-2019 15:49:13.583 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources 13-Jul-2019 15:49:13.583 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs= 13-Jul-2019 15:49:13.584 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\Jun\.IntelliJIdea2018.1\system\tomcat\Unnamed_User_MybatisPro 13-Jul-2019 15:49:13.584 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\apache-tomcat-8.5.37-windows-x64\apache-tomcat-8.5.37 13-Jul-2019 15:49:13.584 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\apache-tomcat-8.5.37-windows-x64\apache-tomcat-8.5.37\temp 13-Jul-2019 15:49:13.584 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library [1.2.19] using APR version [1.6.5]. 13-Jul-2019 15:49:13.584 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true]. 13-Jul-2019 15:49:13.585 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true] 13-Jul-2019 15:49:13.589 信息 [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.1a 20 Nov 2018] 13-Jul-2019 15:49:13.733 信息 [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"] 13-Jul-2019 15:49:13.753 信息 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read 13-Jul-2019 15:49:13.769 信息 [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"] 13-Jul-2019 15:49:13.773 信息 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read 13-Jul-2019 15:49:13.773 信息 [main] org.apache.catalina.startup.Catalina.load Initialization processed in 642 ms 13-Jul-2019 15:49:13.800 信息 [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina] 13-Jul-2019 15:49:13.800 信息 [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.37 13-Jul-2019 15:49:13.810 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"] 13-Jul-2019 15:49:13.822 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"] 13-Jul-2019 15:49:13.824 信息 [main] org.apache.catalina.startup.Catalina.start Server startup in 50 ms
3. Java 数据库开发与实战应用
- 参与学习 人
- 提交作业 357 份
- 解答问题 8016 个
本阶段将带你学习MySQL数据库,JDBC接口,MyBatis框架等,带你掌握的数据的存放和管理。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星