点点滴滴

最近老是有程序占用JVM的端口号,后来上网查询资料很快给解决了,现在总结一下

严重: Error starting endpoint
java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind
    at java.net.PlainSocketImpl.socketBind(Native Method)
    at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359)
    at java.net.ServerSocket.bind(ServerSocket.java:319)
    at java.net.ServerSocket.(ServerSocket.java:185)
    at java.net.ServerSocket.(ServerSocket.java:141)
    at org.apache.tomcat.util.net.DefaultServerSocketFactory.createSocket(DefaultServerSocketFactory.java:50)
    at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:538)
    at org.apache.tomcat.util.net.JIoEndpoint.start(JIoEndpoint.java:565)
    at org.apache.coyote.http11.Http11Protocol.start(Http11Protocol.java:207)
    at org.apache.catalina.connector.Connector.start(Connector.java:1197)
    at org.apache.catalina.core.StandardService.start(StandardService.java:540)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
2016-7-23 20:27:39 org.apache.catalina.core.StandardService start
严重: Failed to start connector [Connector[HTTP/1.1-8080]]
LifecycleException:  service.getName(): "Catalina";  Protocol handler start failed: java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind
    at org.apache.catalina.connector.Connector.start(Connector.java:1204)
    at org.apache.catalina.core.StandardService.start(StandardService.java:540)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
2016-7-23 20:27:40 org.apache.jk.common.ChannelSocket init
信息: Port busy 8009 java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind
2016-7-23 20:27:40 org.apache.jk.common.ChannelSocket init
严重: Can't find free port 8009 8009
2016-7-23 20:27:40 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/135  config=null
2016-7-23 20:27:40 org.apache.catalina.startup.Catalina start
信息: Server startup in 9002 ms
2016-7-23 20:27:40 org.apache.catalina.core.StandardServer await
严重: StandardServer.await: create[8005]:
java.net.BindException: Address already in use: JVM_Bind
    at java.net.PlainSocketImpl.socketBind(Native Method)
    at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359)
    at java.net.ServerSocket.bind(ServerSocket.java:319)
    at java.net.ServerSocket.(ServerSocket.java:185)
    at org.apache.catalina.core.StandardServer.await(StandardServer.java:406)
    at org.apache.catalina.startup.Catalina.await(Catalina.java:676)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:628)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
2016-7-23 20:27:40 org.apache.coyote.http11.Http11Protocol pause
信息: Pausing Coyote HTTP/1.1 on http-8080
2016-7-23 20:27:41 org.apache.catalina.core.StandardService stop
信息: Stopping service Catalina
2016-7-23 20:27:42 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
严重: The web application [/Struts2] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@60bb1ee]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@69ce835b]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
2016-7-23 20:27:42 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
严重: The web application [/Struts2] created a ThreadLocal with key of type [com.sun.faces.util.Util$1] (value [com.sun.faces.util.Util$1@751201a1]) and a value of type [java.util.HashMap] (value [{com.sun.faces.patternCache={ = }}]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
2016-7-23 20:27:43 org.apache.coyote.http11.Http11Protocol destroy
信息: Stopping Coyote HTTP/1.1 on http-8080

方法:

1、Windows平台
在windows命令行窗口下执行:
1.查看所有的端口占用情况

C:\>netstat -ano

  协议    本地地址                     外部地址               状态                   PID

  TCP    127.0.0.1:1434         0.0.0.0:0              LISTENING       3236
  TCP    127.0.0.1:5679         0.0.0.0:0              LISTENING       4168
  TCP    127.0.0.1:7438         0.0.0.0:0              LISTENING       4168
  TCP    127.0.0.1:8015         0.0.0.0:0              LISTENING       1456
  TCP    192.168.3.230:139      0.0.0.0:0              LISTENING       4
  TCP    192.168.3.230:1957     220.181.31.225:443     ESTABLISHED     3068
  TCP    192.168.3.230:2020     183.62.96.189:1522     ESTABLISHED     1456
  TCP    192.168.3.230:2927     117.79.91.18:80        ESTABLISHED     4732
  TCP    192.168.3.230:2929     117.79.91.18:80        ESTABLISHED     4732
  TCP    192.168.3.230:2930     117.79.91.18:80        ESTABLISHED     4732
  TCP    192.168.3.230:2931     117.79.91.18:80        ESTABLISHED     4732

 

2.查看指定端口的占用情况
C:\>netstat -aon|findstr "9050"

  协议    本地地址                     外部地址               状态                   PID

  TCP    127.0.0.1:9050         0.0.0.0:0              LISTENING       2016

P: 看到了吗,端口被进程号为2016的进程占用,继续执行下面命令: (也可以去任务管理器中查看pid对应的进程)

3.查看PID对应的进程
C:\>tasklist|findstr "2016"

 映像名称                       PID 会话名              会话#       内存使用
 ========================= ======== ================
  tor.exe                     2016 Console                 0     16,064 K

P:很清楚吧,tor占用了你的端口。

 

4.结束该进程

C:\>taskkill /f /t /im tor.exe或者打开任务管理器结束该进程

但是如果JVM多次被占用,可以确定是被javaw.exe占用了,只需打开任务管理器,结束内存较小的那个javaw.exe就行了。

 




你可能感兴趣的:(web后台开发)