tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brad Cox PhD <b...@virtualschool.edu>
Subject ServerSocket not being closed properly.
Date Tue, 24 Apr 2001 01:03:46 GMT
At 7:06 PM -0500 04/23/2001, Marc Saegesser wrote:
>I was just about to call the vote for the final release of Tomcat 3.2.2
...

While you're at it, could you ensure that tomcat closes its server 
socket  instead of relying on the system to do it when the VM exits? 
This is a long-standing problem that interferes with running tomcat 
inside  IBM's VisualAge, or (equivalently) building java GUIs for 
starting and stopping the server.

Here's what I've been using in a GUI for starting and stopping tomcat.

private void doStart(String[] args)
{
	org.apache.tomcat.startup.Tomcat.main(args);
}
private void doStop()
{
	String[] stopArgs = new String[] { "-stop" };
	org.apache.tomcat.startup.Tomcat.main(stopArgs);
}

The buttons work the first time they're used. The start buttons fails 
the second times (either by the same GUI or by any other means during 
the same VisualAge session) because the server socket is still being 
held open by the lack of an explicit close. The only way I've found 
to clear the problem is to exit VisualAge altogether; a SLOOOWWWW 
process.

I've seen the same problem in my own applications. The fix was to be 
SURE that the ServerSocket is closed EXPLICITLY rather than leaving 
it to the operating system to do when the process exits.

This session console log may help locate the problem.

2001-04-24 08:51:00 - ContextManager: Adding context Ctx( /examples )
2001-04-24 08:51:01 - ContextManager: Adding context Ctx( /admin )
2001-04-24 08:51:01 - Ctx( /svlt ): Set debug to 9
2001-04-24 08:51:01 - ContextManager: Adding context Ctx( /svlt )
Starting tomcat. Check logs/tomcat.log for error messages
2001-04-24 08:51:01 - ContextManager: Adding context Ctx(  )
2001-04-24 08:51:01 - ContextManager: Adding context Ctx( /test )
2001-04-24 08:51:01 - ContextManager: Adding context Ctx( /digiprop )
2001-04-24 08:51:02 - Ctx( /svlt ): XmlReader - init  /svlt /digiprop
2001-04-24 08:51:02 - Ctx( /svlt ): Reading /digiprop/WEB-INF/web.xml
2001-04-24 08:51:02 - Ctx( /svlt ): Loading -2147483646 jsp
2001-04-24 08:51:02 - Ctx( /svlt ): Loading 1 flush
2001-04-24 08:51:03 - Ctx( /svlt ): Loading 1 page
2001-04-24 08:51:03 - Ctx( /svlt ): Loading 1 login
FATAL:java.net.SocketException: Address already in use
java.net.SocketException: Address already in use
	java.lang.Throwable(java.lang.String)
	java.lang.Exception(java.lang.String)
	java.io.IOException(java.lang.String)
	java.net.SocketException(java.lang.String)
	void java.net.PlainSocketImpl.socketBind(java.net.InetAddress, int)
	void java.net.PlainSocketImpl.bind(java.net.InetAddress, int)
	java.net.ServerSocket(int, int, java.net.InetAddress)
	java.net.ServerSocket(int, int)
	java.net.ServerSocket 
org.apache.tomcat.net.DefaultServerSocketFactory.createSocket(int, 
int)
	void org.apache.tomcat.service.PoolTcpEndpoint.startEndpoint()
	void org.apache.tomcat.service.PoolTcpConnector.start()
	void org.apache.tomcat.core.ContextManager.start()
	void org.apache.tomcat.startup.Tomcat.execute(java.lang.String [])
	void org.apache.tomcat.startup.Tomcat.main(java.lang.String [])
---->	void digiprop.site.TomcatView.doStart()
	void digiprop.site.TomcatView.connEtoC2(java.awt.event.ActionEvent)
	void 
digiprop.site.TomcatView$IvjEventHandler.actionPerformed(java.awt.event.ActionEvent)
	void java.awt.Button.processActionEvent(java.awt.event.ActionEvent)
	void java.awt.Button.processEvent(java.awt.AWTEvent)
	void java.awt.Component.dispatchEventImpl(java.awt.AWTEvent)
	void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
	void java.awt.EventDispatchThread.run()

-- 
---
Brad Cox, Ph.D.; bcox@virtualschool.edu
Phone: 703 361 4751 Cell: 703 919-9623
http://virtualschool.edu

Mime
View raw message