我这么写了,然后在tomcat启动时报错了,貌似nutz还没加载,所以空指针了
public class TomcatListener implements ServletContextListener{
private Dao dao= Mvcs.ctx().getDefaultIoc().get(Dao.class);
//tomcat关闭前触发
@Override
public void contextDestroyed(ServletContextEvent arg0) {
System.out.println("Tomcat destroyed...");
//dao.update("user",Chain.make("status", "hide"),Cnd.where("1","=",1));
}
//Servlet启动后触发
@Override
public void contextInitialized(ServletContextEvent arg0) {
System.out.println("Tomcat init...");
}
}
报错信息如下:
五月 03, 2017 1:41:15 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin
警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:mychat' did not find a matching property.
五月 03, 2017 1:41:15 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server version: Apache Tomcat/8.0.36
五月 03, 2017 1:41:15 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server built: Jun 9 2016 13:55:50 UTC
五月 03, 2017 1:41:15 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server number: 8.0.36.0
五月 03, 2017 1:41:15 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Name: Windows 10
五月 03, 2017 1:41:15 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Version: 10.0
五月 03, 2017 1:41:15 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Architecture: amd64
五月 03, 2017 1:41:15 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Java Home: D:\java\jre
五月 03, 2017 1:41:15 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Version: 1.8.0_91-b15
五月 03, 2017 1:41:15 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Vendor: Oracle Corporation
五月 03, 2017 1:41:15 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_BASE: D:\apache-tomcat-8.0.36
五月 03, 2017 1:41:15 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_HOME: D:\apache-tomcat-8.0.36
五月 03, 2017 1:41:15 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:56687
五月 03, 2017 1:41:15 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.base=D:\apache-tomcat-8.0.36
五月 03, 2017 1:41:15 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.home=D:\apache-tomcat-8.0.36
五月 03, 2017 1:41:15 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dwtp.deploy=D:\apache-tomcat-8.0.36\webapps
五月 03, 2017 1:41:15 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.endorsed.dirs=D:\apache-tomcat-8.0.36\endorsed
五月 03, 2017 1:41:15 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dfile.encoding=UTF-8
五月 03, 2017 1:41:15 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\java\jre\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;D:\java\jre\bin;D:/java/jre/bin/server;D:/java/jre/bin;D:/java/jre/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;D:\java\jdk\bin;F:\?????????\eclipse;;.
五月 03, 2017 1:41:16 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-nio-8080"]
五月 03, 2017 1:41:16 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
信息: Using a shared selector for servlet write/read
五月 03, 2017 1:41:16 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-nio-8009"]
五月 03, 2017 1:41:16 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
信息: Using a shared selector for servlet write/read
五月 03, 2017 1:41:16 下午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 1095 ms
五月 03, 2017 1:41:16 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
五月 03, 2017 1:41:16 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/8.0.36
五月 03, 2017 1:41:17 下午 org.apache.jasper.servlet.TldScanner scanJars
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
socket初始化成功...2
五月 03, 2017 1:41:18 下午 org.apache.catalina.core.StandardContext listenerStart
严重: Error configuring application listener of class com.mychat.listener.TomcatListener
java.lang.NullPointerException
at com.mychat.listener.TomcatListener.<init>(TomcatListener.java:15)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:119)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4764)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1407)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1397)
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)
五月 03, 2017 1:41:18 下午 org.apache.catalina.core.StandardContext listenerStart
严重: Skipped installing application listeners due to previous error(s)
五月 03, 2017 1:41:18 下午 org.apache.catalina.core.StandardContext startInternal
严重: One or more listeners failed to start. Full details will be found in the appropriate container log file
五月 03, 2017 1:41:18 下午 org.apache.catalina.core.StandardContext startInternal
严重: Context [/mychat] startup failed due to previous errors
五月 03, 2017 1:41:18 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory D:\apache-tomcat-8.0.36\webapps\docs
五月 03, 2017 1:41:18 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory D:\apache-tomcat-8.0.36\webapps\docs has finished in 53 ms
五月 03, 2017 1:41:18 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory D:\apache-tomcat-8.0.36\webapps\examples
五月 03, 2017 1:41:18 下午 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
五月 03, 2017 1:41:18 下午 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
五月 03, 2017 1:41:18 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory D:\apache-tomcat-8.0.36\webapps\examples has finished in 362 ms
五月 03, 2017 1:41:18 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory D:\apache-tomcat-8.0.36\webapps\host-manager
五月 03, 2017 1:41:18 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory D:\apache-tomcat-8.0.36\webapps\host-manager has finished in 41 ms
五月 03, 2017 1:41:18 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory D:\apache-tomcat-8.0.36\webapps\manager
五月 03, 2017 1:41:18 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory D:\apache-tomcat-8.0.36\webapps\manager has finished in 44 ms
五月 03, 2017 1:41:18 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory D:\apache-tomcat-8.0.36\webapps\ROOT
五月 03, 2017 1:41:18 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory D:\apache-tomcat-8.0.36\webapps\ROOT has finished in 31 ms
五月 03, 2017 1:41:18 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-nio-8080"]
五月 03, 2017 1:41:18 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-nio-8009"]
五月 03, 2017 1:41:18 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 2440 ms