Re: Tomcat session management with Redisson

2019-02-18 Thread John Dale
This might be what you're looking for:

Unsubscription: Send a blank email to users-unsubscr...@tomcat.apache.org

http://tomcat.apache.org/lists.html


On 2/18/19, Malith Pamuditha Fernando  wrote:
> How to unsubscribe this?
>
> Thank You
>
> Regards
> Malith Pamuditha Fernando
> Director
> RevPort (Pvt.) Ltd.
> malith.ferna...@revport.net  | +94 713 76 92 17
>
>
>
> 
> From: John Dale 
> Sent: Tuesday, February 19, 2019 1:57:10 AM
> To: Tomcat Users List
> Subject: Re: Tomcat session management with Redisson
>
> Regarding clustering and state recovery, I opted some time ago to
> store session information in the database - I prefer full control over
> session state for security/obscurity reasons.
>
> Load balancing is straightforward this way.
>
> I'm not sure I would ever need more than 2 nodes for my purposes,
> though, since Java can address such a huge memory space.  It's an
> amazing computing environment now compared to what we had 20 years
> ago.
>
>
>
> On 2/18/19, Christopher Schultz  wrote:
>> -BEGIN PGP SIGNED MESSAGE-
>> Hash: SHA256
>>
>> Herb,
>>
>> On 2/18/19 13:59, Herb Burnswell wrote:
>>> On Fri, Feb 15, 2019 at 12:21 PM Christopher Schultz <
>>> ch...@christopherschultz.net> wrote:
>>>
>>> Herb,
>>>
>>> On 2/14/19 12:41, Herb Burnswell wrote:
>> Tomcat 8.5.23 RHEL   7.5
>>
>> We are looking to set up session management via Redisson to
>> offload the CPU consumption of using Tomcat's built in
>> clustering session management.  We have CPU licensing limits
>> and need to conserve as much CPU as possible.
>>>
>>> Dumb question: aren't you just going to move the CPU cycles to
>>> another system?
>>>
>>>
 Thanks for the reply.  Short answer, yes.  But that is the idea.
 We can only use 2 CPU's per application node (3 nodes) with our
 licensing structure so we do not want to take cycles away from
 the application to manage sessions.
>>
>> Okay, so if you move the session-management to another machine, you
>> don't have to pay app-license fees for the session-management server?
>> Fair enough.
>>
>> Just remember that you still need code "managing" sessions from your
>> Tomcat note to your Redisson server. I can't imagine that the
>> Tomcat->Resisson code would be any less complicated than the Tomcat ->
>> Tomcat code. You might want to validate that assumption before
>> committing any resources toward solving a problem by adding complexity
>> to your deployments.
>>
>>> Another dumb question: do you actually need clustering?
>>>
>>>
 If I'm using the term correctly, yes.  The idea would be for HA
 functionality; If users were connected to node 3 and the node
 failed for some reason, their session would be picked up by node
 1 or 2 uninterrupted.  Sorry if I confused the intent.
>>
>> That's exactly what you will get.
>>
>> If you do NOT use clustering, a failed node will require the users who
>> were on the failed node to re-login to a surviving node. Only you can
>> determine whether that is an acceptable consequence of a failed node
>> for your users and application. I, as well as many others, have
>> decided that fail-over is such a rare event and logins such a
>> non-issue that introducing the complexity of clustering is not justified
>> .
>>
>> I have never set up a configuration this way, however I have
>> Redis set up and running as 1 Master, 1 Slave.  I seemingly
>> just need to point our application to it.  I have read this
>> doc on how to:
>>
>> https://github.com/redisson/redisson/tree/master/redisson-tomcat
>>
>>
>>
>> It seems pretty straight forward except for the redisson.conf
>> configuration:
>>
>> Add RedissonSessionManager into tomcat/conf/context.xml
>>
>> > className="org.redisson.tomcat.RedissonSessionManager"
>> configPath="${catalina.base}/redisson.conf" readMode="REDIS"
>> updateMode="DEFAULT"/>
>>>
>>> I would do this in the application's context.xml file instead of
>>> the global/default one. That means modifying the application's
>>> META-INF/context.xml file, or, if you deploy via files from
>>> outside your WAR/dir application, then
>>> conf/[engine]/[hostname]/[appname].xml.
>>>
>>>
 Yes, this is requiring the editing a application specific xml
 file.
>>
>> Good.
>>
>> I am more familiar with YAML so plan on configuring the
>> redisson.conf as such.  I have read the referenced
>> configuration wiki page:
>>
>> https://github.com/redisson/redisson/wiki/2.-Configuration
>>
>> However, it has a great deal of options and I'm not sure what
>> is and is not needed.
>>
>> I am reaching out here on the Tomcat user group to see if
>> anyone else is using Redisson for session management and if
>> maybe I can get some guidance on a basic redisson.conf
>> configuration.  I'd also be interested in comments on if
>> there are better options or things 

Re: [OT] Tomcat connection error

2019-02-18 Thread John Dale
Chris,

On 2/18/19, Christopher Schultz  wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
> John,
>
> On 2/18/19 07:45, John Dale wrote:
>> I agree - release your connection, commit transaction (if you have
>> auto-commit set to false), and null-out your connection
>> references.
>>
>> The analogy in c++ is you need deallocate memory.
>
> Deallocation of memory is a bad analogy, here. The better analogy for
> C++ is ... returning a connection to a connection pool in C++. The
> general term for this is "resource management", and it's important in
> every programming language ever.
>
>> Java has GC in Java at a base level, but we also have some
>> resource reclamation at higher levels of abstraction over which GC
>> has no purview.  Pooling (threads, connections) is an example.
>> The connection pool needs to reclaim its connections for
>> reallocation to other threads.  If it can't, the application will
>> hang waiting for connections.
>
> Exactly.
>
>> Do you have a static references to a database connection?
>>
>> The golden rule with database connections is acquire them late and
>> release them early.  I like to create try/catch/finally blocks.
>
> You must use try/catch/finally. Otherwise, you will leak resources.
>
>> In the finally block, which executes even if there is an
>> exception, I commit the transaction and set connection reference to
>> null.
>
> Compilers and static analyzers will often give you dead-store warnings
> for null values, but I disagree with them that dead-stores are *bad*.
> If you add code to the end of the method which makes the dead-store
> into a LIVE-store, but the resource (e.g. ResultSet) shouldn't be used
> anymore, it becomes a bug. An NPE is better than a use-after-free
> (which isn't really a thing in Java like in other languages, but
> practically it can have a similar effect).
>
> I wouldn't always commit the transaction in the finally block. That
> can be wasteful at best and incorrect at worst. You commit should
> (usually) only occur if no exceptions are encountered. All other
> situations (usually) require a rollback.

There are some cases where the logic is more nuanced where I commit
the transaction inside the try.  For 99% of the cases in my code, the
commit should come at the end of the try block, where the next line of
execution is the first line of the finally block anyway.  I do this
for consistency and readability, but your point is well taken.  FWIW,
rollbacks occur in the catch block as required.  As an engineering
artist, this is kind of my signature, I suppose.  I'm sure there are
cases that I will encounter that will require some transactional
gymnastics.  I love Java IS middleware coding with Tomcat.  I feel
like there is no challenge too great to accommodate.

>
>> As a matter of course, I would null out and close references to
>> PreparedStatements and ResultSets as well (especially ResultSets).
>
> This is 100% required for some drivers. The JDBC spec explicitly
> allows for drivers to leak these resources if you do not clean them up
> properly... especially if you are using pooled-connections (which IS
> the case, here). I have seen some drivers (MySQL) which seem to
> clean-up the mess and others (Oracle) which can cause problems not
> only on the client, but also on the server ("Too many open cursors").

I've developed some patterns that make this easy for the coding that
I'm doing including asking a Connection wrapper class for a
PreparedStatement and passing in a SQL statement.  Then, the
connection wrapper registers the PS.  After processing, when calling
cleanup() I commit if necessary, and all PS's are closed accordingly.
I handle ResultSets similarly by calling a function to register the RS
with the connection, which handles the RS's on cleanup() as well.
rollback() functions as expected in this context.  Thanks for the
comments.

