You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Chirag Dewan <ch...@yahoo.in> on 2013/05/13 17:34:14 UTC

Port still busy after removing connector in Embedded Tomcat 7.0.30

Hi,

I am embedding  Apache Tomcat 7.0.30 in my application. I am using the Tomcat class,and my application requires dynamic addition and removal of connectors(HTTP).

Now while removing the connectors,the application gets undeployed but the port remains occupied and the connector continue to listen on the port. I am using customized HTTP connector.


  Here is a snippet from my source code:

for removing connector:

if( connector != null )
        {
            connector.decUsage();
            if( connector.getUsage() == 0 )
            {
                connector.stop();
                this.tomcat.getService().removeConnector( connector );
            }
        }

for adding connector:

this.tomcat.getService().addConnector( connector );


I know the port is not getting free. Because when I try to deploy to the same port again,it gives me an address already in use exception.
I have surfed for this issue a lot,but to no avail. Any help would be greatly appreciated.

Thanks

RE: Port still busy after removing connector in Embedded Tomcat 7.0.30

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Caldarale, Charles R 
> Subject: RE: Port still busy after removing connector in Embedded Tomcat 7.0.30

> > How long are you waiting? Can you give us the specifics of your
> > connector configuration? I wonder if the connector is remaining open
> > for something like a keepalive timeout (I don't know if it *should*
> > stay open for a keepalive timeout, but it seems plausible).

> It would be interesting to see the actual netstat report here; I wonder 
> if the socket is in a FIN_WAIT or CLOSE_WAIT state.

But that probably shouldn't happen for a ServerSocket.

Does forcing a GC "fix" the problem?

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Port still busy after removing connector in Embedded Tomcat 7.0.30

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Christopher Schultz [mailto:chris@christopherschultz.net] 
> Subject: Re: Port still busy after removing connector in Embedded Tomcat 7.0.30

> > If I am calling the removeConnector, shouldn't it cleanup the
> > context and the free the port?

> In theory, yes, but ...

> How long are you waiting? Can you give us the specifics of your
> connector configuration? I wonder if the connector is remaining open
> for something like a keepalive timeout (I don't know if it *should*
> stay open for a keepalive timeout, but it seems plausible).

It would be interesting to see the actual netstat report here; I wonder if the socket is in a FIN_WAIT or CLOSE_WAIT state.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Port still busy after removing connector in Embedded Tomcat 7.0.30

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Chirag,

On 5/13/13 1:03 PM, Chirag Dewan wrote:
>> If the context was removed, but the Connector was still there, 
>> should you not get a 404 Not Found, rather than a timeout ?
> 
> 
> If I am calling the removeConnector, shouldn't it cleanup the
> context and the free the port?

In theory, yes, but ...

How long are you waiting? Can you give us the specifics of your
connector configuration? I wonder if the connector is remaining open
for something like a keepalive timeout (I don't know if it *should*
stay open for a keepalive timeout, but it seems plausible).

> I mean is my context blocking the connector even after I removed
> it? i should get a 404. Yes.

But you aren't getting a 404: you are getting a request timeout which
seems a bit odd. Perhaps the connector is partially shut-down, but not
completely.

How about that stack trace?

> Sorry I forget to mention,it worked fine with Tomcat 6 Embedded 
> version. I am trying to upgrade it to Tomcat 7.0.30 and I am 
> following the same process as in Tomcat 6.

Tomcat 7 is different than Tomcat 6... did you read the embedded
documentation to see if anything changed? In general, connector states
should be the same, but changing major versions is likely to require
you to change your embedded code somewhat.

Tomcat's unit tests (available in the source distribution of Tomcat)
extensively use embedded techniques and are a good source of
information for how to properly use Tomcat in an embedded way.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJRkVPqAAoJEBzwKT+lPKRY8UEQALqicEQax+K9xYGb3XdzvOgE
a5emxV6fHog9ZSUqHVDnxtSIaxOQ3uUjHiwmc2gtTAnn5NiTN3IES+3YkHLnI6Vl
La0fdpNOshuqhz37DAAY9/nPI4fgWOwAMBuAHCrl53BerbHTGaKHUwF0e42/otIa
jWxQlVTXD2V06WyuoF9CJupKbcENGrTS7dsDegqmRzbbrGjLHc1Ot/l+AK8uEdjw
cjWcI9Od9BkLKMkD+C0aHfT8s5fdUWr3f62K13T8uBrmNbghvK1NKsntpA84VqSy
EUuNUcIbJglgLGz+XOc2UlTKZs01y2tRIwoPZQiv3ap15lf1El5KuB3b+NMzj4UT
al9fK2sITcQW/6AAdoafChpttW65OvM6kwl3nTZBhOimkW/hw8Qrf7rFh1uUvpY7
Q7rhiCYiyEtVaBPKxPkY4D3272F4OHviZev1ltYyfHHHgFs1+DricOmEhVDF/hd2
6W6FRaxNpdSbS4U2bW9JziISb+5hKH+GyJkSJRJGHagQOXwfNRm89PhKA2mfE3XP
Ihtv7eIRBiw6jCWvCYbeXFW5Fvx75AtU1xMlFs2c5HLsryV1h4PCZRtvf/LXYs5G
Nl/osLQius4IpHkEdc88CVByYtRlEB8PereQZe/zKXSZt61ahYGQjDf4rDhAt1qa
y2eqzNhJ97OrYMz+KPW/
=feVR
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Port still busy after removing connector in Embedded Tomcat 7.0.30

Posted by Chirag Dewan <ch...@yahoo.in>.
> If the context was removed, but the Connector was still there, should you not get a 404 
Not Found, rather than a timeout ?


If I am calling the removeConnector,shouldn't it cleanup the context and the free the port?
I mean is my context blocking the connector even after I removed it? i should get a 404. Yes.



Sorry I forget to mention,it worked fine with Tomcat 6 Embedded version. I am trying to upgrade it to Tomcat 7.0.30 and I am following the same process as in Tomcat 6.

Thanks



________________________________
 From: André Warnier <aw...@ice-sa.com>
To: Tomcat Users List <us...@tomcat.apache.org> 
Sent: Monday, 13 May 2013 10:13 PM
Subject: Re: Port still busy after removing connector in Embedded Tomcat 7.0.30
 

Chirag Dewan wrote:
>> How do you observe that the connector is still bound to the port?
> 
> Yes. I used netstat to observe that. Plus when I try to add another context to the same port,I get "Address already in use" exception.
> 
>> What does it show? 
> 
> I can see my java process running on that port.
> 
>> What happens if you make a request?
> 
>  As I said,I am sure that the deployed context is removed. I get a timeout on a request.

If the context was removed, but the Connector was still there, should you not get a 404 
Not Found, rather than a timeout ?

