Re: Serve same content to multiple URL's
Chris Arnold wrote: I didn't think I needed a second worker but because the working config only worked for http://share.domain1.com and nothing else, I wanted to verify it should work or I needed another worker and you verified I do not need another worker and in fact, the existing config for http://share.domain1.com should work for http://share.domain2.com You definitely don't need a second worker. Great! I know i am going in the right direction Why do you need a second VirtualHost, even? Apache has to answer for that request (http://share.domain2.com) and pass it to tomcat Maybe some basic information to clear up things in the first place : When you work with virtual hosts, as well under Apache httpd as under Tomcat, the basic principle is this : When the server receives the request, it examines the request to determine to which hostname it is addressed. The server then cycles through all the hosts in its configuration, to find one whose declared hostname matches the hostname contained in the request. If it finds one that matches (either on the declared hostname or a declared alias), it loads the configuration of that one, to process this request. If it does not find a declared host that matches, then it defaults to its default host to process this request. Both Apache httpd and Tomcat have a default host, but the way in which this is configured is different in each. - for Tomcat, it is the host which is declared in the Engine tag of rhe server.xml file. Usually, this is : Engine name=Catalina defaultHost=localhost and later in the server.xml. you will find the corresponding Host tag, like : Host name=localhost ... - for Apache httpd, there is no explicity defined default host, but the default host is the first declared VirtualHost (*) matching the port on which the request was received. (*) from top to bottom of the configuration file, including all the includes) So, assuming that all requests which are forwarded by Apache to Tomcat can be processed by the same webapp(s), then you do not need to define any virtual hosts in Tomcat (other than the standard default Host name=localhost, because : when Tomcat receives the request, it will look at the host to which it is addressed, and try to match this with the hostname or alias of one of its Host's. Since it will not find any, it will default to the Host name=localhost to process the request, and that's exactly what you want anyway. It is the same within Apache httpd : if all you want is that your server accepts requests for hostname1.mycompany.com and hostname2.mycompany.com and processes them in exactly the same way, then all you would need to do is define one VirtualHost such that either the ServerName or a ServerAlias matches one of those names (or so that none matches, which would cause the request to be processed by the default host). You /can/ define 2 VirtualHost's, each with the appropriate ServerName, but you don't really have to do that unless you really want some things to happen differently in each. (which in reality, is likely to happen sooner or later, so maybe you want to bite the bullet now anyway. But that's your choice). - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Tomcat7 - ajax and connection pool : connection closed despite the use of validationQuery and testOnBorrow
Hi, I use the connection pool of tomcat7 and set a connection in a ThreadLocal. The context is a web application : the threadLocal is configured when the http request is initialized. The jdbc connection is closed and removed from the threadLocal when the resquest is destroyed. If I'm not mistaken, each http request is treated by one thread by tomcat. So, I have one jdbc connection for each request ( = thread). My problem appears when I use Ajax. For 2 successive ajax request, I have the error Connection closed : it's a random problem (the stacktrace is not the same for the 2 attemps and it's not depending of the thread execution order). I know this issue : http://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html#Random_Connection_Closed_Exceptions These can occur when one request gets a db connection from the connection pool and closes it twice. When using a connection pool, closing the connection just returns it to the pool for reuse by another request, it doesn't close the connection. And Tomcat uses multiple threads to handle concurrent requests But, I'm sure, I always close the connection only once. I use too the validationQuery and testOnBorrow parameters. Is it possible that the connection pool returns the same connection for 2 different threads? So I don't understand why my connection is closed during the treatment. Thank for your help - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: problem with clustering
Am 04.04.2013 15:01, schrieb Daniel Mikusa: The tomcat version is 6.0.18, running on Linux 2.6.24, Java version is 1.6.0_13. It would be helpful to post your configuration, minus comments, as well as the exact version of Tomcat that you are running. ?xml version='1.0' encoding='utf-8'? Server port=8005 shutdown=SHUTDOWN Listener className=org.apache.catalina.core.AprLifecycleListener SSLEngine=on / Listener className=org.apache.catalina.core.JasperListener / Listener className=org.apache.catalina.mbeans.ServerLifecycleListener / Listener className=org.apache.catalina.mbeans.GlobalResourcesLifecycleListener / GlobalNamingResources Resource name=UserDatabase auth=Container type=org.apache.catalina.UserDatabase description=User database that can be updated and saved factory=org.apache.catalina.users.MemoryUserDatabaseFactory pathname=conf/tomcat-users.xml / /GlobalNamingResources Service name=Catalina Connector port=8090 protocol=HTTP/1.1 connectionTimeout=2 redirectPort=8443 / Connector port=8009 protocol=AJP/1.3 redirectPort=8443 / Engine name=Catalina defaultHost=localhost Cluster className=org.apache.catalina.ha.tcp.SimpleTcpCluster/ Realm className=org.apache.catalina.realm.UserDatabaseRealm resourceName=UserDatabase/ Host name=localhost appBase=webapps unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false /Host /Engine /Service /Server If you suspect a network issue, you could try monitoring with Wireshark or tcpdump to capture the network packets. Analysis of the packets could show if there is a problem. Another option would be to try and use a tool like iperf to put a high load on your network and possibly trigger the problem. Dan
Re: Tomcat7 - ajax and connection pool : connection closed despite the use of validationQuery and testOnBorrow
Am 2013-04-05 11:37, schrieb Jean-Claude Haw-King-Chon: Hi, I use the connection pool of tomcat7 and set a connection in a ThreadLocal. The context is a web application : the threadLocal is configured when the http request is initialized. The jdbc connection is closed and removed from the threadLocal when the resquest is destroyed. Why do you do that at all? Why don't you simply use such an idiom in your thead/controller: ... Connection conn = ConnetionUtils.getReadWriteConnection(DataSource dataSource); // has to be implemented of course .. Use this connetion in the entire thread, pass it along, when you are done. Close it. ThreadLocals are useful in other cases but not in this one. Michael - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat7 - ajax and connection pool : connection closed despite the use of validationQuery and testOnBorrow
I wish to avoid passing the connection through the layers of the application (from controller to DAO). The controller initialize the connection and must pass it to the Dao layer. I don't want to pass the datasource or connection to the business layer as a parameter. Futher, the data source can be different for each user : it's not possible to use a static attribute to store the connection or the datasource (by example, in a connection factory). That's why I think that threadlocal is the solution for passing the connection between 2 non adjacent layers : is it a bad practice? Jean-Claude HAW-KING-CHON *MédiFirst ** **Immeuble LE SESAME** *8 rue Germain Soufflot 78180 Montigny le Bretonneux *Hotline Support: 01 79 85 39 40* Le 05/04/2013 12:40, Michael-O a écrit : Am 2013-04-05 11:37, schrieb Jean-Claude Haw-King-Chon: Hi, I use the connection pool of tomcat7 and set a connection in a ThreadLocal. The context is a web application : the threadLocal is configured when the http request is initialized. The jdbc connection is closed and removed from the threadLocal when the resquest is destroyed. Why do you do that at all? Why don't you simply use such an idiom in your thead/controller: ... Connection conn = ConnetionUtils.getReadWriteConnection(DataSource dataSource); // has to be implemented of course .. Use this connetion in the entire thread, pass it along, when you are done. Close it. ThreadLocals are useful in other cases but not in this one. Michael - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat7 - ajax and connection pool : connection closed despite the use of validationQuery and testOnBorrow
2013/4/5 Jean-Claude Haw-King-Chon jchaw-king-c...@medifirst.fr: Hi, I use the connection pool of tomcat7 and set a connection in a ThreadLocal. The context is a web application : the threadLocal is configured when the http request is initialized. The jdbc connection is closed and removed from the threadLocal when the resquest is destroyed. 1. What exactly do you mean by initialized and destroyed? If I'm not mistaken, each http request is treated by one thread by tomcat. So, I have one jdbc connection for each request ( = thread). 2. No. It depends on how you use it and at what points in time you look at it. If you look at it in a call chain, e.g. using try{ } finally block in a Filter, then yes, all calls inside of try belong to the same thread. If you return processing to Tomcat and Tomcat makes a different call into your code (e.g. using Async or Comet APIs), then that call can be using a different thread from a thread pool. (...) My problem appears when I use Ajax. For 2 successive ajax request, I have the error Connection closed : it's a random problem (the stacktrace is not the same for the 2 attemps and it's not depending of the thread execution order). I know this issue : http://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html#Random_Connection_Closed_Exceptions These can occur when one request gets a db connection from the connection pool and closes it twice. When using a connection pool, closing the connection just returns it to the pool for reuse by another request, it doesn't close the connection. And Tomcat uses multiple threads to handle concurrent requests But, I'm sure, I always close the connection only once. I use too the validationQuery and testOnBorrow parameters. Is it possible that the connection pool returns the same connection for 2 different threads? You can check its hash code. So I don't understand why my connection is closed during the treatment. Best regards, Konstantin Kolinko - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat7 - ajax and connection pool : connection closed despite the use of validationQuery and testOnBorrow
Fist of all, do NOT top post. Use the power of your wondeful mail client. Am 2013-04-05 13:05, schrieb Jean-Claude Haw-King-Chon: I wish to avoid passing the connection through the layers of the application (from controller to DAO). The controller initialize the connection and must pass it to the Dao layer. I don't want to pass the datasource or connection to the business layer as a parameter. Futher, the data source can be different for each user : it's not possible to use a static attribute to store the connection or the datasource (by example, in a connection factory). That's why I think that threadlocal is the solution for passing the connection between 2 non adjacent layers : is it a bad practice? ThreadLocals have their use cases but must be used with great caution. Are you certain that no one else sets the ThreadLocal and you do not suffer from race conditions due to missing synchronization? Michael - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
websockets holding on to threads.
I am seeing what at first appears to be a bug, but given the lack of other reports I can't believe I am the only person seeing this, so maybe it is user-error. I have tomcat (was 7.0.30, but I just tried with 7.0.39) running a website which uses websockets. The websockets code in tomcat isn't that complicated - My servlet returns a new subclass of StreamInbound which has overridden the onTextData() and onBinaryData() methods. This seems to generally work fine, and I can send and receive data happily. However when I load up several browser windows I find that tomcat hangs. I used jconsole to check the tomcat threads and found that as I open each new websocket, the tomcat worker threads go from idle threads waiting for work to the following busy, blocking threads waiting for websocket data. Name: http-bio-4415-exec-5 State: RUNNABLE Total blocked: 50 Total waited: 112 Stack trace: java.net.SocketInputStream.socketRead0(Native Method) java.net.SocketInputStream.read(SocketInputStream.java:161) java.net.SocketInputStream.read(SocketInputStream.java:132) org.apache.coyote.http11.upgrade.UpgradeBioProcessor.read(UpgradeBioProcessor.java:81) org.apache.catalina.websocket.WsFrame.nextFrame(WsFrame.java:214) org.apache.catalina.websocket.WsInputStream.nextFrame(WsInputStream.java:68) org.apache.catalina.websocket.StreamInbound.onData(StreamInbound.java:149) org.apache.coyote.http11.upgrade.UpgradeProcessor.upgradeDispatch(UpgradeProcessor.java:83) org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:587) org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) - locked org.apache.tomcat.util.net.SocketWrapper@ddb0d168 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1156) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:626) java.lang.Thread.run(Thread.java:780) I am trying to figure out what I am missing. I didn't think I needed to override StreamInbound.onData() in my class, but as that seems to be what is keeping the thread busy, presumably waiting for data looking at that stack. Am I misunderstanding something, or is this possibly a tomcat bug? Unless stated otherwise above: IBM United Kingdom Limited - Registered in England and Wales with number 741598. Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
Re: problem with clustering
On Apr 5, 2013, at 6:02 AM, Andy Pahne wrote: Am 04.04.2013 15:01, schrieb Daniel Mikusa: The tomcat version is 6.0.18, running on Linux 2.6.24, Java version is 1.6.0_13. That's incredibly old, you should look at upgrading ASAP. It would be helpful to post your configuration, minus comments, as well as the exact version of Tomcat that you are running. ?xml version='1.0' encoding='utf-8'? Server port=8005 shutdown=SHUTDOWN Listener className=org.apache.catalina.core.AprLifecycleListener SSLEngine=on / Listener className=org.apache.catalina.core.JasperListener / Listener className=org.apache.catalina.mbeans.ServerLifecycleListener / Listener className=org.apache.catalina.mbeans.GlobalResourcesLifecycleListener / GlobalNamingResources Resource name=UserDatabase auth=Container type=org.apache.catalina.UserDatabase description=User database that can be updated and saved factory=org.apache.catalina.users.MemoryUserDatabaseFactory pathname=conf/tomcat-users.xml / /GlobalNamingResources Service name=Catalina Connector port=8090 protocol=HTTP/1.1 connectionTimeout=2 redirectPort=8443 / Connector port=8009 protocol=AJP/1.3 redirectPort=8443 / Engine name=Catalina defaultHost=localhost Cluster className=org.apache.catalina.ha.tcp.SimpleTcpCluster/ While this will work, you can't customize any of the cluster configuration settings when you use it. You might want to look at replacing this with the expanded XML for a cluster setup. It's a lot more XML, but it gives you much more control over your configuration. See the following link which shows what the above element is equivalent to. https://tomcat.apache.org/tomcat-6.0-doc/cluster-howto.html#For_the_impatient Once you make the switch, you can try adjusting the dropTime and frequency settings like I mentioned in my previous email. You'd set them on the Membership/ element. https://tomcat.apache.org/tomcat-6.0-doc/config/cluster-membership.html Dan Realm className=org.apache.catalina.realm.UserDatabaseRealm resourceName=UserDatabase/ Host name=localhost appBase=webapps unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false /Host /Engine /Service /Server If you suspect a network issue, you could try monitoring with Wireshark or tcpdump to capture the network packets. Analysis of the packets could show if there is a problem. Another option would be to try and use a tool like iperf to put a high load on your network and possibly trigger the problem. Dan - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: problem with clustering
Am 05.04.2013 15:34, schrieb Daniel Mikusa: Am 04.04.2013 15:01, schrieb Daniel Mikusa: The tomcat version is 6.0.18, running on Linux 2.6.24, Java version is 1.6.0_13. That's incredibly old, you should look at upgrading ASAP. I know. That's not really my call, unfortunatly. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: Tomcat and Window nonpaged pool
-Original Message- From: André Warnier [mailto:a...@ice-sa.com] Sent: Thursday, April 04, 2013 12:34 PM To: Tomcat Users List Subject: Re: Tomcat and Window nonpaged pool Jeffrey Janner wrote: -Original Message- From: Harris, Jeffrey E. [mailto:jeffrey.har...@mantech.com] Sent: Thursday, April 04, 2013 10:45 AM To: Tomcat Users List Subject: RE: Tomcat and Window nonpaged pool -Original Message- From: Jeffrey Janner [mailto:jeffrey.jan...@polydyne.com] Sent: Thursday, April 04, 2013 11:04 AM To: 'Tomcat Users List' Subject: Tomcat and Window nonpaged pool Tomcat 6.0.x (unsure but 33+) with Java 1.6 and Windows 2008 Server. I've got a customer who is monitoring his system using the Windows Performance Monitor and is concerned about Tomcat usage of the nonpaged pool. When monitoring just the Tomcat service, it shows the line for the pool to slowly rise over time, with hardly ever a drop that cannot be attributed to a restart of the service (I think). I know that the nonpaged pool contains structures that should not be paged out by Windows per this quote: Nonpaged pool is therefore always kept present in physical memory and nonpaged pool virtual memory is assigned physical memory. Common system data structures stored in nonpaged pool include the kernel and objects that represent processes and threads, synchronization objects like mutexes, semaphores and events, references to files, which are represented as file objects, and I/O request packets (IRPs), which represent I/O operations. I am struggling with how this relates to internal workings of Tomcat Java. Obviously, as more processing threads, in this case connectors not executors, are opened, I would expect to see a rise in this pool to support all the items it uses. I would expect to see a drop as usage dropped and connectors were returned (or are they permanent at 6). Also, I assume processing threads for the Oracle connection pool will cause this to increase as well, and should drop as the pool size drop back to normal. Any app-based threads would also cause a rise, but should drop if the thread is properly terminated. I guess that this shows a potential memory leak somewhere, I'm just wondering if there are other things I should look at that could determine if this is normal behavior or indicative of a real issue. I do most of my Tomcat app monitoring using jconsole, jvisualvm, and the Oracle OEM for looking for connection pool leaks there (not an easy task). Any help is appreciated. Jeff You might try the procedure in this URL to further isolate the issue: https://www.simple-talk.com/sysadmin/general/troubleshooting- nonpaged - and-paged-pool-errors-in-windows/ If you have the ability, you might also try disconnecting your Webapps and Oracle and see if simply running Tomcat by itself still displays the same behavior; if so, then the issue is probably Tomcat, rather than a Webapp or Oracle. If you are not using the latest version of Tomcat 6.0, you might also want to try upgrading and see if the behavior changes, as it is possible there are memory leaks in earlier versions of Tomcat (some of the Tomcat developers can speak to that). Jeffrey Harris Oh, I fully expect any problems to be with our webapp and not Tomcat. The end user should be on a version of Tomcat6 very near the latest release, at least if they are following our usage recommendations. Unfortunately, it's at a customer site and I have not access to it. I'm totally dependent on their willingness to research the issue on their end and any information about how they are using the app vs. our other customers. I think they are using a specific feature that is little used by 90% of our customer base causing the issue. I ran the same monitor against two of my hosted Tomcat instances, with several virtual hosts each, meaning a diverse user base. It does not appear to show the pattern. However, I may need to do a longer run to see if I replicate their results. My results were over a 15 minute period. Theirs was several days. Mine remained flat, or nearly so. In fact, I saw a nice little random rise and fall in the graph right around a central value for both Tomcats. One actually ended lower than it started. So, I'm pretty sure it's our app and how it's being used. Just trying to understand what objects might be getting tossed into this pool, so I know what to go after. Does you app connect to anything by itself ? If so, does it close these connections properly ? netstat -pan might show something. Yes, it connects to an Oracle DB, and I strongly suspect they may be seeing a connection pool leak in a little-used bit of code. But I'm also trying to figure this out without access to the machines themselves, so was hoping to get guidance on other questions to ask them.
Re: Tomcat and Window nonpaged pool
Jeffrey Janner wrote: -Original Message- From: André Warnier [mailto:a...@ice-sa.com] Sent: Thursday, April 04, 2013 12:34 PM To: Tomcat Users List Subject: Re: Tomcat and Window nonpaged pool Jeffrey Janner wrote: -Original Message- From: Harris, Jeffrey E. [mailto:jeffrey.har...@mantech.com] Sent: Thursday, April 04, 2013 10:45 AM To: Tomcat Users List Subject: RE: Tomcat and Window nonpaged pool -Original Message- From: Jeffrey Janner [mailto:jeffrey.jan...@polydyne.com] Sent: Thursday, April 04, 2013 11:04 AM To: 'Tomcat Users List' Subject: Tomcat and Window nonpaged pool Tomcat 6.0.x (unsure but 33+) with Java 1.6 and Windows 2008 Server. I've got a customer who is monitoring his system using the Windows Performance Monitor and is concerned about Tomcat usage of the nonpaged pool. When monitoring just the Tomcat service, it shows the line for the pool to slowly rise over time, with hardly ever a drop that cannot be attributed to a restart of the service (I think). I know that the nonpaged pool contains structures that should not be paged out by Windows per this quote: Nonpaged pool is therefore always kept present in physical memory and nonpaged pool virtual memory is assigned physical memory. Common system data structures stored in nonpaged pool include the kernel and objects that represent processes and threads, synchronization objects like mutexes, semaphores and events, references to files, which are represented as file objects, and I/O request packets (IRPs), which represent I/O operations. I am struggling with how this relates to internal workings of Tomcat Java. Obviously, as more processing threads, in this case connectors not executors, are opened, I would expect to see a rise in this pool to support all the items it uses. I would expect to see a drop as usage dropped and connectors were returned (or are they permanent at 6). Also, I assume processing threads for the Oracle connection pool will cause this to increase as well, and should drop as the pool size drop back to normal. Any app-based threads would also cause a rise, but should drop if the thread is properly terminated. I guess that this shows a potential memory leak somewhere, I'm just wondering if there are other things I should look at that could determine if this is normal behavior or indicative of a real issue. I do most of my Tomcat app monitoring using jconsole, jvisualvm, and the Oracle OEM for looking for connection pool leaks there (not an easy task). Any help is appreciated. Jeff You might try the procedure in this URL to further isolate the issue: https://www.simple-talk.com/sysadmin/general/troubleshooting- nonpaged - and-paged-pool-errors-in-windows/ If you have the ability, you might also try disconnecting your Webapps and Oracle and see if simply running Tomcat by itself still displays the same behavior; if so, then the issue is probably Tomcat, rather than a Webapp or Oracle. If you are not using the latest version of Tomcat 6.0, you might also want to try upgrading and see if the behavior changes, as it is possible there are memory leaks in earlier versions of Tomcat (some of the Tomcat developers can speak to that). Jeffrey Harris Oh, I fully expect any problems to be with our webapp and not Tomcat. The end user should be on a version of Tomcat6 very near the latest release, at least if they are following our usage recommendations. Unfortunately, it's at a customer site and I have not access to it. I'm totally dependent on their willingness to research the issue on their end and any information about how they are using the app vs. our other customers. I think they are using a specific feature that is little used by 90% of our customer base causing the issue. I ran the same monitor against two of my hosted Tomcat instances, with several virtual hosts each, meaning a diverse user base. It does not appear to show the pattern. However, I may need to do a longer run to see if I replicate their results. My results were over a 15 minute period. Theirs was several days. Mine remained flat, or nearly so. In fact, I saw a nice little random rise and fall in the graph right around a central value for both Tomcats. One actually ended lower than it started. So, I'm pretty sure it's our app and how it's being used. Just trying to understand what objects might be getting tossed into this pool, so I know what to go after. Does you app connect to anything by itself ? If so, does it close these connections properly ? netstat -pan might show something. Yes, it connects to an Oracle DB, and I strongly suspect they may be seeing a connection pool leak in a little-used bit of code. But I'm also trying to figure this out without access to the machines themselves, so was hoping to get guidance on other questions to ask them. Essentially, as I understand it, the non-paged pool primarily stores data structures needed to manage threads and
Re: Tomcat7 - ajax and connection pool : connection closed despite the use of validationQuery and testOnBorrow
Le 05/04/2013 13:09, Konstantin Kolinko a écrit : 2013/4/5 Jean-Claude Haw-King-Chon jchaw-king-c...@medifirst.fr: Hi, I use the connection pool of tomcat7 and set a connection in a ThreadLocal. The context is a web application : the threadLocal is configured when the http request is initialized. The jdbc connection is closed and removed from the threadLocal when the resquest is destroyed. 1. What exactly do you mean by initialized and destroyed? If I'm not mistaken, each http request is treated by one thread by tomcat. So, I have one jdbc connection for each request ( = thread). 2. No. It depends on how you use it and at what points in time you look at it. If you look at it in a call chain, e.g. using try{ } finally block in a Filter, then yes, all calls inside of try belong to the same thread. If you return processing to Tomcat and Tomcat makes a different call into your code (e.g. using Async or Comet APIs), then that call can be using a different thread from a thread pool. (...) My problem appears when I use Ajax. For 2 successive ajax request, I have the error Connection closed : it's a random problem (the stacktrace is not the same for the 2 attemps and it's not depending of the thread execution order). I know this issue : http://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html#Random_Connection_Closed_Exceptions These can occur when one request gets a db connection from the connection pool and closes it twice. When using a connection pool, closing the connection just returns it to the pool for reuse by another request, it doesn't close the connection. And Tomcat uses multiple threads to handle concurrent requests But, I'm sure, I always close the connection only once. I use too the validationQuery and testOnBorrow parameters. Is it possible that the connection pool returns the same connection for 2 different threads? You can check its hash code. So I don't understand why my connection is closed during the treatment. Best regards, Konstantin Kolinko - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org 1. What exactly do you mean by initialized and destroyed? Sorry, to be more precise, 2 approches has been tested : 1) The connection is initialized in the servlet by a method called by doGet or doPost. But the connection is closed (and removed from the threadLocal) by a ServletRequestListener in the override of the requestDestroyed method. 2) The connection is initialized in the servlet by a method called by doGet or doPost. The process is encapsuled in a try/catch/finally block. The connection is closed (and removed from the threadLocal) in the finally block. These 2 approches didn't work (random closed connection). 2. No. It depends on how you use it and at what points in time you look at it. So for the 2 approches, I'm in a call chain. Is it possible that the connection pool returns the same connection for 2 different threads? You can check its hash code. Thank you for this tip. The thread name and the connection hashCode are now logged : I'm trying to understand the mechanism. The first results show that the problem appears with connections precedently closed... My configuration : Resource name=jdbc/607 auth=Container type=javax.sql.DataSource username=x password=x driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/X removeAbandoned=true removeAbandonedTimeout=300 testOnBorrow=true validationQuery=SELECT 1 logAbandoned=true / Tomcat 7.0.29 Linux Fedora Core 12 - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat7 - ajax and connection pool : connection closed despite the use of validationQuery and testOnBorrow
2013/4/5 Jean-Claude Haw-King-Chon jchaw-king-c...@medifirst.fr: Le 05/04/2013 13:09, Konstantin Kolinko a écrit : 2013/4/5 Jean-Claude Haw-King-Chon jchaw-king-c...@medifirst.fr: Hi, I use the connection pool of tomcat7 and set a connection in a ThreadLocal. The context is a web application : the threadLocal is configured when the http request is initialized. The jdbc connection is closed and removed from the threadLocal when the resquest is destroyed. 1. What exactly do you mean by initialized and destroyed? If I'm not mistaken, each http request is treated by one thread by tomcat. So, I have one jdbc connection for each request ( = thread). 2. No. It depends on how you use it and at what points in time you look at it. If you look at it in a call chain, e.g. using try{ } finally block in a Filter, then yes, all calls inside of try belong to the same thread. If you return processing to Tomcat and Tomcat makes a different call into your code (e.g. using Async or Comet APIs), then that call can be using a different thread from a thread pool. (...) My problem appears when I use Ajax. For 2 successive ajax request, I have the error Connection closed : it's a random problem (the stacktrace is not the same for the 2 attemps and it's not depending of the thread execution order). I know this issue : http://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html#Random_Connection_Closed_Exceptions These can occur when one request gets a db connection from the connection pool and closes it twice. When using a connection pool, closing the connection just returns it to the pool for reuse by another request, it doesn't close the connection. And Tomcat uses multiple threads to handle concurrent requests But, I'm sure, I always close the connection only once. I use too the validationQuery and testOnBorrow parameters. Is it possible that the connection pool returns the same connection for 2 different threads? You can check its hash code. So I don't understand why my connection is closed during the treatment. Best regards, Konstantin Kolinko - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org 1. What exactly do you mean by initialized and destroyed? Sorry, to be more precise, 2 approches has been tested : 1) The connection is initialized in the servlet by a method called by doGet or doPost. But the connection is closed (and removed from the threadLocal) by a ServletRequestListener in the override of the requestDestroyed method. 2) The connection is initialized in the servlet by a method called by doGet or doPost. The process is encapsuled in a try/catch/finally block. The connection is closed (and removed from the threadLocal) in the finally block. These 2 approches didn't work (random closed connection). You should go with 2). 2. No. It depends on how you use it and at what points in time you look at it. So for the 2 approches, I'm in a call chain. Is it possible that the connection pool returns the same connection for 2 different threads? You can check its hash code. Thank you for this tip. The thread name and the connection hashCode are now logged : I'm trying to understand the mechanism. The first results show that the problem appears with connections precedently closed... My configuration : Resource name=jdbc/607 auth=Container type=javax.sql.DataSource username=x password=x driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/X removeAbandoned=true removeAbandonedTimeout=300 testOnBorrow=true validationQuery=SELECT 1 logAbandoned=true / Tomcat 7.0.29 Linux Fedora Core 12 Do you have queries that run or are used for more than 5 minutes in a single request? If so, then your removeAbandonedTimeout is too short and removeAbandoned will close them. http://commons.apache.org/proper/commons-dbcp/configuration.html BTW, your pool size is 8. Best regards, Konstantin Kolinko - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat7 - ajax and connection pool : connection closed despite the use of validationQuery and testOnBorrow
Hi Konstantin: About this link http://commons.apache.org/proper/commons-dbcp/configuration.html If you have enabled removeAbandoned then it is possible that a connection is reclaimed by the pool because it is considered to be abandoned. This mechanism is triggered when (getNumIdle() 2) and (getNumActive() getMaxActive() - 3) I know that it's about DBCP , not JDBC Pool in Tomcat 7, but Do you know if it's the same mechanism ? In this case, this mechanism only is useful when pool is about to be exhausted, right ? Regards Do you have queries that run or are used for more than 5 minutes in a single request? If so, then your removeAbandonedTimeout is too short and removeAbandoned will close them. http://commons.apache.org/proper/commons-dbcp/configuration.html BTW, your pool size is 8. Best regards, Konstantin Kolinko - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: websockets holding on to threads.
On Fri, Apr 5, 2013 at 9:07 AM, Anton Piatek1 anton.pia...@uk.ibm.comwrote: I am seeing what at first appears to be a bug, but given the lack of other reports I can't believe I am the only person seeing this, so maybe it is user-error. I have tomcat (was 7.0.30, but I just tried with 7.0.39) running a website which uses websockets. The websockets code in tomcat isn't that complicated - My servlet returns a new subclass of StreamInbound which has overridden the onTextData() and onBinaryData() methods. This seems to generally work fine, and I can send and receive data happily. However when I load up several browser windows I find that tomcat hangs. I used jconsole to check the tomcat threads and found that as I open each new websocket, the tomcat worker threads go from idle threads waiting for work to the following busy, blocking threads waiting for websocket data. I have not written low-level websocket code as you are doing, but I think I have seen this behavior even in/with my app, and others have reported and discussed this issue in more ways than one. I am using Atmosphere Framework via PrimeFaces Push to implement websockets in my app, and it does work well with one browser tab/window, but it is commonly reported that websockets do not work when one client (machine) has multiple simultaneous websocket connections to the server. Since I use Atmosphere Framework, I searched their google groups for the following: browser windows and found the following (URL and quote from page at URL below): https://github.com/Atmosphere/atmosphere/issues/493 According to HTTP RFChttp://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html : Clients that use persistent connections SHOULD limit the number of simultaneous connections that they maintain to a given server. A single-user client SHOULD NOT maintain more than 2 connections with any server or proxy. This can cause problems if you have multiple tabs/window open, which all maintain a persistent connection. It would be great if persistent connections should be shared (as GWT or Bayeux Protocolhttp://svn.cometd.com/trunk/bayeux/bayeux.htm does it). Name: http-bio-4415-exec-5 State: RUNNABLE Total blocked: 50 Total waited: 112 Stack trace: java.net.SocketInputStream.socketRead0(Native Method) java.net.SocketInputStream.read(SocketInputStream.java:161) java.net.SocketInputStream.read(SocketInputStream.java:132) org.apache.coyote.http11.upgrade.UpgradeBioProcessor.read(UpgradeBioProcessor.java:81) org.apache.catalina.websocket.WsFrame.nextFrame(WsFrame.java:214) org.apache.catalina.websocket.WsInputStream.nextFrame(WsInputStream.java:68) org.apache.catalina.websocket.StreamInbound.onData(StreamInbound.java:149) org.apache.coyote.http11.upgrade.UpgradeProcessor.upgradeDispatch(UpgradeProcessor.java:83) org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:587) org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) - locked org.apache.tomcat.util.net.SocketWrapper@ddb0d168 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1156) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:626) java.lang.Thread.run(Thread.java:780) I am trying to figure out what I am missing. I didn't think I needed to override StreamInbound.onData() in my class, but as that seems to be what is keeping the thread busy, presumably waiting for data looking at that stack. Am I misunderstanding something, or is this possibly a tomcat bug? I don't think this is a tomcat bug, but I could be mistaking. Unless stated otherwise above: IBM United Kingdom Limited - Registered in England and Wales with number 741598. Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
RE: Tomcat7 - ajax and connection pool : connection closed despite the use of validationQuery and testOnBorrow
I could be wrong, but is that validationQuery attribute correct? SELECT 1 ? - I have validationQuery=select 1 from dual in mine, and my doc states it has to be a valid SQL statement returning at least one row. That may not factor in at all, just noticed it. Looked maybe out of kilter. -Original Message- From: Jean-Claude Haw-King-Chon [mailto:jchaw-king-c...@medifirst.fr] Sent: Friday, April 05, 2013 10:38 AM To: Tomcat Users List Subject: Re: Tomcat7 - ajax and connection pool : connection closed despite the use of validationQuery and testOnBorrow .. My configuration : Resource name=jdbc/607 auth=Container type=javax.sql.DataSource username=x password=x driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/X removeAbandoned=true removeAbandonedTimeout=300 testOnBorrow=true validationQuery=SELECT 1 logAbandoned=true / Tomcat 7.0.29 Linux Fedora Core 12 - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat7 - ajax and connection pool : connection closed despite the use of validationQuery and testOnBorrow
'select 1 from dual' works in Oracle DB In MySQL, select 1 2013/4/5 Propes, Barry L barry.l.pro...@citi.com I could be wrong, but is that validationQuery attribute correct? SELECT 1 ? - I have validationQuery=select 1 from dual in mine, and my doc states it has to be a valid SQL statement returning at least one row. That may not factor in at all, just noticed it. Looked maybe out of kilter. -Original Message- From: Jean-Claude Haw-King-Chon [mailto:jchaw-king-c...@medifirst.fr] Sent: Friday, April 05, 2013 10:38 AM To: Tomcat Users List Subject: Re: Tomcat7 - ajax and connection pool : connection closed despite the use of validationQuery and testOnBorrow .. My configuration : Resource name=jdbc/607 auth=Container type=javax.sql.DataSource username=x password=x driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/X removeAbandoned=true removeAbandonedTimeout=300 testOnBorrow=true validationQuery=SELECT 1 logAbandoned=true / Tomcat 7.0.29 Linux Fedora Core 12 - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: Tomcat7 - ajax and connection pool : connection closed despite the use of validationQuery and testOnBorrow
Ok, thanks for clarification. I thought it had to be from some faux table or object. -Original Message- From: Jose María Zaragoza [mailto:demablo...@gmail.com] Sent: Friday, April 05, 2013 3:44 PM To: Tomcat Users List Subject: Re: Tomcat7 - ajax and connection pool : connection closed despite the use of validationQuery and testOnBorrow 'select 1 from dual' works in Oracle DB In MySQL, select 1 2013/4/5 Propes, Barry L barry.l.pro...@citi.com I could be wrong, but is that validationQuery attribute correct? SELECT 1 ? - I have validationQuery=select 1 from dual in mine, and my doc states it has to be a valid SQL statement returning at least one row. That may not factor in at all, just noticed it. Looked maybe out of kilter. -Original Message- From: Jean-Claude Haw-King-Chon [mailto:jchaw-king-c...@medifirst.fr] Sent: Friday, April 05, 2013 10:38 AM To: Tomcat Users List Subject: Re: Tomcat7 - ajax and connection pool : connection closed despite the use of validationQuery and testOnBorrow .. My configuration : Resource name=jdbc/607 auth=Container type=javax.sql.DataSource username=x password=x driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/X removeAbandoned=true removeAbandonedTimeout=300 testOnBorrow=true validationQuery=SELECT 1 logAbandoned=true / Tomcat 7.0.29 Linux Fedora Core 12 - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat7 - ajax and connection pool : connection closed despite the use of validationQuery and testOnBorrow
And that's right . You can define any SQL , but you prefer the easiest ( and fastest ) Indeed , you could use SELECT 1 FROM DUAL in MySQL, but it's not required by using FROM DUAL From MySQL doc DUAL is purely for the convenience of people who require that all SELECT statements should have FROM and possibly other clauses. MySQL may ignore the clauses. MySQL does not require FROM DUAL if no tables are referenced. I think that Oracle requires FROM word in queries ( I think ) 2013/4/5 Propes, Barry L barry.l.pro...@citi.com Ok, thanks for clarification. I thought it had to be from some faux table or object. -Original Message- From: Jose María Zaragoza [mailto:demablo...@gmail.com] Sent: Friday, April 05, 2013 3:44 PM To: Tomcat Users List Subject: Re: Tomcat7 - ajax and connection pool : connection closed despite the use of validationQuery and testOnBorrow 'select 1 from dual' works in Oracle DB In MySQL, select 1 2013/4/5 Propes, Barry L barry.l.pro...@citi.com I could be wrong, but is that validationQuery attribute correct? SELECT 1 ? - I have validationQuery=select 1 from dual in mine, and my doc states it has to be a valid SQL statement returning at least one row. That may not factor in at all, just noticed it. Looked maybe out of kilter. -Original Message- From: Jean-Claude Haw-King-Chon [mailto:jchaw-king-c...@medifirst.fr] Sent: Friday, April 05, 2013 10:38 AM To: Tomcat Users List Subject: Re: Tomcat7 - ajax and connection pool : connection closed despite the use of validationQuery and testOnBorrow .. My configuration : Resource name=jdbc/607 auth=Container type=javax.sql.DataSource username=x password=x driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/X removeAbandoned=true removeAbandonedTimeout=300 testOnBorrow=true validationQuery=SELECT 1 logAbandoned=true / Tomcat 7.0.29 Linux Fedora Core 12 - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat and Window nonpaged pool
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Jeffrey, On 4/5/13 10:27 AM, Jeffrey Janner wrote: Yes, it connects to an Oracle DB, and I strongly suspect they may be seeing a connection pool leak in a little-used bit of code. If you think you have a connection leak, debug that first. Can you not imagine which little-used code might be leaking these connections? Have you run Findbugs or other static analysis tools against your code? They might be able to find the problem relatively quickly. Better yet, write complete-coverage unit tests and then use a connection pool with size=1: you'll find it *very* quickly after that (but if you had those unit tests already, you'd have already found it, of course). I personally very highly recommend that you run with logAbandoned=true and maxActive=1 *always* in development. - -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/ iQIcBAEBCAAGBQJRX4o9AAoJEBzwKT+lPKRYmZMP+wSQuw2BCOxzZetfIfDJXOX8 7tJxNJxXkgZFAW4dpTtywMHA440LOFQPDEhma+ARc611L9N2z/0bWswn+VvtgkEF Qjhjq8b6Ab9dGpI9WjBJv6Qp59MohdYUC7toSc+Xfuho9j4C0nUI2/3Wul8amK+N KtUfl61iqLsj2XsbimQsmoemXL4Kh9mXapeENoMlESHd1FFOOzf+8IrbwCLifLbn Lb9lvXdIF+hmIAIL81jsgDaow5IlPat0vEr0IS4nQbbZOhdhfXVIXxDCg7Y4yqHC BZ0BDf4N8Duif+G3WqAR019TZkMWNCDN+k3TRKhA/2sFfw5pp1NA+2M9/vUHrnik Dw0YoAFfRbMbrCu9bpNXoGA/FM9SUQtPlXZ5M1whWQhhOpKYHNTp+EmBxQsRLXfX xI3s/32IMwCd4+uFRFmh9DXLr0wuzWkP0Hw2Dr65F8pdS16ZPgjwnBLcA3Wrp31V TBoo7kmAV3VVeDtyeNAMDyezmsO197q5Lgr493E8G+lDeLZvYTDwqc9KNw2hcgUW SEi2u+bDR2mxVYXPBhYKM+4/gUQroqtpTh1hElUTaoDNukIZsZ0nNUqlXV54hd8D QRvudINcAQNm7XBZ/eqHGIYXWrel84ie49YC8bMyfk7JwZTGFqpecPh1edo0wQ5Z 1v8aRUSAAcV4dOk2XdYs =7XTT -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org