>
> - -chris
> -BEGIN PGP SIGNATURE-
> Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
>
> iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlxrCWQACgkQHPApP6U8
> pFhnOhAAvZeMADzrIz3x28CZjjBE2Hw2xEc9pEIeBaJVUTsPkjIHDQdTWNruxasz
> NkW8T6hXkHRexoEqq6aLTrjtlaQmOawjvdvDzkF0+b7BvrUSBjAmpB4ai02FSZ/Y
> vBvDXFgqthHxPYL9ykP3LlTaV2a4g+noDkVj862++AFhsVzEwZzW3cuQsegwoRs2
> pmEFIH9ZxGeD3OM5+2TdzUTdTGyc49OcmmI0UzKRFF1iZxmhBuuBDijvdW0OA+2K
> WVq+RhCeqKclAGXOV9OIBSTewQaLVL5fgujlJxRDG7xW3oBsnfOc0SzipDMkXXsy
> QpZQGzbx8XnaeEnFE7m5gqL0bxnen31pcrF3NigCPw75rOHbOTxO2pSvlRpSK6xq
> WV8Wieytwq0Bc691TnmAibmx5wVMjqiFlXLmzd3wNlVMxHf9NmxmoWNfzqX03YZs
> 44tj/tko5ukOJcI8oyhDeVKuGA8T57gU0qHl/aAgxunBmCSJiizoPc/8UcR577jj
> ZLSrG1Fk/SXa1opzDZyOZbiG8apZX5V3oWmfcmyoLTIq0I46waTDBd3MohWmAm9t
> stp0oLlCgmv9ydJK7VptiTXcTBYjfFn5sMEmcBx6Mp+Z3GexaX9gZx5dGNPFMa8v
> 3LboKGJ27V4mc60g8yUd+4MiK+09xlQcbsILIhCH2mcWy+YOkdo=
> =Df7E
> -END PGP SIGNATURE-
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail:

Re: Tomcat session management with Redisson

2019-02-18 Thread Malith Pamuditha Fernando
How to unsubscribe this?

Thank You

Regards
Malith Pamuditha Fernando
Director
RevPort (Pvt.) Ltd.
malith.ferna...@revport.net  | +94 713 76 92 17




From: John Dale 
Sent: Tuesday, February 19, 2019 1:57:10 AM
To: Tomcat Users List
Subject: Re: Tomcat session management with Redisson

Regarding clustering and state recovery, I opted some time ago to
store session information in the database - I prefer full control over
session state for security/obscurity reasons.

Load balancing is straightforward this way.

I'm not sure I would ever need more than 2 nodes for my purposes,
though, since Java can address such a huge memory space.  It's an
amazing computing environment now compared to what we had 20 years
ago.