> 
> When I start my Tomcat Server(tomcat.start()),I understand it adds a default connector to the service on port 8080,so after adding my connector on port 1090,i can see my java process listening on port 1090 and 8080.
> 
> I really dont understand what wrong I might be doing.
> 
> 
> Thanks
> 
> 
> 
> 
> 
> 
> 
> ________________________________
>  From: Christopher Schultz <ch...@christopherschultz.net>
> To: Tomcat Users List <us...@tomcat.apache.org> 
> Sent: Monday, 13 May 2013 9:47 PM
> Subject: Re: Port still busy after removing connector in Embedded Tomcat 7.0.30
>  
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
> 
> Chirag,
> 
> On 5/13/13 11:34 AM, Chirag Dewan wrote:
>> I am embedding  Apache Tomcat 7.0.30 in my application. I am using
>> the Tomcat class,and my application requires dynamic addition and
>> removal of connectors(HTTP).
>>
>> Now while removing the connectors,the application gets undeployed
>> but the port remains occupied and the connector continue to listen
>> on the port. I am using customized HTTP connector.
>>
>>
>> Here is a snippet from my source code:
>>
>> for removing connector:
>>
>> if( connector != null ) { connector.decUsage(); if(
>> connector.getUsage() == 0 ) { connector.stop(); 
>> this.tomcat.getService().removeConnector( connector ); } }
>>
>> for adding connector:
>>
>> this.tomcat.getService().addConnector( connector );
>>
>>
>> I know the port is not getting free. Because when I try to deploy
>> to the same port again,it gives me an address already in use
>> exception. I have surfed for this issue a lot,but to no avail. Any
>> help would be greatly appreciated.
> 
> Can you take a thread dump and find which code look like it's doing
> connection-related things?
> 
> How do you observe that the connector is still bound to the port?
> netstat? What does it show? What happens if you make a request?
> 
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
> 
> iQIcBAEBCAAGBQJRkRIbAAoJEBzwKT+lPKRYH4kP/2WiZK75ifzqSXojAw1ckw6k
> iH5NvnWNNFeibFvqtj0tN2Nun+mb3atqs4ySwQahN/FAtz8klhdfGLTlccMxzh4u
> x1yvMKLEh1Xr3qTxeot/y98zER/gubdgNsM4lr5MkkFVtaprK7/emz1OCwcuZe0L
> XApJRuSNF+GxtH9lSKEw4Tn4kzc5Asv2gMQOQmLAmBi3fKI9MsoRS9V5TPU88dhL
> XBk+rkcUdvL2KWKbP9yrt2Geu9NqBzqADCA4FJUESS9sm8A/VECzyUZ+4uW/jqiP
> qpn4GSAtpaH9CyHzynZF5qyA8Fx+BllhyIFwZfUl5DMqk+t4gw3LdPay8Rkpfg7G
> fdLHXrLez/Pcj2nvOp60OLeC4DD13AJON9KyYXmnUuk29aV/lrOes9nmUbIVDh8k
> 2LXh9cYErtD55bCgmTLPT0bLBpC9v1aUGEjFzeLjfJX9hEkvpUrN5OWvKHYg5Vaw
> 2qc+bV31qitjrUfZYU58S5UX1txATx6Ig76y/pt49XfiQFc6/GG25Ju5UCJOpat0
> mOV4qTck+Exy+YuGvME7V/IcLAbymm9vGIB4bQD9dLq36Kx0cL5lE/DOYANd2PJD
> 0nBO/co4uRvKW54NDnHVzzpAU7IUXBoQ+SmU4IQMv1+TP6auHO8ekwDW7+59ZgCc
> Ev3xtRom84ly50SQcxKf
> =zDpF
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

Re: Port still busy after removing connector in Embedded Tomcat 7.0.30

Posted by André Warnier <aw...@ice-sa.com>.
Chirag Dewan wrote:
>> How do you observe that the connector is still bound to the port?
> 
> Yes. I used netstat to observe that. Plus when I try to add another context to the same port,I get "Address already in use" exception.
> 
>> What does it show? 
> 
> I can see my java process running on that port.
> 
>> What happens if you make a request?
> 
>  As I said,I am sure that the deployed context is removed. I get a timeout on a request.

If the context was removed, but the Connector was still there, should you not get a 404 
Not Found, rather than a timeout ?

