最近在centOS上面做j2ee開發,當啟動tomcat7.0的時候總是報如下錯誤:
嚴重: StandardServer.await: create[localhost:8005]:
java.net.BindException: Cannot assign requested address
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:383)
at java.net.ServerSocket.bind(ServerSocket.java:328)
at java.net.ServerSocket.<init>(ServerSocket.java:194)
at org.apache.catalina.core.StandardServer.await(StandardServer.java:427)
at org.apache.catalina.startup.Catalina.await(Catalina.java:757)
at org.apache.catalina.startup.Catalina.start(Catalina.java:703)
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:322)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:450)
2012-6-5 21:07:21 org.apache.coyote.AbstractProtocol pause
資訊: Pausing ProtocolHandler ["http-bio-8080"]
Hibernate: select name from server_info
Hibernate: select clusterinf0_.id as id1_, clusterinf0_.name as name1_ from cluster_info clusterinf0_
2012-6-5 21:07:23 org.apache.coyote.AbstractProtocol pause
資訊: Pausing ProtocolHandler ["http-bio-8443"]
2012-6-5 21:07:25 org.apache.coyote.AbstractProtocol pause
資訊: Pausing ProtocolHandler ["ajp-bio-8009"]
2012-6-5 21:07:27 org.apache.catalina.core.StandardService stopInternal
資訊: Stopping service Catalina
2012-6-5 21:07:27 org.apache.catalina.core.ApplicationContext log
資訊: Closing Spring root WebApplicationContext
2012-6-5 21:07:27 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
嚴重: The web application [/glustermg] registered the JDBC driver [org.apache.derby.jdbc.AutoloadedDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
2012-6-5 21:07:27 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
嚴重: The web application [/glustermg] created a ThreadLocal with key of type [org.apache.derby.iapi.sql.dictionary.TableDescriptor$1] (value [org.apache.derby.iapi.sql.dictionary.TableDescriptor$1@73abdb5e]) and a value of type [java.util.WeakHashMap] (value [{}]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
2012-6-5 21:07:27 org.apache.coyote.AbstractProtocol stop
資訊: Stopping ProtocolHandler ["http-bio-8080"]
2012-6-5 21:07:29 org.apache.coyote.AbstractProtocol stop
資訊: Stopping ProtocolHandler ["http-bio-8443"]
2012-6-5 21:07:31 org.apache.coyote.AbstractProtocol stop
資訊: Stopping ProtocolHandler ["ajp-bio-8009"]
2012-6-5 21:07:33 org.apache.coyote.AbstractProtocol destroy
資訊: Destroying ProtocolHandler ["http-bio-8080"]
2012-6-5 21:07:33 org.apache.coyote.AbstractProtocol destroy
資訊: Destroying ProtocolHandler ["http-bio-8443"]
2012-6-5 21:07:33 org.apache.coyote.AbstractProtocol destroy
資訊: Destroying ProtocolHandler ["ajp-bio-8009"]
在網上找了很多解決方案,都沒有解決,然後我以後是項目工程改動的錯誤,但將項目從tomcat中去除後重啟,還是不行,上網也有說是tomcat7的新問題,我換成6.0的版本後,還是不行,最後才記得可能是網路設定錯誤,我的解決方案出下:編輯/etc/hosts檔案:
vim /etc/hosts
10.11.2.180 istore01 localhost
10.11.2.201 Dev01
10.11.2.202 Dev02
~
檢查這裡的IP地址是否和當前實際的地址相同,如果不相同,則改為當前的IP,我的情況就是本來我的IP是10.11.2.180的,但這個檔案中記錄的是192.168.0.180。這下找到這個問題了,記錄在這裡,讓遇到相同問題的朋友也能快速解決問題。對了,以後我得養成寫文章的習慣 了,協助別人的同時也能對自己加深印象,雖然多花了點時間,我覺得還是值得的!!希望對有協助的朋友回複下啊:)