On 2/18/19, Christopher Schultz  wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
> Herb,
>
> On 2/18/19 13:59, Herb Burnswell wrote:
>> On Fri, Feb 15, 2019 at 12:21 PM Christopher Schultz <
>> ch...@christopherschultz.net> wrote:
>>
>> Herb,
>>
>> On 2/14/19 12:41, Herb Burnswell wrote:
> Tomcat 8.5.23 RHEL   7.5
>
> We are looking to set up session management via Redisson to
> offload the CPU consumption of using Tomcat's built in
> clustering session management.  We have CPU licensing limits
> and need to conserve as much CPU as possible.
>>
>> Dumb question: aren't you just going to move the CPU cycles to
>> another system?
>>
>>
>>> Thanks for the reply.  Short answer, yes.  But that is the idea.
>>> We can only use 2 CPU's per application node (3 nodes) with our
>>> licensing structure so we do not want to take cycles away from
>>> the application to manage sessions.
>
> Okay, so if you move the session-management to another machine, you
> don't have to pay app-license fees for the session-management server?
> Fair enough.
>
> Just remember that you still need code "managing" sessions from your
> Tomcat note to your Redisson server. I can't imagine that the
> Tomcat->Resisson code would be any less complicated than the Tomcat ->
> Tomcat code. You might want to validate that assumption before
> committing any resources toward solving a problem by adding complexity
> to your deployments.
>
>> Another dumb question: do you actually need clustering?
>>
>>
>>> If I'm using the term correctly, yes.  The idea would be for HA
>>> functionality; If users were connected to node 3 and the node
>>> failed for some reason, their session would be picked up by node
>>> 1 or 2 uninterrupted.  Sorry if I confused the intent.
>
> That's exactly what you will get.
>
> If you do NOT use clustering, a failed node will require the users who
> were on the failed node to re-login to a surviving node. Only you can
> determine whether that is an acceptable consequence of a failed node
> for your users and application. I, as well as many others, have
> decided that fail-over is such a rare event and logins such a
> non-issue that introducing the complexity of clustering is not justified
> .
>
> I have never set up a configuration this way, however I have
> Redis set up and running as 1 Master, 1 Slave.  I seemingly
> just need to point our application to it.  I have read this
> doc on how to:
>
> https://github.com/redisson/redisson/tree/master/redisson-tomcat
>
>
>
> It seems pretty straight forward except for the redisson.conf
> configuration:
>
> Add RedissonSessionManager into tomcat/conf/context.xml
>
>  className="org.redisson.tomcat.RedissonSessionManager"
> configPath="${catalina.base}/redisson.conf" readMode="REDIS"
> updateMode="DEFAULT"/>
>>
>> I would do this in the application's context.xml file instead of
>> the global/default one. That means modifying the application's
>> META-INF/context.xml file, or, if you deploy via files from
>> outside your WAR/dir application, then
>> conf/[engine]/[hostname]/[appname].xml.
>>
>>
>>> Yes, this is requiring the editing a application specific xml
>>> file.
>
> Good.
>
> I am more familiar with YAML so plan on configuring the
> redisson.conf as such.  I have read the referenced
> configuration wiki page:
>
> https://github.com/redisson/redisson/wiki/2.-Configuration
>
> However, it has a great deal of options and I'm not sure what
> is and is not needed.
>
> I am reaching out here on the Tomcat user group to see if
> anyone else is using Redisson for session management and if
> maybe I can get some guidance on a basic redisson.conf
> configuration.  I'd also be interested in comments on if
> there are better options or things to watch out for.
>>
>> I don't have any experience with either Redis or Redisson, but what
>> is wrong with the default/sample configuration you have provided
>> above?
>>
>>
>>> I have through much trial and error been using this config:
>>
>>> { "masterSlaveServersConfig":{ "idleConnectionTimeout":1,
>>> "connectTimeout":1, "timeout":3000, "

Re: Tomcat session management with Redisson

2019-02-18 Thread John Dale
Regarding clustering and state recovery, I opted some time ago to
store session information in the database - I prefer full control over
session state for security/obscurity reasons.

Load balancing is straightforward this way.

I'm not sure I would ever need more than 2 nodes for my purposes,
though, since Java can address such a huge memory space.  It's an
amazing computing environment now compared to what we had 20 years
ago.



On 2/18/19, Christopher Schultz  wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
> Herb,
>
> On 2/18/19 13:59, Herb Burnswell wrote:
>> On Fri, Feb 15, 2019 at 12:21 PM Christopher Schultz <
>> ch...@christopherschultz.net> wrote:
>>
>> Herb,
>>
>> On 2/14/19 12:41, Herb Burnswell wrote:
> Tomcat 8.5.23 RHEL   7.5
>
> We are looking to set up session management via Redisson to
> offload the CPU consumption of using Tomcat's built in
> clustering session management.  We have CPU licensing limits
> and need to conserve as much CPU as possible.
>>
>> Dumb question: aren't you just going to move the CPU cycles to
>> another system?
>>
>>
>>> Thanks for the reply.  Short answer, yes.  But that is the idea.
>>> We can only use 2 CPU's per application node (3 nodes) with our
>>> licensing structure so we do not want to take cycles away from
>>> the application to manage sessions.
>
> Okay, so if you move the session-management to another machine, you
> don't have to pay app-license fees for the session-management server?
> Fair enough.
>
> Just remember that you still need code "managing" sessions from your
> Tomcat note to your Redisson server. I can't imagine that the
> Tomcat->Resisson code would be any less complicated than the Tomcat ->
> Tomcat code. You might want to validate that assumption before
> committing any resources toward solving a problem by adding complexity
> to your deployments.
>
>> Another dumb question: do you actually need clustering?
>>
>>
>>> If I'm using the term correctly, yes.  The idea would be for HA
>>> functionality; If users were connected to node 3 and the node
>>> failed for some reason, their session would be picked up by node
>>> 1 or 2 uninterrupted.  Sorry if I confused the intent.
>
> That's exactly what you will get.
>
> If you do NOT use clustering, a failed node will require the users who
> were on the failed node to re-login to a surviving node. Only you can
> determine whether that is an acceptable consequence of a failed node
> for your users and application. I, as well as many others, have
> decided that fail-over is such a rare event and logins such a
> non-issue that introducing the complexity of clustering is not justified
> .
>
> I have never set up a configuration this way, however I have
> Redis set up and running as 1 Master, 1 Slave.  I seemingly
> just need to point our application to it.  I have read this
> doc on how to:
>
> https://github.com/redisson/redisson/tree/master/redisson-tomcat
>
>
>
> It seems pretty straight forward except for the redisson.conf
> configuration:
>
> Add RedissonSessionManager into tomcat/conf/context.xml
>
>  className="org.redisson.tomcat.RedissonSessionManager"
> configPath="${catalina.base}/redisson.conf" readMode="REDIS"
> updateMode="DEFAULT"/>
>>
>> I would do this in the application's context.xml file instead of
>> the global/default one. That means modifying the application's
>> META-INF/context.xml file, or, if you deploy via files from
>> outside your WAR/dir application, then
>> conf/[engine]/[hostname]/[appname].xml.
>>
>>
>>> Yes, this is requiring the editing a application specific xml
>>> file.
>
> Good.
>
> I am more familiar with YAML so plan on configuring the
> redisson.conf as such.  I have read the referenced
> configuration wiki page:
>
> https://github.com/redisson/redisson/wiki/2.-Configuration
>
> However, it has a great deal of options and I'm not sure what
> is and is not needed.
>
> I am reaching out here on the Tomcat user group to see if
> anyone else is using Redisson for session management and if
> maybe I can get some guidance on a basic redisson.conf
> configuration.  I'd also be interested in comments on if
> there are better options or things to watch out for.
>>
>> I don't have any experience with either Redis or Redisson, but what
>> is wrong with the default/sample configuration you have provided
>> above?
>>
>>
>>> I have through much trial and error been using this config:
>>
>>> { "masterSlaveServersConfig":{ "idleConnectionTimeout":1,
>>> "connectTimeout":1, "timeout":3000, "retryAttempts":3,
>>> "retryInterval":1500, "failedSlaveReconnectionInterval":3000,
>>> "failedSlaveCheckInterval":6, "password":"",
>>> "subscriptionsPerConnection":5, "clientName":true,
>>> "subscriptionConnectionMinimumIdleSize":1,
>>> "subscriptionConnectionPoolSize":50,
>>> "slaveConnectionMinimumIdleSize":32,

Re: [OT] Tomcat connection error

2019-02-18 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

John,

On 2/18/19 07:45, John Dale wrote:
> I agree - release your connection, commit transaction (if you have 
> auto-commit set to false), and null-out your connection
> references.
> 
> The analogy in c++ is you need deallocate memory.

Deallocation of memory is a bad analogy, here. The better analogy for
C++ is ... returning a connection to a connection pool in C++. The
general term for this is "resource management", and it's important in
every programming language ever.

> Java has GC in Java at a base level, but we also have some
> resource reclamation at higher levels of abstraction over which GC
> has no purview.  Pooling (threads, connections) is an example.
> The connection pool needs to reclaim its connections for
> reallocation to other threads.  If it can't, the application will
> hang waiting for connections.

Exactly.

> Do you have a static references to a database connection?
> 
> The golden rule with database connections is acquire them late and 
> release them early.  I like to create try/catch/finally blocks.

You must use try/catch/finally. Otherwise, you will leak resources.

> In the finally block, which executes even if there is an
> exception, I commit the transaction and set connection reference to
> null.

Compilers and static analyzers will often give you dead-store warnings
for null values, but I disagree with them that dead-stores are *bad*.
If you add code to the end of the method which makes the dead-store
into a LIVE-store, but the resource (e.g. ResultSet) shouldn't be used
anymore, it becomes a bug. An NPE is better than a use-after-free
(which isn't really a thing in Java like in other languages, but
practically it can have a similar effect).

I wouldn't always commit the transaction in the finally block. That
can be wasteful at best and incorrect at worst. You commit should
(usually) only occur if no exceptions are encountered. All other
situations (usually) require a rollback.

> As a matter of course, I would null out and close references to 
> PreparedStatements and ResultSets as well (especially ResultSets).

This is 100% required for some drivers. The JDBC spec explicitly
allows for drivers to leak these resources if you do not clean them up
properly... especially if you are using pooled-connections (which IS
the case, here). I have seen some drivers (MySQL) which seem to
clean-up the mess and others (Oracle) which can cause problems not
only on the client, but also on the server ("Too many open cursors").

- -chris
-BEGIN PGP SIGNATURE-
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlxrCWQACgkQHPApP6U8
pFhnOhAAvZeMADzrIz3x28CZjjBE2Hw2xEc9pEIeBaJVUTsPkjIHDQdTWNruxasz
NkW8T6hXkHRexoEqq6aLTrjtlaQmOawjvdvDzkF0+b7BvrUSBjAmpB4ai02FSZ/Y
vBvDXFgqthHxPYL9ykP3LlTaV2a4g+noDkVj862++AFhsVzEwZzW3cuQsegwoRs2
pmEFIH9ZxGeD3OM5+2TdzUTdTGyc49OcmmI0UzKRFF1iZxmhBuuBDijvdW0OA+2K
WVq+RhCeqKclAGXOV9OIBSTewQaLVL5fgujlJxRDG7xW3oBsnfOc0SzipDMkXXsy
QpZQGzbx8XnaeEnFE7m5gqL0bxnen31pcrF3NigCPw75rOHbOTxO2pSvlRpSK6xq
WV8Wieytwq0Bc691TnmAibmx5wVMjqiFlXLmzd3wNlVMxHf9NmxmoWNfzqX03YZs
44tj/tko5ukOJcI8oyhDeVKuGA8T57gU0qHl/aAgxunBmCSJiizoPc/8UcR577jj
ZLSrG1Fk/SXa1opzDZyOZbiG8apZX5V3oWmfcmyoLTIq0I46waTDBd3MohWmAm9t
stp0oLlCgmv9ydJK7VptiTXcTBYjfFn5sMEmcBx6Mp+Z3GexaX9gZx5dGNPFMa8v
3LboKGJ27V4mc60g8yUd+4MiK+09xlQcbsILIhCH2mcWy+YOkdo=
=Df7E
-END PGP SIGNATURE-

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



Re: Tomcat connection error

2019-02-18 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Faisal,

On 2/18/19 00:32, fai...@bestercapitalmedia.com wrote:
> Dear all,
> 
> 
> 
> I am working on a project and I am facing following issue on almost
> every second day. I need to restart tomcat to get it running
> again.
> 
> Can someone guide me on it. Ask if you need some other insight to
> look into it.
> 
> 
> 
> 2019-02-18 04:49:35.572  WARN 20698 --- [io-4200-exec-15] 
> o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 0, SQLState:
> null
> 
> 2019-02-18 04:49:35.572 ERROR 20698 --- [io-4200-exec-15] 
> o.h.engine.jdbc.spi.SqlExceptionHelper   : HikariPool-1 -
> Connection is not available, request timed out after 3ms.
> 
> 2019-02-18 04:49:35.573  WARN 20698 --- [io-4200-exec-15] 
> o.s.s.o.provider.endpoint.TokenEndpoint  : Handling error: 
> InternalAuthenticationServiceException, Unable to acquire JDBC
> Connection; nested exception is
> org.hibernate.exception.JDBCConnectionException: Unable to acquire
> JDBC Connection
> 
> 
> 
> Server is Ubuntu (aws)
> 
> Database is mySql
> 
> java version "1.8.0_181"
> 
> Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
> 
> Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

My guess is that you have a connection leak in your code.

Might I suggest reading this?

https://blog.christopherschultz.net/index.php/2009/03/16/properly-handli
ng-pooled-jdbc-connections/

- -chris
-BEGIN PGP SIGNATURE-
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlxrB3MACgkQHPApP6U8
pFjUNQ/8C5NP0GXYusuOZi2RO1qzOh+SlmdjqAUK9L7fE219XdoXRHdgBPzTr2tK
BdW5n/l3ypZ4J9UPmXZlAfkuF775lahi5iiCdFLUCJUaBcYVn22z8i/jgcGXUWwS
BZq9i12Av0qRgiEZTs8UC28f+yBjHs3SXo/WxsdbuE159Wdo6kxqqSpUsebjAa5z
gWurE7fxDiyiXOak5Zb7Puay2X1Zxg9vTugDFqZXqpNVxyzFGkkaHWYg/TpUphmW
JHB0ucPRK0MIOsdov3onceTfwMF2/HuBJv3GGKSvggleDRYbeRoMOgGas3YipX+j
/lz+wrxhIDAZqBHoGWSJFytkkinLECHZEtubxbZG1HkU4+ntasoXvj4LkE/cARya
Z1YYKydgHHAk8AMVbBRUwW2Xw2lULXzEY26Y8gKezoL7V/yU7ASPeNujgoMxPzEx
wg3PjShAQf1ajsRWC0QylYNelFEzjclnZI/4VQ7GIJan1FOmHNP44wKgeBxmVtA4
C8X3LV7TObBZYGCD59CRE107BUudLF5003keGjixxODc4ygTuhBuQbaPBLt3y+Yb
tIsnilVYQM0jHeOOtXoQZWmEjhcpCxB8Otrke3mYGmmo+398quLoLJuzdOuGCwrF
Ggl8ed7pv2uR+8DPst0TIn793opcjXRZ1W7ALRD9aTudX8XsnRA=
=T7C6
-END PGP SIGNATURE-

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



Re: Tomcat session management with Redisson

2019-02-18 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Herb,

On 2/18/19 13:59, Herb Burnswell wrote:
> On Fri, Feb 15, 2019 at 12:21 PM Christopher Schultz < 
> ch...@christopherschultz.net> wrote:
> 
> Herb,
> 
> On 2/14/19 12:41, Herb Burnswell wrote:
 Tomcat 8.5.23 RHEL   7.5
 
 We are looking to set up session management via Redisson to
 offload the CPU consumption of using Tomcat's built in
 clustering session management.  We have CPU licensing limits
 and need to conserve as much CPU as possible.
> 
> Dumb question: aren't you just going to move the CPU cycles to
> another system?
> 
> 
>> Thanks for the reply.  Short answer, yes.  But that is the idea.
>> We can only use 2 CPU's per application node (3 nodes) with our
>> licensing structure so we do not want to take cycles away from
>> the application to manage sessions.

Okay, so if you move the session-management to another machine, you
don't have to pay app-license fees for the session-management server?
Fair enough.

Just remember that you still need code "managing" sessions from your
Tomcat note to your Redisson server. I can't imagine that the
Tomcat->Resisson code would be any less complicated than the Tomcat ->
Tomcat code. You might want to validate that assumption before
committing any resources toward solving a problem by adding complexity
to your deployments.

> Another dumb question: do you actually need clustering?
> 
> 
>> If I'm using the term correctly, yes.  The idea would be for HA 
>> functionality; If users were connected to node 3 and the node
>> failed for some reason, their session would be picked up by node
>> 1 or 2 uninterrupted.  Sorry if I confused the intent.

That's exactly what you will get.

If you do NOT use clustering, a failed node will require the users who
were on the failed node to re-login to a surviving node. Only you can
determine whether that is an acceptable consequence of a failed node
for your users and application. I, as well as many others, have
decided that fail-over is such a rare event and logins such a
non-issue that introducing the complexity of clustering is not justified
.

 I have never set up a configuration this way, however I have
 Redis set up and running as 1 Master, 1 Slave.  I seemingly
 just need to point our application to it.  I have read this
 doc on how to:
 
 https://github.com/redisson/redisson/tree/master/redisson-tomcat


 
It seems pretty straight forward except for the redisson.conf
 configuration:
 
 Add RedissonSessionManager into tomcat/conf/context.xml
 
 >>> className="org.redisson.tomcat.RedissonSessionManager" 
 configPath="${catalina.base}/redisson.conf" readMode="REDIS" 
 updateMode="DEFAULT"/>
> 
> I would do this in the application's context.xml file instead of
> the global/default one. That means modifying the application's 
> META-INF/context.xml file, or, if you deploy via files from
> outside your WAR/dir application, then
> conf/[engine]/[hostname]/[appname].xml.
> 
> 
>> Yes, this is requiring the editing a application specific xml
>> file.

Good.

 I am more familiar with YAML so plan on configuring the 
 redisson.conf as such.  I have read the referenced
 configuration wiki page:
 
 https://github.com/redisson/redisson/wiki/2.-Configuration
 
 However, it has a great deal of options and I'm not sure what
 is and is not needed.
 
 I am reaching out here on the Tomcat user group to see if
 anyone else is using Redisson for session management and if
 maybe I can get some guidance on a basic redisson.conf
 configuration.  I'd also be interested in comments on if
 there are better options or things to watch out for.
> 
> I don't have any experience with either Redis or Redisson, but what
> is wrong with the default/sample configuration you have provided
> above?
> 
> 
>> I have through much trial and error been using this config:
> 
>> { "masterSlaveServersConfig":{ "idleConnectionTimeout":1, 
>> "connectTimeout":1, "timeout":3000, "retryAttempts":3, 
>> "retryInterval":1500, "failedSlaveReconnectionInterval":3000, 
>> "failedSlaveCheckInterval":6, "password":"", 
>> "subscriptionsPerConnection":5, "clientName":true, 
>> "subscriptionConnectionMinimumIdleSize":1, 
>> "subscriptionConnectionPoolSize":50, 
>> "slaveConnectionMinimumIdleSize":32, 
>> "slaveConnectionPoolSize":64, 
>> "masterConnectionMinimumIdleSize":32, 
>> "masterConnectionPoolSize":64, "readMode":"SLAVE", 
>> "subscriptionMode":"SLAVE", "slaveAddresses":[ 
>> "> "masterAddress":":6379", "database":0 }, 
>> "threads":0, "nettyThreads":0, "transportMode":"NIO" }
> 
>> However, I am getting a couple exceptions and am not sure what
>> might be the issue:

Okay, let's take a look:

>> INFO   | jvm 1| main| 2019/02/18 10:09:33.068 | Feb 18,
>> 2019 10:09:33 AM org.apache.catalina.core.StandardContext
>> startInternal INFO   | jvm 1| main|

Re: Tomcat session management with Redisson

2019-02-18 Thread Harpreet Sandhu
If you want to go with redis in HA environment. You should opt redis
sentinel over master-slave architecture.

On Tue 19 Feb, 2019, 12:29 AM Herb Burnswell  On Fri, Feb 15, 2019 at 12:21 PM Christopher Schultz <
> ch...@christopherschultz.net> wrote:
>
> > -BEGIN PGP SIGNED MESSAGE-
> > Hash: SHA256
> >
> > Herb,
> >
> > On 2/14/19 12:41, Herb Burnswell wrote:
> > > Tomcat 8.5.23 RHEL   7.5
> > >
> > > We are looking to set up session management via Redisson to offload
> > > the CPU consumption of using Tomcat's built in clustering session
> > > management.  We have CPU licensing limits and need to conserve as
> > > much CPU as possible.
> >
> > Dumb question: aren't you just going to move the CPU cycles to another
> > system?
> >
>
> Thanks for the reply.  Short answer, yes.  But that is the idea.  We can
> only use 2 CPU's per application node (3 nodes) with our licensing
> structure so we do not want to take cycles away from the application to
> manage sessions.
>
>
> > Another dumb question: do you actually need clustering?
> >
>
> If I'm using the term correctly, yes.  The idea would be for HA
> functionality; If users were connected to node 3 and the node failed for
> some reason, their session would be picked up by node 1 or 2
> uninterrupted.  Sorry if I confused the intent.
>
>
> >
> > > I have never set up a configuration this way, however I have Redis
> > > set up and running as 1 Master, 1 Slave.  I seemingly just need to
> > > point our application to it.  I have read this doc on how to:
> > >
> > > https://github.com/redisson/redisson/tree/master/redisson-tomcat
> > >
> > > It seems pretty straight forward except for the redisson.conf
> > > configuration:
> > >
> > > Add RedissonSessionManager into tomcat/conf/context.xml
> > >
> > >  > > configPath="${catalina.base}/redisson.conf" readMode="REDIS"
> > > updateMode="DEFAULT"/>
> >
> > I would do this in the application's context.xml file instead of the
> > global/default one. That means modifying the application's
> > META-INF/context.xml file, or, if you deploy via files from outside
> > your WAR/dir application, then conf/[engine]/[hostname]/[appname].xml.
> >
>
> Yes, this is requiring the editing a application specific xml file.
>
>
> >
> > > I am more familiar with YAML so plan on configuring the
> > > redisson.conf as such.  I have read the referenced configuration
> > > wiki page:
> > >
> > > https://github.com/redisson/redisson/wiki/2.-Configuration
> > >
> > > However, it has a great deal of options and I'm not sure what is
> > > and is not needed.
> > >
> > > I am reaching out here on the Tomcat user group to see if anyone
> > > else is using Redisson for session management and if maybe I can
> > > get some guidance on a basic redisson.conf configuration.  I'd also
> > > be interested in comments on if there are better options or things
> > > to watch out for.
> >
> > I don't have any experience with either Redis or Redisson, but what is
> > wrong with the default/sample configuration you have provided above?
> >
>
> I have through much trial and error been using this config:
>
> {
>"masterSlaveServersConfig":{
>   "idleConnectionTimeout":1,
>   "connectTimeout":1,
>   "timeout":3000,
>   "retryAttempts":3,
>   "retryInterval":1500,
>   "failedSlaveReconnectionInterval":3000,
>   "failedSlaveCheckInterval":6,
>   "password":"",
>   "subscriptionsPerConnection":5,
>   "clientName":true,
>   "subscriptionConnectionMinimumIdleSize":1,
>   "subscriptionConnectionPoolSize":50,
>   "slaveConnectionMinimumIdleSize":32,
>   "slaveConnectionPoolSize":64,
>   "masterConnectionMinimumIdleSize":32,
>   "masterConnectionPoolSize":64,
>   "readMode":"SLAVE",
>   "subscriptionMode":"SLAVE",
>   "slaveAddresses":[
>  "   ],
>   "masterAddress":":6379",
>   "database":0
>},
>"threads":0,
>"nettyThreads":0,
>"transportMode":"NIO"
> }
>
> However, I am getting a couple exceptions and am not sure what might be the
> issue:
>
> INFO   | jvm 1| main| 2019/02/18 10:09:33.068 | Feb 18, 2019
> 10:09:33 AM org.apache.catalina.core.StandardContext startInternal
> INFO   | jvm 1| main| 2019/02/18 10:09:33.068 | SEVERE: The session
> manager failed to start
> INFO   | jvm 1| main| 2019/02/18 10:09:33.068 |
> org.apache.catalina.LifecycleException: Failed to start component
> [org.redisson.tomcat.RedissonSessionManager[]]
> INFO   | jvm 1| main| 2019/02/18 10:09:33.068 | at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
> INFO   | jvm 1| main| 2019/02/18 10:09:33.068 | at
>
> org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5224)
> INFO   | jvm 1| main| 2019/02/18 10:09:33.068 | at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
> INFO   | jvm 1| main| 2019/02/18 10:09:33.068 |

Re: Tomcat session management with Redisson

2019-02-18 Thread Herb Burnswell
On Fri, Feb 15, 2019 at 12:21 PM Christopher Schultz <
ch...@christopherschultz.net> wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
> Herb,
>
> On 2/14/19 12:41, Herb Burnswell wrote:
> > Tomcat 8.5.23 RHEL   7.5
> >
> > We are looking to set up session management via Redisson to offload
> > the CPU consumption of using Tomcat's built in clustering session
> > management.  We have CPU licensing limits and need to conserve as
> > much CPU as possible.
>
> Dumb question: aren't you just going to move the CPU cycles to another
> system?
>

Thanks for the reply.  Short answer, yes.  But that is the idea.  We can
only use 2 CPU's per application node (3 nodes) with our licensing
structure so we do not want to take cycles away from the application to
manage sessions.


> Another dumb question: do you actually need clustering?
>

If I'm using the term correctly, yes.  The idea would be for HA
functionality; If users were connected to node 3 and the node failed for
some reason, their session would be picked up by node 1 or 2
uninterrupted.  Sorry if I confused the intent.


>
> > I have never set up a configuration this way, however I have Redis
> > set up and running as 1 Master, 1 Slave.  I seemingly just need to
> > point our application to it.  I have read this doc on how to:
> >
> > https://github.com/redisson/redisson/tree/master/redisson-tomcat
> >
> > It seems pretty straight forward except for the redisson.conf
> > configuration:
> >
> > Add RedissonSessionManager into tomcat/conf/context.xml
> >
> >  > configPath="${catalina.base}/redisson.conf" readMode="REDIS"
> > updateMode="DEFAULT"/>
>
> I would do this in the application's context.xml file instead of the
> global/default one. That means modifying the application's
> META-INF/context.xml file, or, if you deploy via files from outside
> your WAR/dir application, then conf/[engine]/[hostname]/[appname].xml.
>

Yes, this is requiring the editing a application specific xml file.


>
> > I am more familiar with YAML so plan on configuring the
> > redisson.conf as such.  I have read the referenced configuration
> > wiki page:
> >
> > https://github.com/redisson/redisson/wiki/2.-Configuration
> >
> > However, it has a great deal of options and I'm not sure what is
> > and is not needed.
> >
> > I am reaching out here on the Tomcat user group to see if anyone
> > else is using Redisson for session management and if maybe I can
> > get some guidance on a basic redisson.conf configuration.  I'd also
> > be interested in comments on if there are better options or things
> > to watch out for.
>
> I don't have any experience with either Redis or Redisson, but what is
> wrong with the default/sample configuration you have provided above?
>

I have through much trial and error been using this config:

{
   "masterSlaveServersConfig":{
  "idleConnectionTimeout":1,
  "connectTimeout":1,
  "timeout":3000,
  "retryAttempts":3,
  "retryInterval":1500,
  "failedSlaveReconnectionInterval":3000,
  "failedSlaveCheckInterval":6,
  "password":"",
  "subscriptionsPerConnection":5,
  "clientName":true,
  "subscriptionConnectionMinimumIdleSize":1,
  "subscriptionConnectionPoolSize":50,
  "slaveConnectionMinimumIdleSize":32,
  "slaveConnectionPoolSize":64,
  "masterConnectionMinimumIdleSize":32,
  "masterConnectionPoolSize":64,
  "readMode":"SLAVE",
  "subscriptionMode":"SLAVE",
  "slaveAddresses":[
 ":6379",
  "database":0
   },
   "threads":0,
   "nettyThreads":0,
   "transportMode":"NIO"
}

However, I am getting a couple exceptions and am not sure what might be the
issue:

INFO   | jvm 1| main| 2019/02/18 10:09:33.068 | Feb 18, 2019
10:09:33 AM org.apache.catalina.core.StandardContext startInternal
INFO   | jvm 1| main| 2019/02/18 10:09:33.068 | SEVERE: The session
manager failed to start
INFO   | jvm 1| main| 2019/02/18 10:09:33.068 |
org.apache.catalina.LifecycleException: Failed to start component
[org.redisson.tomcat.RedissonSessionManager[]]
INFO   | jvm 1| main| 2019/02/18 10:09:33.068 | at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
INFO   | jvm 1| main| 2019/02/18 10:09:33.068 | at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5224)
INFO   | jvm 1| main| 2019/02/18 10:09:33.068 | at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
INFO   | jvm 1| main| 2019/02/18 10:09:33.068 | at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
INFO   | jvm 1| main| 2019/02/18 10:09:33.068 | at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
INFO   | jvm 1| main| 2019/02/18 10:09:33.068 | at
java.util.concurrent.FutureTask.run(FutureTask.java:266)
INFO   | jvm 1| main| 2019/02/18 10:09:33.068 | at
java

Re: Tomcat connection error

2019-02-18 Thread John Dale
Greetings;

If you can, send some code that uses the connection.  From that I
think we can rule out an improperly handled connection.  There are a
few patterns to look for in connection handling that can cause this
type of issue.

I had a case once where I opened two connections and only closed one
of them .. it took a day or two for my connection pool to start timing
out.

Something like this seems like it will be in the Java code.

Have a super day,

John


On 2/18/19, fai...@bestercapitalmedia.com  wrote:
> Hi John,
>
> I am working in spring boot (maven) project.
> I am not doing exclusive null-out of the connection feeling that spring boot
> will manage it, do I still need to manage it myself?
> If you want I can list the dependencies here.
>
> I have just added the following dependency but didn’t try yet on production
> server.
>   
>   com.zaxxer
>   HikariCP
>   2.7.8
>   compile
>   
>
> Regards,
> Faisal Zaidi
>
> -Original Message-
> From: John Dale [mailto:jcdw...@gmail.com]
> Sent: Monday, February 18, 2019 5:45 PM
> To: Tomcat Users List
> Subject: Re: Tomcat connection error
>
> I agree - release your connection, commit transaction (if you have
> auto-commit set to false), and null-out your connection references.
>
> The analogy in c++ is you need deallocate memory.
>
> Java has GC in Java at a base level, but we also have some resource
> reclamation at higher levels of abstraction over which GC has no purview.
> Pooling (threads, connections) is an example.  The connection pool needs to
> reclaim its connections for reallocation to other threads.  If it can't, the
> application will hang waiting for connections.
>
> Do you have a static references to a database connection?
>
> The golden rule with database connections is acquire them late and release
> them early.  I like to create try/catch/finally blocks.  In the finally
> block, which executes even if there is an exception, I commit the
> transaction and set connection reference to null.
>
> As a matter of course, I would null out and close references to
> PreparedStatements and ResultSets as well (especially ResultSets).
>
> I'm sure you'll figure it out.
>
> Sincerely,
>
> John
>
>
> On 2/18/19, Mark Thomas  wrote:
>> On 18/02/2019 10:24, fai...@bestercapitalmedia.com wrote:
>>> Hi Ted,
>>>
>>> Yes, you are right.
>>> I just need to restart the tomcat to get back it on.
>>> There is no need to restart the mySql in my case.
>>>
>>> Any clue please.
>>
>> Sounds like a connection leak in the web application. I expect the
>> connection pool includes tools to help you track that sort of problem
>> down.
>>
>> Mark
>>
>>
>>>
>>> Faisal Zaidi
>>>
>>> -Original Message-
>>> From: Ted Spradley [mailto:ted.k.sprad...@gmail.com]
>>> Sent: Monday, February 18, 2019 1:52 PM
>>> To: Tomcat Users List
>>> Subject: Re: Tomcat connection error
>>>
>>> Hi Faisal,
>>>
>>> Your application(s) run as expected for a while, then you get the SQL
>>> Connection error? Then the only way to “fix it” is to restart Tomcat?
>>> At the same time are you also restarting MySQL?
>>>
>>> Thanks,
>>> Ted
>>>
 On Feb 18, 2019, at 02:17, Luis Rodríguez Fernández
 
 wrote:

 Hello Faisal,

 It looks like your problem is more related with your hikari
 connection pool than with tomcat itself. I would recommend you to
 double check your hikari configuration properties. Pay specially
 attention on how you are configuring your connection pool (minimum
 and maximum size, timeout,
 etc...) It looks like there is "something" in your application that
 prevents to get connections from your pool.

 Hope it helps,

 Luis






> El lun., 18 feb. 2019 a las 6:33, 
> escribió:
>
> Dear all,
>
>
>
> I am working on a project and I am facing following issue on almost
> every second day. I need to restart tomcat to get it running again.
>
> Can someone guide me on it. Ask if you need some other insight to
> look into it.
>
>
>
> 2019-02-18 04:49:35.572  WARN 20698 --- [io-4200-exec-15]
> o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 0, SQLState:
> null
>
> 2019-02-18 04:49:35.572 ERROR 20698 --- [io-4200-exec-15]
> o.h.engine.jdbc.spi.SqlExceptionHelper   : HikariPool-1 - Connection
> is
> not
> available, request timed out after 3ms.
>
> 2019-02-18 04:49:35.573  WARN 20698 --- [io-4200-exec-15]
> o.s.s.o.provider.endpoint.TokenEndpoint  : Handling error:
> InternalAuthenticationServiceException, Unable to acquire JDBC
> Connection; nested exception is
> org.hibernate.exception.JDBCConnectionException: Unable to acquire
> JDBC Connection
>
>
>
> Server is Ubuntu (aws)
>
> Database is mySql
>
> java version "1.8.0_181

RE: Tomcat connection error

2019-02-18 Thread faisal
Hi John,

I am working in spring boot (maven) project.
I am not doing exclusive null-out of the connection feeling that spring boot 
will manage it, do I still need to manage it myself?
If you want I can list the dependencies here.

I have just added the following dependency but didn’t try yet on production 
server.

com.zaxxer
HikariCP
2.7.8
compile


Regards,
Faisal Zaidi

-Original Message-
From: John Dale [mailto:jcdw...@gmail.com] 
Sent: Monday, February 18, 2019 5:45 PM
To: Tomcat Users List
Subject: Re: Tomcat connection error

I agree - release your connection, commit transaction (if you have auto-commit 
set to false), and null-out your connection references.

The analogy in c++ is you need deallocate memory.

Java has GC in Java at a base level, but we also have some resource reclamation 
at higher levels of abstraction over which GC has no purview.  Pooling 
(threads, connections) is an example.  The connection pool needs to reclaim its 
connections for reallocation to other threads.  If it can't, the application 
will hang waiting for connections.

Do you have a static references to a database connection?

The golden rule with database connections is acquire them late and release them 
early.  I like to create try/catch/finally blocks.  In the finally block, which 
executes even if there is an exception, I commit the transaction and set 
connection reference to null.

As a matter of course, I would null out and close references to 
PreparedStatements and ResultSets as well (especially ResultSets).

I'm sure you'll figure it out.

Sincerely,

John


On 2/18/19, Mark Thomas  wrote:
> On 18/02/2019 10:24, fai...@bestercapitalmedia.com wrote:
>> Hi Ted,
>>
>> Yes, you are right.
>> I just need to restart the tomcat to get back it on.
>> There is no need to restart the mySql in my case.
>>
>> Any clue please.
>
> Sounds like a connection leak in the web application. I expect the 
> connection pool includes tools to help you track that sort of problem down.
>
> Mark
>
>
>>
>> Faisal Zaidi
>>
>> -Original Message-
>> From: Ted Spradley [mailto:ted.k.sprad...@gmail.com]
>> Sent: Monday, February 18, 2019 1:52 PM
>> To: Tomcat Users List
>> Subject: Re: Tomcat connection error
>>
>> Hi Faisal,
>>
>> Your application(s) run as expected for a while, then you get the SQL 
>> Connection error? Then the only way to “fix it” is to restart Tomcat? 
>> At the same time are you also restarting MySQL?
>>
>> Thanks,
>> Ted
>>
>>> On Feb 18, 2019, at 02:17, Luis Rodríguez Fernández 
>>> 
>>> wrote:
>>>
>>> Hello Faisal,
>>>
>>> It looks like your problem is more related with your hikari 
>>> connection pool than with tomcat itself. I would recommend you to 
>>> double check your hikari configuration properties. Pay specially 
>>> attention on how you are configuring your connection pool (minimum 
>>> and maximum size, timeout,
>>> etc...) It looks like there is "something" in your application that 
>>> prevents to get connections from your pool.
>>>
>>> Hope it helps,
>>>
>>> Luis
>>>
>>>
>>>
>>>
>>>
>>>
 El lun., 18 feb. 2019 a las 6:33, 
 escribió:

 Dear all,



 I am working on a project and I am facing following issue on almost 
 every second day. I need to restart tomcat to get it running again.

 Can someone guide me on it. Ask if you need some other insight to 
 look into it.



 2019-02-18 04:49:35.572  WARN 20698 --- [io-4200-exec-15]
 o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 0, SQLState: null

 2019-02-18 04:49:35.572 ERROR 20698 --- [io-4200-exec-15]
 o.h.engine.jdbc.spi.SqlExceptionHelper   : HikariPool-1 - Connection is
 not
 available, request timed out after 3ms.

 2019-02-18 04:49:35.573  WARN 20698 --- [io-4200-exec-15] 
 o.s.s.o.provider.endpoint.TokenEndpoint  : Handling error:
 InternalAuthenticationServiceException, Unable to acquire JDBC 
 Connection; nested exception is
 org.hibernate.exception.JDBCConnectionException: Unable to acquire 
 JDBC Connection



 Server is Ubuntu (aws)

 Database is mySql

 java version "1.8.0_181"

 Java(TM) SE Runtime Environment (build 1.8.0_181-b13)

 Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)



 Best Regards | Bien Cordialement | تحياتي

 Faisal Zaidi
 Application Architect




>>>
>>> --
>>>
>>> "Ever tried. Ever failed. No matter. Try Again. Fail again. Fail 
>>> better."
>>>
>>> - Samuel Beckett
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: users-h...@tomcat.apache.org
>>
>>
>>
>> 

Re: Tomcat connection error

2019-02-18 Thread John Dale
I agree - release your connection, commit transaction (if you have
auto-commit set to false), and null-out your connection references.

The analogy in c++ is you need deallocate memory.

Java has GC in Java at a base level, but we also have some resource
reclamation at higher levels of abstraction over which GC has no
purview.  Pooling (threads, connections) is an example.  The
connection pool needs to reclaim its connections for reallocation to
other threads.  If it can't, the application will hang waiting for
connections.

Do you have a static references to a database connection?

The golden rule with database connections is acquire them late and
release them early.  I like to create try/catch/finally blocks.  In
the finally block, which executes even if there is an exception, I
commit the transaction and set connection reference to null.

As a matter of course, I would null out and close references to
PreparedStatements and ResultSets as well (especially ResultSets).

I'm sure you'll figure it out.

Sincerely,

John


On 2/18/19, Mark Thomas  wrote:
> On 18/02/2019 10:24, fai...@bestercapitalmedia.com wrote:
>> Hi Ted,
>>
>> Yes, you are right.
>> I just need to restart the tomcat to get back it on.
>> There is no need to restart the mySql in my case.
>>
>> Any clue please.
>
> Sounds like a connection leak in the web application. I expect the
> connection pool includes tools to help you track that sort of problem down.
>
> Mark
>
>
>>
>> Faisal Zaidi
>>
>> -Original Message-
>> From: Ted Spradley [mailto:ted.k.sprad...@gmail.com]
>> Sent: Monday, February 18, 2019 1:52 PM
>> To: Tomcat Users List
>> Subject: Re: Tomcat connection error
>>
>> Hi Faisal,
>>
>> Your application(s) run as expected for a while, then you get the SQL
>> Connection error? Then the only way to “fix it” is to restart Tomcat? At
>> the same time are you also restarting MySQL?
>>
>> Thanks,
>> Ted
>>
>>> On Feb 18, 2019, at 02:17, Luis Rodríguez Fernández 
>>> wrote:
>>>
>>> Hello Faisal,
>>>
>>> It looks like your problem is more related with your hikari connection
>>> pool than with tomcat itself. I would recommend you to double check
>>> your hikari configuration properties. Pay specially attention on how
>>> you are configuring your connection pool (minimum and maximum size,
>>> timeout,
>>> etc...) It looks like there is "something" in your application that
>>> prevents to get connections from your pool.
>>>
>>> Hope it helps,
>>>
>>> Luis
>>>
>>>
>>>
>>>
>>>
>>>
 El lun., 18 feb. 2019 a las 6:33, 
 escribió:

 Dear all,



 I am working on a project and I am facing following issue on almost
 every second day. I need to restart tomcat to get it running again.

 Can someone guide me on it. Ask if you need some other insight to
 look into it.



 2019-02-18 04:49:35.572  WARN 20698 --- [io-4200-exec-15]
 o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 0, SQLState: null

 2019-02-18 04:49:35.572 ERROR 20698 --- [io-4200-exec-15]
 o.h.engine.jdbc.spi.SqlExceptionHelper   : HikariPool-1 - Connection is
 not
 available, request timed out after 3ms.

 2019-02-18 04:49:35.573  WARN 20698 --- [io-4200-exec-15]
 o.s.s.o.provider.endpoint.TokenEndpoint  : Handling error:
 InternalAuthenticationServiceException, Unable to acquire JDBC
 Connection; nested exception is
 org.hibernate.exception.JDBCConnectionException: Unable to acquire
 JDBC Connection



 Server is Ubuntu (aws)

 Database is mySql

 java version "1.8.0_181"

 Java(TM) SE Runtime Environment (build 1.8.0_181-b13)

 Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)



 Best Regards | Bien Cordialement | تحياتي

 Faisal Zaidi
 Application Architect




>>>
>>> --
>>>
>>> "Ever tried. Ever failed. No matter. Try Again. Fail again. Fail
>>> better."
>>>
>>> - Samuel Beckett
>>
>> -
>> 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
>
>

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



Re: Tomcat connection error

2019-02-18 Thread Mark Thomas
On 18/02/2019 10:24, fai...@bestercapitalmedia.com wrote:
> Hi Ted,
> 
> Yes, you are right.
> I just need to restart the tomcat to get back it on. 
> There is no need to restart the mySql in my case.
> 
> Any clue please.

Sounds like a connection leak in the web application. I expect the
connection pool includes tools to help you track that sort of problem down.

Mark


> 
> Faisal Zaidi
> 
> -Original Message-
> From: Ted Spradley [mailto:ted.k.sprad...@gmail.com] 
> Sent: Monday, February 18, 2019 1:52 PM
> To: Tomcat Users List
> Subject: Re: Tomcat connection error
> 
> Hi Faisal, 
> 
> Your application(s) run as expected for a while, then you get the SQL 
> Connection error? Then the only way to “fix it” is to restart Tomcat? At the 
> same time are you also restarting MySQL? 
> 
> Thanks,
> Ted
> 
>> On Feb 18, 2019, at 02:17, Luis Rodríguez Fernández  
>> wrote:
>>
>> Hello Faisal,
>>
>> It looks like your problem is more related with your hikari connection 
>> pool than with tomcat itself. I would recommend you to double check 
>> your hikari configuration properties. Pay specially attention on how 
>> you are configuring your connection pool (minimum and maximum size, 
>> timeout,
>> etc...) It looks like there is "something" in your application that 
>> prevents to get connections from your pool.
>>
>> Hope it helps,
>>
>> Luis
>>
>>
>>
>>
>>
>>
>>> El lun., 18 feb. 2019 a las 6:33,  escribió:
>>>
>>> Dear all,
>>>
>>>
>>>
>>> I am working on a project and I am facing following issue on almost 
>>> every second day. I need to restart tomcat to get it running again.
>>>
>>> Can someone guide me on it. Ask if you need some other insight to 
>>> look into it.
>>>
>>>
>>>
>>> 2019-02-18 04:49:35.572  WARN 20698 --- [io-4200-exec-15]
>>> o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 0, SQLState: null
>>>
>>> 2019-02-18 04:49:35.572 ERROR 20698 --- [io-4200-exec-15]
>>> o.h.engine.jdbc.spi.SqlExceptionHelper   : HikariPool-1 - Connection is not
>>> available, request timed out after 3ms.
>>>
>>> 2019-02-18 04:49:35.573  WARN 20698 --- [io-4200-exec-15] 
>>> o.s.s.o.provider.endpoint.TokenEndpoint  : Handling error:
>>> InternalAuthenticationServiceException, Unable to acquire JDBC 
>>> Connection; nested exception is 
>>> org.hibernate.exception.JDBCConnectionException: Unable to acquire 
>>> JDBC Connection
>>>
>>>
>>>
>>> Server is Ubuntu (aws)
>>>
>>> Database is mySql
>>>
>>> java version "1.8.0_181"
>>>
>>> Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
>>>
>>> Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
>>>
>>>
>>>
>>> Best Regards | Bien Cordialement | تحياتي
>>>
>>> Faisal Zaidi
>>> Application Architect
>>>
>>>
>>>
>>>
>>
>> --
>>
>> "Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better."
>>
>> - Samuel Beckett
> 
> -
> 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 connection error

2019-02-18 Thread faisal
Hi Ted,

Yes, you are right.
I just need to restart the tomcat to get back it on. 
There is no need to restart the mySql in my case.

Any clue please.

Faisal Zaidi

-Original Message-
From: Ted Spradley [mailto:ted.k.sprad...@gmail.com] 
Sent: Monday, February 18, 2019 1:52 PM
To: Tomcat Users List
Subject: Re: Tomcat connection error

Hi Faisal, 

Your application(s) run as expected for a while, then you get the SQL 
Connection error? Then the only way to “fix it” is to restart Tomcat? At the 
same time are you also restarting MySQL? 

Thanks,
Ted

> On Feb 18, 2019, at 02:17, Luis Rodríguez Fernández  wrote:
> 
> Hello Faisal,
> 
> It looks like your problem is more related with your hikari connection 
> pool than with tomcat itself. I would recommend you to double check 
> your hikari configuration properties. Pay specially attention on how 
> you are configuring your connection pool (minimum and maximum size, 
> timeout,
> etc...) It looks like there is "something" in your application that 
> prevents to get connections from your pool.
> 
> Hope it helps,
> 
> Luis
> 
> 
> 
> 
> 
> 
>> El lun., 18 feb. 2019 a las 6:33,  escribió:
>> 
>> Dear all,
>> 
>> 
>> 
>> I am working on a project and I am facing following issue on almost 
>> every second day. I need to restart tomcat to get it running again.
>> 
>> Can someone guide me on it. Ask if you need some other insight to 
>> look into it.
>> 
>> 
>> 
>> 2019-02-18 04:49:35.572  WARN 20698 --- [io-4200-exec-15]
>> o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 0, SQLState: null
>> 
>> 2019-02-18 04:49:35.572 ERROR 20698 --- [io-4200-exec-15]
>> o.h.engine.jdbc.spi.SqlExceptionHelper   : HikariPool-1 - Connection is not
>> available, request timed out after 3ms.
>> 
>> 2019-02-18 04:49:35.573  WARN 20698 --- [io-4200-exec-15] 
>> o.s.s.o.provider.endpoint.TokenEndpoint  : Handling error:
>> InternalAuthenticationServiceException, Unable to acquire JDBC 
>> Connection; nested exception is 
>> org.hibernate.exception.JDBCConnectionException: Unable to acquire 
>> JDBC Connection
>> 
>> 
>> 
>> Server is Ubuntu (aws)
>> 
>> Database is mySql
>> 
>> java version "1.8.0_181"
>> 
>> Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
>> 
>> Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
>> 
>> 
>> 
>> Best Regards | Bien Cordialement | تحياتي
>> 
>> Faisal Zaidi
>> Application Architect
>> 
>> 
>> 
>> 
> 
> --
> 
> "Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better."
> 
> - Samuel Beckett

-
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 connection error

2019-02-18 Thread Ted Spradley
Hi Faisal, 

Your application(s) run as expected for a while, then you get the SQL 
Connection error? Then the only way to “fix it” is to restart Tomcat? At the 
same time are you also restarting MySQL? 

Thanks,
Ted

> On Feb 18, 2019, at 02:17, Luis Rodríguez Fernández  wrote:
> 
> Hello Faisal,
> 
> It looks like your problem is more related with your hikari connection pool
> than with tomcat itself. I would recommend you to double check your hikari
> configuration properties. Pay specially attention on how you are
> configuring your connection pool (minimum and maximum size, timeout,
> etc...) It looks like there is "something" in your application that
> prevents to get connections from your pool.
> 
> Hope it helps,
> 
> Luis
> 
> 
> 
> 
> 
> 
>> El lun., 18 feb. 2019 a las 6:33,  escribió:
>> 
>> Dear all,
>> 
>> 
>> 
>> I am working on a project and I am facing following issue on almost every
>> second day. I need to restart tomcat to get it running again.
>> 
>> Can someone guide me on it. Ask if you need some other insight to look into
>> it.
>> 
>> 
>> 
>> 2019-02-18 04:49:35.572  WARN 20698 --- [io-4200-exec-15]
>> o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 0, SQLState: null
>> 
>> 2019-02-18 04:49:35.572 ERROR 20698 --- [io-4200-exec-15]
>> o.h.engine.jdbc.spi.SqlExceptionHelper   : HikariPool-1 - Connection is not
>> available, request timed out after 3ms.
>> 
>> 2019-02-18 04:49:35.573  WARN 20698 --- [io-4200-exec-15]
>> o.s.s.o.provider.endpoint.TokenEndpoint  : Handling error:
>> InternalAuthenticationServiceException, Unable to acquire JDBC Connection;
>> nested exception is org.hibernate.exception.JDBCConnectionException: Unable
>> to acquire JDBC Connection
>> 
>> 
>> 
>> Server is Ubuntu (aws)
>> 
>> Database is mySql
>> 
>> java version "1.8.0_181"
>> 
>> Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
>> 
>> Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
>> 
>> 
>> 
>> Best Regards | Bien Cordialement | تحياتي
>> 
>> Faisal Zaidi
>> Application Architect
>> 
>> 
>> 
>> 
> 
> -- 
> 
> "Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better."
> 
> - Samuel Beckett

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



Re: Tomcat connection error

2019-02-18 Thread Luis Rodríguez Fernández
Hello Faisal,

It looks like your problem is more related with your hikari connection pool
than with tomcat itself. I would recommend you to double check your hikari
configuration properties. Pay specially attention on how you are
configuring your connection pool (minimum and maximum size, timeout,
etc...) It looks like there is "something" in your application that
prevents to get connections from your pool.

Hope it helps,

Luis






El lun., 18 feb. 2019 a las 6:33,  escribió:

> Dear all,
>
>
>
> I am working on a project and I am facing following issue on almost every
> second day. I need to restart tomcat to get it running again.
>
> Can someone guide me on it. Ask if you need some other insight to look into
> it.
>
>
>
> 2019-02-18 04:49:35.572  WARN 20698 --- [io-4200-exec-15]
> o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 0, SQLState: null
>
> 2019-02-18 04:49:35.572 ERROR 20698 --- [io-4200-exec-15]
> o.h.engine.jdbc.spi.SqlExceptionHelper   : HikariPool-1 - Connection is not
> available, request timed out after 3ms.
>
> 2019-02-18 04:49:35.573  WARN 20698 --- [io-4200-exec-15]
> o.s.s.o.provider.endpoint.TokenEndpoint  : Handling error:
> InternalAuthenticationServiceException, Unable to acquire JDBC Connection;
> nested exception is org.hibernate.exception.JDBCConnectionException: Unable
> to acquire JDBC Connection
>
>
>
> Server is Ubuntu (aws)
>
> Database is mySql
>
> java version "1.8.0_181"
>
> Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
>
> Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
>
>
>
> Best Regards | Bien Cordialement | تحياتي
>
> Faisal Zaidi
> Application Architect
>
>
>
>

-- 

"Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better."

- Samuel Beckett