> 
> When I start my Tomcat Server(tomcat.start()),I understand it adds a default connector to the service on port 8080,so after adding my connector on port 1090,i can see my java process listening on port 1090 and 8080.
> 
> I really dont understand what wrong I might be doing.
> 
> 
> Thanks
> 
> 
> 
> 
> 
> 
> 
> ________________________________
>  From: Christopher Schultz <ch...@christopherschultz.net>
> To: Tomcat Users List <us...@tomcat.apache.org> 
> Sent: Monday, 13 May 2013 9:47 PM
> Subject: Re: Port still busy after removing connector in Embedded Tomcat 7.0.30
>  
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
> 
> Chirag,
> 
> On 5/13/13 11:34 AM, Chirag Dewan wrote:
>> I am embedding  Apache Tomcat 7.0.30 in my application. I am using
>> the Tomcat class,and my application requires dynamic addition and
>> removal of connectors(HTTP).
>>
>> Now while removing the connectors,the application gets undeployed
>> but the port remains occupied and the connector continue to listen
>> on the port. I am using customized HTTP connector.
>>
>>
>> Here is a snippet from my source code:
>>
>> for removing connector:
>>
>> if( connector != null ) { connector.decUsage(); if(
>> connector.getUsage() == 0 ) { connector.stop(); 
>> this.tomcat.getService().removeConnector( connector ); } }
>>
>> for adding connector:
>>
>> this.tomcat.getService().addConnector( connector );
>>
>>
>> I know the port is not getting free. Because when I try to deploy
>> to the same port again,it gives me an address already in use
>> exception. I have surfed for this issue a lot,but to no avail. Any
>> help would be greatly appreciated.
> 
> Can you take a thread dump and find which code look like it's doing
> connection-related things?
> 
> How do you observe that the connector is still bound to the port?
> netstat? What does it show? What happens if you make a request?
> 
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
> 
> iQIcBAEBCAAGBQJRkRIbAAoJEBzwKT+lPKRYH4kP/2WiZK75ifzqSXojAw1ckw6k
> iH5NvnWNNFeibFvqtj0tN2Nun+mb3atqs4ySwQahN/FAtz8klhdfGLTlccMxzh4u
> x1yvMKLEh1Xr3qTxeot/y98zER/gubdgNsM4lr5MkkFVtaprK7/emz1OCwcuZe0L
> XApJRuSNF+GxtH9lSKEw4Tn4kzc5Asv2gMQOQmLAmBi3fKI9MsoRS9V5TPU88dhL
> XBk+rkcUdvL2KWKbP9yrt2Geu9NqBzqADCA4FJUESS9sm8A/VECzyUZ+4uW/jqiP
> qpn4GSAtpaH9CyHzynZF5qyA8Fx+BllhyIFwZfUl5DMqk+t4gw3LdPay8Rkpfg7G
> fdLHXrLez/Pcj2nvOp60OLeC4DD13AJON9KyYXmnUuk29aV/lrOes9nmUbIVDh8k
> 2LXh9cYErtD55bCgmTLPT0bLBpC9v1aUGEjFzeLjfJX9hEkvpUrN5OWvKHYg5Vaw
> 2qc+bV31qitjrUfZYU58S5UX1txATx6Ig76y/pt49XfiQFc6/GG25Ju5UCJOpat0
> mOV4qTck+Exy+YuGvME7V/IcLAbymm9vGIB4bQD9dLq36Kx0cL5lE/DOYANd2PJD
> 0nBO/co4uRvKW54NDnHVzzpAU7IUXBoQ+SmU4IQMv1+TP6auHO8ekwDW7+59ZgCc
> Ev3xtRom84ly50SQcxKf
> =zDpF
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Port still busy after removing connector in Embedded Tomcat 7.0.30

Posted by Chirag Dewan <ch...@yahoo.in>.
>How do you observe that the connector is still bound to the port?

Yes. I used netstat to observe that. Plus when I try to add another context to the same port,I get "Address already in use" exception.

> What does it show? 

I can see my java process running on that port.

>What happens if you make a request?

 As I said,I am sure that the deployed context is removed. I get a timeout on a request.

When I start my Tomcat Server(tomcat.start()),I understand it adds a default connector to the service on port 8080,so after adding my connector on port 1090,i can see my java process listening on port 1090 and 8080.

I really dont understand what wrong I might be doing.


Thanks







________________________________
 From: Christopher Schultz <ch...@christopherschultz.net>
