简体   繁体   中英

nullpointer exception in starting tomcat

my tomcat server is not starting in eclipse which was working fine before but now its showing the following exception. although its working quite fine outside eclipse. but whenever i try to start the server, the following exception occurs and it shows the message = " starting Tomcat server v8.0 server at localhost has encountered a problem"

Dec 08, 2014 4:35:16 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-nio-8009"]
Dec 08, 2014 4:35:16 PM org.apache.coyote.AbstractProtocol destroy
SEVERE: Failed to destroy end point associated with ProtocolHandler ["ajp-nio-8009"]
java.lang.NullPointerException
    at org.apache.tomcat.util.net.NioEndpoint.releaseCaches(NioEndpoint.java:307)
    at org.apache.tomcat.util.net.NioEndpoint.unbind(NioEndpoint.java:482)
    at org.apache.tomcat.util.net.AbstractEndpoint.destroy(AbstractEndpoint.java:795)
    at org.apache.coyote.AbstractProtocol.destroy(AbstractProtocol.java:531)
    at org.apache.catalina.connector.Connector.destroyInternal(Connector.java:1023)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)
    at org.apache.catalina.core.StandardService.destroyInternal(StandardService.java:588)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)
    at org.apache.catalina.core.StandardServer.destroyInternal(StandardServer.java:850)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:629)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)

The stacktrace seems to show that Tomcat has already decided that the startup has failed, and that the NPE occurred while trying to shutdown.

I expect that the real problem (ie the one that caused Tomcat to abandon the startup attempt) is earlier in the log file.


Indeed the Tomcat source code confirms this:

protected void releaseCaches() {
    this.keyCache.clear();
    this.nioChannels.clear();
    this.processorCache.clear();
    if ( handler != null ) handler.recycle();
}

A NullPointerException here means that keyCache or nioChannels or processorCache is null . (I think) that can only happen if something went wrong during the construction of the NioEndPoint object because those three fields are private final . Or at least, they are in the version I looked at.

This happened to me, it was because I had misconfigured my Tomcat server. Deleting it and creating a new server entry helped.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM