Posted on 2006-06-13 20:37
shaofan 阅读(1038)
评论(0) 编辑 收藏 所属分类:
Java
如果你不幸装了NetBeans并且启用了外置的服务器,那么它会自动在你的web server的web.xml里添加一个filter,名叫HttpMonitorFilter。你用NetBeans时,它会过滤所有的http请求,这样NetBeans就可以显示所有的相关信息。但是如果不用NetBeans,比如我,用eclipse + Tomcat ,那就会得到这个异常:
NotifyUtil::java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.(Unknown Source)
at sun.net.www.http.HttpClient.(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
at org.netbeans.modules.web.monitor.server.NotifyUtil$RecordSender.run(NotifyUtil.java:237)
解决方法是:
第一步. 删除 Tomcat目录中common\lib下的两个和netbeans有关的jar文件(以org-netbeans开头的)
第二步. 修改tomcat目录下的conf\web.xml,删除相关Filter的定义,就是这一段:
<filter>
<filter-name>HTTPMonitorFilter</filter-name>
<filter-class>
org.netbeans.modules.web.monitor.server.MonitorFilter
</filter-class>
<init-param>
<param-name>netbeans.monitor.ide</param-name>
<param-value>127.0.0.1:8082</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>HTTPMonitorFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>