To: Tomcat Users List <us...@tomcat.apache.org> 
Sent: Monday, 13 May 2013 9:47 PM
Subject: Re: Port still busy after removing connector in Embedded Tomcat 7.0.30
 

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Chirag,

On 5/13/13 11:34 AM, Chirag Dewan wrote:
> I am embedding  Apache Tomcat 7.0.30 in my application. I am using
> the Tomcat class,and my application requires dynamic addition and
> removal of connectors(HTTP).
> 
> Now while removing the connectors,the application gets undeployed
> but the port remains occupied and the connector continue to listen
> on the port. I am using customized HTTP connector.
> 
> 
> Here is a snippet from my source code:
> 
> for removing connector:
> 
> if( connector != null ) { connector.decUsage(); if(
> connector.getUsage() == 0 ) { connector.stop(); 
> this.tomcat.getService().removeConnector( connector ); } }
> 
> for adding connector:
> 
> this.tomcat.getService().addConnector( connector );
> 
> 
> I know the port is not getting free. Because when I try to deploy
> to the same port again,it gives me an address already in use
> exception. I have surfed for this issue a lot,but to no avail. Any
> help would be greatly appreciated.

Can you take a thread dump and find which code look like it's doing
connection-related things?

How do you observe that the connector is still bound to the port?
netstat? What does it show? What happens if you make a request?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJRkRIbAAoJEBzwKT+lPKRYH4kP/2WiZK75ifzqSXojAw1ckw6k
iH5NvnWNNFeibFvqtj0tN2Nun+mb3atqs4ySwQahN/FAtz8klhdfGLTlccMxzh4u
x1yvMKLEh1Xr3qTxeot/y98zER/gubdgNsM4lr5MkkFVtaprK7/emz1OCwcuZe0L
XApJRuSNF+GxtH9lSKEw4Tn4kzc5Asv2gMQOQmLAmBi3fKI9MsoRS9V5TPU88dhL
XBk+rkcUdvL2KWKbP9yrt2Geu9NqBzqADCA4FJUESS9sm8A/VECzyUZ+4uW/jqiP
qpn4GSAtpaH9CyHzynZF5qyA8Fx+BllhyIFwZfUl5DMqk+t4gw3LdPay8Rkpfg7G
fdLHXrLez/Pcj2nvOp60OLeC4DD13AJON9KyYXmnUuk29aV/lrOes9nmUbIVDh8k
2LXh9cYErtD55bCgmTLPT0bLBpC9v1aUGEjFzeLjfJX9hEkvpUrN5OWvKHYg5Vaw
2qc+bV31qitjrUfZYU58S5UX1txATx6Ig76y/pt49XfiQFc6/GG25Ju5UCJOpat0
mOV4qTck+Exy+YuGvME7V/IcLAbymm9vGIB4bQD9dLq36Kx0cL5lE/DOYANd2PJD
0nBO/co4uRvKW54NDnHVzzpAU7IUXBoQ+SmU4IQMv1+TP6auHO8ekwDW7+59ZgCc
Ev3xtRom84ly50SQcxKf
=zDpF
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

Re: Port still busy after removing connector in Embedded Tomcat 7.0.30

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Chirag,

On 5/13/13 11:34 AM, Chirag Dewan wrote:
> I am embedding  Apache Tomcat 7.0.30 in my application. I am using
> the Tomcat class,and my application requires dynamic addition and
> removal of connectors(HTTP).
> 
> Now while removing the connectors,the application gets undeployed
> but the port remains occupied and the connector continue to listen
> on the port. I am using customized HTTP connector.
> 
> 
> Here is a snippet from my source code:
> 
> for removing connector:
> 
> if( connector != null ) { connector.decUsage(); if(
> connector.getUsage() == 0 ) { connector.stop(); 
> this.tomcat.getService().removeConnector( connector ); } }
> 
> for adding connector:
> 
> this.tomcat.getService().addConnector( connector );
> 
> 
> I know the port is not getting free. Because when I try to deploy
> to the same port again,it gives me an address already in use
> exception. I have surfed for this issue a lot,but to no avail. Any
> help would be greatly appreciated.

Can you take a thread dump and find which code look like it's doing
connection-related things?

How do you observe that the connector is still bound to the port?
netstat? What does it show? What happens if you make a request?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJRkRIbAAoJEBzwKT+lPKRYH4kP/2WiZK75ifzqSXojAw1ckw6k
iH5NvnWNNFeibFvqtj0tN2Nun+mb3atqs4ySwQahN/FAtz8klhdfGLTlccMxzh4u
x1yvMKLEh1Xr3qTxeot/y98zER/gubdgNsM4lr5MkkFVtaprK7/emz1OCwcuZe0L
XApJRuSNF+GxtH9lSKEw4Tn4kzc5Asv2gMQOQmLAmBi3fKI9MsoRS9V5TPU88dhL
XBk+rkcUdvL2KWKbP9yrt2Geu9NqBzqADCA4FJUESS9sm8A/VECzyUZ+4uW/jqiP
qpn4GSAtpaH9CyHzynZF5qyA8Fx+BllhyIFwZfUl5DMqk+t4gw3LdPay8Rkpfg7G
fdLHXrLez/Pcj2nvOp60OLeC4DD13AJON9KyYXmnUuk29aV/lrOes9nmUbIVDh8k
2LXh9cYErtD55bCgmTLPT0bLBpC9v1aUGEjFzeLjfJX9hEkvpUrN5OWvKHYg5Vaw
2qc+bV31qitjrUfZYU58S5UX1txATx6Ig76y/pt49XfiQFc6/GG25Ju5UCJOpat0
mOV4qTck+Exy+YuGvME7V/IcLAbymm9vGIB4bQD9dLq36Kx0cL5lE/DOYANd2PJD
0nBO/co4uRvKW54NDnHVzzpAU7IUXBoQ+SmU4IQMv1+TP6auHO8ekwDW7+59ZgCc
Ev3xtRom84ly50SQcxKf
=zDpF
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Port still busy after removing connector in Embedded Tomcat 7.0.30

Posted by David Kerber <dc...@verizon.net>.
On 5/14/2013 5:27 AM, Mark Thomas wrote:
> On 14/05/2013 04:34, Chirag Dewan wrote:
>>
>>
>>> You need to destroy the connector to close the port.
>>
>> Mark,
>>
>> That seems to work. :)
>>
>> Now the port is free. But is it the right approach?
>
> You had a problem you couldn't solve. Someone with an @apache.org e-mail
> address (i.e. an Apache committer and probably a Tomcat committer -
> something you can easily check) provided a solution that worked and you
> are asking if that solution is correct? I am trying very hard not to be
> to be extremely sarcastic right now.

Mark, remember that most people's e-mail clients will only show the 
"friendly" name of the e-mail sender if it's available, not the full 
e-mail address, so he probably didn't see your @Apache.org address.

Those of us who have been participating (or at least lurking) here for a 
while understand that you know pretty much everything there is to know 
about tomcat, but a new poster may not, so I'd give him the benefit of 
the doubt on this.

D


>
>> Is this something we need to do in Tomcat 7 specifically?
>
> There was a lot of lifecycle clean-up in Tomcat 7 including:
> - using the same interface for all components
> - adding JMX registration consistently
> - making sure things were symmetric (what is done in init() is undone in
> destroy(), what is done in start() is undone in stop())
>
> It is likely that binding and unbinding of the port were different in
> Tomcat 6 but I haven't checked svn to confirm this.
>
> Sockets in Tomcat 7 connectors are bound in init() and unbound in
> destroy() by default although you can change this to start() and stop()
> by setting the bindOnInit attribute on the connector to false.
>
> Mark
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Port still busy after removing connector in Embedded Tomcat 7.0.30

Posted by Mark Thomas <ma...@apache.org>.
On 14/05/2013 04:34, Chirag Dewan wrote:
> 
> 
>> You need to destroy the connector to close the port.
> 
> Mark,
> 
> That seems to work. :)
> 
> Now the port is free. But is it the right approach?

You had a problem you couldn't solve. Someone with an @apache.org e-mail
address (i.e. an Apache committer and probably a Tomcat committer -
something you can easily check) provided a solution that worked and you
are asking if that solution is correct? I am trying very hard not to be
to be extremely sarcastic right now.

> Is this something we need to do in Tomcat 7 specifically?

There was a lot of lifecycle clean-up in Tomcat 7 including:
- using the same interface for all components
- adding JMX registration consistently
- making sure things were symmetric (what is done in init() is undone in
destroy(), what is done in start() is undone in stop())

It is likely that binding and unbinding of the port were different in
Tomcat 6 but I haven't checked svn to confirm this.

Sockets in Tomcat 7 connectors are bound in init() and unbound in
destroy() by default although you can change this to start() and stop()
by setting the bindOnInit attribute on the connector to false.

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Port still busy after removing connector in Embedded Tomcat 7.0.30

Posted by Chirag Dewan <ch...@yahoo.in>.

> You need to destroy the connector to close the port.

Mark,

That seems to work. :)

Now the port is free. But is it the right approach? Is this something we need to do in Tomcat 7 specifically? 


Thanks.


________________________________
 From: Mark Thomas <ma...@apache.org>
To: Tomcat Users List <us...@tomcat.apache.org> 
Sent: Tuesday, 14 May 2013 2:41 AM
Subject: Re: Port still busy after removing connector in Embedded Tomcat 7.0.30
 

On 13/05/2013 16:34, Chirag Dewan wrote:
> Hi,
> 
> I am embedding  Apache Tomcat 7.0.30 in my application. I am using the Tomcat class,and my application requires dynamic addition and removal of connectors(HTTP).
> 
> Now while removing the connectors,the application gets undeployed but the port remains occupied and the connector continue to listen on the port. I am using customized HTTP connector.
> 
> 
>   Here is a snippet from my source code:
> 
> for removing connector:
> 
> if( connector != null )
>         {
>             connector.decUsage();
>             if( connector.getUsage() == 0 )
>             {
>                 connector.stop();
>                 this.tomcat.getService().removeConnector( connector );
>             }
>         }
> 
> for adding connector:
> 
> this.tomcat.getService().addConnector( connector );
> 
> 
> I know the port is not getting free. Because when I try to deploy to the same port again,it gives me an address already in use exception.
> I have surfed for this issue a lot,but to no avail. Any help would be greatly appreciated.

You need to destroy the connector to close the port.

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

Re: Port still busy after removing connector in Embedded Tomcat 7.0.30

Posted by Mark Thomas <ma...@apache.org>.
On 13/05/2013 16:34, Chirag Dewan wrote:
> Hi,
> 
> I am embedding  Apache Tomcat 7.0.30 in my application. I am using the Tomcat class,and my application requires dynamic addition and removal of connectors(HTTP).
> 
> Now while removing the connectors,the application gets undeployed but the port remains occupied and the connector continue to listen on the port. I am using customized HTTP connector.
> 
> 
>   Here is a snippet from my source code:
> 
> for removing connector:
> 
> if( connector != null )
>         {
>             connector.decUsage();
>             if( connector.getUsage() == 0 )
>             {
>                 connector.stop();
>                 this.tomcat.getService().removeConnector( connector );
>             }
>         }
> 
> for adding connector:
> 
> this.tomcat.getService().addConnector( connector );
> 
> 
> I know the port is not getting free. Because when I try to deploy to the same port again,it gives me an address already in use exception.
> I have surfed for this issue a lot,but to no avail. Any help would be greatly appreciated.

You need to destroy the connector to close the port.

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org