FAQ
Hi all.
We had some DB problems last night (MariaDB with the ConnectorJ driver). As soon as I had started the DB back up, our EOF applications were up and running, but the Cayenne apps were still down and required a restart to start running again.

Is there any way to tell Cayenne to reconnect to the DB after an event like this?

Cheers,
- hugi

// Hugi Thordarson
// http://www.loftfar.is/
// s. 895-6688

Search Discussions

  • Andrus Adamchik at Feb 29, 2016 at 10:57 am
    Probably a DataSource configuration. I am using DB urls like this:

    jdbc:mysql://127.0.0.1/db?connectTimeout=0&autoReconnect=true&useUnicode=true&characterEncoding=UTF-8

    and also add "validationQuery" parameter to my pool config. Both ensure reconnects are transparent.

    Andrus
    On Feb 29, 2016, at 1:53 PM, Hugi Thordarson wrote:

    Hi all.
    We had some DB problems last night (MariaDB with the ConnectorJ driver). As soon as I had started the DB back up, our EOF applications were up and running, but the Cayenne apps were still down and required a restart to start running again.

    Is there any way to tell Cayenne to reconnect to the DB after an event like this?

    Cheers,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688
  • Hugi Thordarson at Feb 29, 2016 at 11:20 am
    Thanks Andrus. I do have “autoReconnect=true” in the string but added the connectionTimeout, perhaps that helps.

    What does validationQuery do?

    Cheers,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 10:57, Andrus Adamchik wrote:

    Probably a DataSource configuration. I am using DB urls like this:

    jdbc:mysql://127.0.0.1/db?connectTimeout=0&autoReconnect=true&useUnicode=true&characterEncoding=UTF-8

    and also add "validationQuery" parameter to my pool config. Both ensure reconnects are transparent.

    Andrus
    On Feb 29, 2016, at 1:53 PM, Hugi Thordarson wrote:

    Hi all.
    We had some DB problems last night (MariaDB with the ConnectorJ driver). As soon as I had started the DB back up, our EOF applications were up and running, but the Cayenne apps were still down and required a restart to start running again.

    Is there any way to tell Cayenne to reconnect to the DB after an event like this?

    Cheers,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688
  • Andrus Adamchik at Feb 29, 2016 at 11:25 am

    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson wrote:

    What does validationQuery do?
    Periodically executes for each pooled connection, and kills connections that throw during validation. So it ensures that all pooled connections are in a good state.

    Andrus
  • Hugi Thordarson at Feb 29, 2016 at 11:27 am
    Ah, awesome. Added to my config :).

    Cheers,
    - hugi


    On 29. feb. 2016, at 11:25, Andrus Adamchik wrote:

    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson wrote:

    What does validationQuery do?
    Periodically executes for each pooled connection, and kills connections that throw during validation. So it ensures that all pooled connections are in a good state.

    Andrus
  • Michael Gentry at Feb 29, 2016 at 1:11 pm
    Hi Hugi,

    Just out of curiosity, which connection pooling mechanism were you using?
    I've seen Cayenne automatically re-connect to PostgreSQL before.

    mrg

    On Mon, Feb 29, 2016 at 6:26 AM, Hugi Thordarson wrote:

    Ah, awesome. Added to my config :).

    Cheers,
    - hugi


    On 29. feb. 2016, at 11:25, Andrus Adamchik wrote:

    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson wrote:

    What does validationQuery do?
    Periodically executes for each pooled connection, and kills connections
    that throw during validation. So it ensures that all pooled connections are
    in a good state.
    Andrus
  • Hugi Thordarson at Feb 29, 2016 at 1:14 pm
    Hi Michael,
    I’m not quite sure, I’m just giving Cayenne my connection information. Should I be using a different mechanism?

    Cheers,
    - hugi


    On 29. feb. 2016, at 13:10, Michael Gentry wrote:

    Hi Hugi,

    Just out of curiosity, which connection pooling mechanism were you using?
    I've seen Cayenne automatically re-connect to PostgreSQL before.

    mrg

    On Mon, Feb 29, 2016 at 6:26 AM, Hugi Thordarson wrote:

    Ah, awesome. Added to my config :).

    Cheers,
    - hugi


    On 29. feb. 2016, at 11:25, Andrus Adamchik <andrus@objectstyle.org>
    wrote:
    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson wrote:

    What does validationQuery do?
    Periodically executes for each pooled connection, and kills connections
    that throw during validation. So it ensures that all pooled connections are
    in a good state.
    Andrus
  • Michael Gentry at Feb 29, 2016 at 2:13 pm
    Hi Hugi,

    I don't know the nature of your application. I've used Cayenne's native
    connection pooling (stand-alone applications) and JNDI (typically based on
    Apache Commons DBCP) in the past. If my memory is correct, Cayenne's
    native connection pooling does attempt to do a re-connect on failure. for
    JNDI, you probably have to tell the JDBC connector to auto-reconnect. If
    you are using Cayenne's native and it didn't re-connect, we might have an
    issue to explore. What version of Cayenne are you using?

    Thanks,

    mrg

    On Mon, Feb 29, 2016 at 8:14 AM, Hugi Thordarson wrote:

    Hi Michael,
    I’m not quite sure, I’m just giving Cayenne my connection information.
    Should I be using a different mechanism?

    Cheers,
    - hugi


    On 29. feb. 2016, at 13:10, Michael Gentry wrote:

    Hi Hugi,

    Just out of curiosity, which connection pooling mechanism were you using?
    I've seen Cayenne automatically re-connect to PostgreSQL before.

    mrg

    On Mon, Feb 29, 2016 at 6:26 AM, Hugi Thordarson wrote:

    Ah, awesome. Added to my config :).

    Cheers,
    - hugi


    On 29. feb. 2016, at 11:25, Andrus Adamchik <andrus@objectstyle.org>
    wrote:
    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson wrote:

    What does validationQuery do?
    Periodically executes for each pooled connection, and kills connections
    that throw during validation. So it ensures that all pooled connections
    are
    in a good state.
    Andrus
  • Hugi Thordarson at Feb 29, 2016 at 2:34 pm
    I’m using Cayenne’s internal mechanism for everything related to the DB and currently using 4.0.M4-SNAPSHOT. The stack trace we were getting (after restarting the DB, and the EOF programs had started working) was:

    Caused by: org.apache.cayenne.datasource.UnmanagedPoolingDataSource$ConnectionUnavailableException: Can't obtain connection. Request to pool timed out. Total pool size: 0
      at org.apache.cayenne.datasource.UnmanagedPoolingDataSource.getConnection(UnmanagedPoolingDataSource.java:339)
      at org.apache.cayenne.datasource.ManagedPoolingDataSource.getConnection(ManagedPoolingDataSource.java:80)
      at org.apache.cayenne.access.DataNode$TransactionDataSource.getConnection(DataNode.java:372)
      at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:286)


    I’ve added setting a validationQuery on my ServerRuntimeBuilder, perhaps that will help the next time. I’ll test it some more tonight.

    Thanks!
    - hugi


    On 29. feb. 2016, at 14:12, Michael Gentry wrote:

    Hi Hugi,

    I don't know the nature of your application. I've used Cayenne's native
    connection pooling (stand-alone applications) and JNDI (typically based on
    Apache Commons DBCP) in the past. If my memory is correct, Cayenne's
    native connection pooling does attempt to do a re-connect on failure. for
    JNDI, you probably have to tell the JDBC connector to auto-reconnect. If
    you are using Cayenne's native and it didn't re-connect, we might have an
    issue to explore. What version of Cayenne are you using?

    Thanks,

    mrg

    On Mon, Feb 29, 2016 at 8:14 AM, Hugi Thordarson wrote:

    Hi Michael,
    I’m not quite sure, I’m just giving Cayenne my connection information.
    Should I be using a different mechanism?

    Cheers,
    - hugi


    On 29. feb. 2016, at 13:10, Michael Gentry <mgentry@masslight.net> wrote:
    Hi Hugi,

    Just out of curiosity, which connection pooling mechanism were you using?
    I've seen Cayenne automatically re-connect to PostgreSQL before.

    mrg


    On Mon, Feb 29, 2016 at 6:26 AM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    Ah, awesome. Added to my config :).

    Cheers,
    - hugi


    On 29. feb. 2016, at 11:25, Andrus Adamchik <andrus@objectstyle.org>
    wrote:
    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    What does validationQuery do?
    Periodically executes for each pooled connection, and kills connections
    that throw during validation. So it ensures that all pooled connections
    are
    in a good state.
    Andrus
  • Hugi Thordarson at Mar 7, 2016 at 10:46 am
    Hi all,
    This is still happening, even after I added a validationQuery, our app is dying quite frequently :(. I’m not quite sure how to debug this, is there any way for me to catch where connections are being opened in the code and at what location they’re hanging?

    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0

    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik wrote:

    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson wrote:

    What does validationQuery do?
    Periodically executes for each pooled connection, and kills connections that throw during validation. So it ensures that all pooled connections are in a good state.

    Andrus
  • Andrus Adamchik at Mar 7, 2016 at 6:54 pm
    Hmm... It shows there are zero connections in the pool. I have a theory about that. Looks like when you uncheck your first connection after the DB restart, pool goes through all connections to find a valid one, and removing bad connections in the process. As there are no longer valid connections there, the pool is drained completely. Then the error happens; and then at a later time, pool manager thread kicks in and fills the pool with new connections.

    I need to test it.. And perhaps move the validation to background.

    (and perhaps add Tomcat connection pool to a list of DataSource options ... that's the one I am using in Bootique: https://github.com/nhl/bootique-jdbc and elsewhere in production).

    Andrus
    On Mar 7, 2016, at 2:46 AM, Hugi Thordarson wrote:

    Hi all,
    This is still happening, even after I added a validationQuery, our app is dying quite frequently :(. I’m not quite sure how to debug this, is there any way for me to catch where connections are being opened in the code and at what location they’re hanging?

    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0

    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik wrote:

    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson wrote:

    What does validationQuery do?
    Periodically executes for each pooled connection, and kills connections that throw during validation. So it ensures that all pooled connections are in a good state.

    Andrus
  • Hugi Thordarson at Mar 7, 2016 at 8:02 pm
    Thanks for the reply Andrus!

    Sounds like it might be the case. But actually, this now happens without the DB going down (and I don’t think it’s a communication problem with the DB either, since the DB runs on the same server as the apps).

    I recently added a PostCommitListener that does quite a lot of DB work and I believe the issue started around the same time. At first I thought it might be a deadlocking sitation, but a jstack thread dump from a dead process does not point to that.

    Is there any way for me to check the number and status of currently open connections?

    Cheers,
    - hugi


    On 7. mar. 2016, at 18:54, Andrus Adamchik wrote:

    Hmm... It shows there are zero connections in the pool. I have a theory about that. Looks like when you uncheck your first connection after the DB restart, pool goes through all connections to find a valid one, and removing bad connections in the process. As there are no longer valid connections there, the pool is drained completely. Then the error happens; and then at a later time, pool manager thread kicks in and fills the pool with new connections.

    I need to test it.. And perhaps move the validation to background.

    (and perhaps add Tomcat connection pool to a list of DataSource options ... that's the one I am using in Bootique: https://github.com/nhl/bootique-jdbc and elsewhere in production).

    Andrus
    On Mar 7, 2016, at 2:46 AM, Hugi Thordarson wrote:

    Hi all,
    This is still happening, even after I added a validationQuery, our app is dying quite frequently :(. I’m not quite sure how to debug this, is there any way for me to catch where connections are being opened in the code and at what location they’re hanging?

    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0

    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik wrote:

    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson wrote:

    What does validationQuery do?
    Periodically executes for each pooled connection, and kills connections that throw during validation. So it ensures that all pooled connections are in a good state.

    Andrus
  • Hugi Thordarson at Mar 7, 2016 at 8:29 pm
    Is it possible it’s a configuration issue? I’m setting minConnections to 1 and maxConnections to 10. Should I rather leave these at default values or choose different values?

    Cheers,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 7. mar. 2016, at 20:01, Hugi Thordarson wrote:

    Thanks for the reply Andrus!

    Sounds like it might be the case. But actually, this now happens without the DB going down (and I don’t think it’s a communication problem with the DB either, since the DB runs on the same server as the apps).

    I recently added a PostCommitListener that does quite a lot of DB work and I believe the issue started around the same time. At first I thought it might be a deadlocking sitation, but a jstack thread dump from a dead process does not point to that.

    Is there any way for me to check the number and status of currently open connections?

    Cheers,
    - hugi


    On 7. mar. 2016, at 18:54, Andrus Adamchik wrote:

    Hmm... It shows there are zero connections in the pool. I have a theory about that. Looks like when you uncheck your first connection after the DB restart, pool goes through all connections to find a valid one, and removing bad connections in the process. As there are no longer valid connections there, the pool is drained completely. Then the error happens; and then at a later time, pool manager thread kicks in and fills the pool with new connections.

    I need to test it.. And perhaps move the validation to background.

    (and perhaps add Tomcat connection pool to a list of DataSource options ... that's the one I am using in Bootique: https://github.com/nhl/bootique-jdbc and elsewhere in production).

    Andrus
    On Mar 7, 2016, at 2:46 AM, Hugi Thordarson wrote:

    Hi all,
    This is still happening, even after I added a validationQuery, our app is dying quite frequently :(. I’m not quite sure how to debug this, is there any way for me to catch where connections are being opened in the code and at what location they’re hanging?

    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0

    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik wrote:

    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson wrote:

    What does validationQuery do?
    Periodically executes for each pooled connection, and kills connections that throw during validation. So it ensures that all pooled connections are in a good state.

    Andrus
  • Michael Gentry at Mar 7, 2016 at 7:13 pm
    Hi Hugi,

    Since this appears to be a web-based application, can you switch to using
    JNDI?

    mrg

    On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson wrote:

    Hi all,
    This is still happening, even after I added a validationQuery, our app is
    dying quite frequently :(. I’m not quite sure how to debug this, is there
    any way for me to catch where connections are being opened in the code and
    at what location they’re hanging?


    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0

    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik wrote:

    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson wrote:

    What does validationQuery do?
    Periodically executes for each pooled connection, and kills connections
    that throw during validation. So it ensures that all pooled connections are
    in a good state.
    Andrus
  • Hugi Thordarson at Mar 7, 2016 at 8:07 pm
    Hi Michael,
    does using JNDI change anything about the connection itself, isn’t it just a different method of looking up connection information?

    But I probably can’t use it anyway since one of the apps is a WebObjects app and doesn’t provide a JNDI service (at least I’ve never used it).

    Thanks,
    - hugi

    On 7. mar. 2016, at 19:13, Michael Gentry wrote:

    Hi Hugi,

    Since this appears to be a web-based application, can you switch to using
    JNDI?

    mrg

    On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson wrote:

    Hi all,
    This is still happening, even after I added a validationQuery, our app is
    dying quite frequently :(. I’m not quite sure how to debug this, is there
    any way for me to catch where connections are being opened in the code and
    at what location they’re hanging?


    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0

    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik <andrus@objectstyle.org>
    wrote:
    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson wrote:

    What does validationQuery do?
    Periodically executes for each pooled connection, and kills connections
    that throw during validation. So it ensures that all pooled connections are
    in a good state.
    Andrus
  • Michael Gentry at Mar 7, 2016 at 8:31 pm
    Well, I'm not sure what you are using to run your web application, but
    Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups of DB
    connection pools. You just tell Cayenne Modeler to use JNDI lookup and
    give it the JNDI name, then configure the container to provide the DB
    connection.

    Is your WO application using EOF or Cayenne? Been a while since I used WO,
    but I'd be stunned if EOF cannot use a JNDI lookup as well.

    mrg

    On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson wrote:

    Hi Michael,
    does using JNDI change anything about the connection itself, isn’t it just
    a different method of looking up connection information?

    But I probably can’t use it anyway since one of the apps is a WebObjects
    app and doesn’t provide a JNDI service (at least I’ve never used it).

    Thanks,
    - hugi

    On 7. mar. 2016, at 19:13, Michael Gentry wrote:

    Hi Hugi,

    Since this appears to be a web-based application, can you switch to using
    JNDI?

    mrg

    On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson wrote:

    Hi all,
    This is still happening, even after I added a validationQuery, our app
    is
    dying quite frequently :(. I’m not quite sure how to debug this, is
    there
    any way for me to catch where connections are being opened in the code
    and
    at what location they’re hanging?

    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik <andrus@objectstyle.org>
    wrote:
    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson wrote:

    What does validationQuery do?
    Periodically executes for each pooled connection, and kills connections
    that throw during validation. So it ensures that all pooled connections
    are
    in a good state.
    Andrus
  • John Huss at Mar 7, 2016 at 8:39 pm
    EOF can do JNDI, but that's not going to do anything to fix your problem.

    The connection pool in cayenne had some changes somewhat recently so it's
    entirely possible there are bugs.

    In practice it turns out many people don't use the connection pool built-in
    to Cayenne at all, and rather use a third-party connection pool, of which
    there are several. The cayenne one is decent, but it is very limited in
    functionality and less robust due to having a smaller user base and being a
    non-core feature.

    You can use another pool like:
    hikari <https://github.com/brettwooldridge/HikariCP> - If I was starting a
    new project I'd use this
    tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html> -
    This is what I currently use
    commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
    c3po <http://www.mchange.com/projects/c3p0/>

    The main reason I turned to a third-party connection pool was to get
    fair-scheduling which will provide connections to whoever has been waiting
    the longest, which helps avoid unnecessary errors caused by serving
    requests out of order.

    John
    On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry wrote:

    Well, I'm not sure what you are using to run your web application, but
    Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups of DB
    connection pools. You just tell Cayenne Modeler to use JNDI lookup and
    give it the JNDI name, then configure the container to provide the DB
    connection.

    Is your WO application using EOF or Cayenne? Been a while since I used WO,
    but I'd be stunned if EOF cannot use a JNDI lookup as well.

    mrg

    On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson wrote:

    Hi Michael,
    does using JNDI change anything about the connection itself, isn’t it just
    a different method of looking up connection information?

    But I probably can’t use it anyway since one of the apps is a WebObjects
    app and doesn’t provide a JNDI service (at least I’ve never used it).

    Thanks,
    - hugi

    On 7. mar. 2016, at 19:13, Michael Gentry wrote:

    Hi Hugi,

    Since this appears to be a web-based application, can you switch to
    using
    JNDI?

    mrg


    On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    Hi all,
    This is still happening, even after I added a validationQuery, our app
    is
    dying quite frequently :(. I’m not quite sure how to debug this, is
    there
    any way for me to catch where connections are being opened in the code
    and
    at what location they’re hanging?

    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik <andrus@objectstyle.org>
    wrote:
    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    What does validationQuery do?
    Periodically executes for each pooled connection, and kills
    connections
    that throw during validation. So it ensures that all pooled
    connections
    are
    in a good state.
    Andrus
  • Hugi Thordarson at Mar 7, 2016 at 8:45 pm
    Thanks John! I’m going to try my hand at HikariCP.

    Are there any examples anywhere on how to configure Cayenne to use a third party connection pool?

    Cheers,
    - hugi



    On 7. mar. 2016, at 20:39, John Huss wrote:

    EOF can do JNDI, but that's not going to do anything to fix your problem.

    The connection pool in cayenne had some changes somewhat recently so it's
    entirely possible there are bugs.

    In practice it turns out many people don't use the connection pool built-in
    to Cayenne at all, and rather use a third-party connection pool, of which
    there are several. The cayenne one is decent, but it is very limited in
    functionality and less robust due to having a smaller user base and being a
    non-core feature.

    You can use another pool like:
    hikari <https://github.com/brettwooldridge/HikariCP> - If I was starting a
    new project I'd use this
    tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html> -
    This is what I currently use
    commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
    c3po <http://www.mchange.com/projects/c3p0/>

    The main reason I turned to a third-party connection pool was to get
    fair-scheduling which will provide connections to whoever has been waiting
    the longest, which helps avoid unnecessary errors caused by serving
    requests out of order.

    John
    On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry wrote:

    Well, I'm not sure what you are using to run your web application, but
    Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups of DB
    connection pools. You just tell Cayenne Modeler to use JNDI lookup and
    give it the JNDI name, then configure the container to provide the DB
    connection.

    Is your WO application using EOF or Cayenne? Been a while since I used WO,
    but I'd be stunned if EOF cannot use a JNDI lookup as well.

    mrg

    On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson wrote:

    Hi Michael,
    does using JNDI change anything about the connection itself, isn’t it just
    a different method of looking up connection information?

    But I probably can’t use it anyway since one of the apps is a WebObjects
    app and doesn’t provide a JNDI service (at least I’ve never used it).

    Thanks,
    - hugi

    On 7. mar. 2016, at 19:13, Michael Gentry <mgentry@masslight.net>
    wrote:
    Hi Hugi,

    Since this appears to be a web-based application, can you switch to
    using
    JNDI?

    mrg


    On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    Hi all,
    This is still happening, even after I added a validationQuery, our app
    is
    dying quite frequently :(. I’m not quite sure how to debug this, is
    there
    any way for me to catch where connections are being opened in the code
    and
    at what location they’re hanging?

    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik <andrus@objectstyle.org>
    wrote:
    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    What does validationQuery do?
    Periodically executes for each pooled connection, and kills
    connections
    that throw during validation. So it ensures that all pooled
    connections
    are
    in a good state.
    Andrus
  • Andrus Adamchik at Mar 7, 2016 at 8:51 pm
    Yep. Cayenne built-in pool is intentionally basic with a minimal number of features (Here we may be dealing with a bug though, and I'd like to fix it, but that's a separate issue). So yeah, using a third party DS may be a good idea. Here is an example how you can set it up:

    DataSource ds = // instantiate it via API specific to you DS provider

    ServerRuntime runtime = ServerRuntimeBuilder.builder().dataSource(ds).build();
    // of course add any other things you need to add to the builder to get a working Cayenne stack.

    Andrus

    On Mar 7, 2016, at 12:45 PM, Hugi Thordarson wrote:

    Thanks John! I’m going to try my hand at HikariCP.

    Are there any examples anywhere on how to configure Cayenne to use a third party connection pool?

    Cheers,
    - hugi



    On 7. mar. 2016, at 20:39, John Huss wrote:

    EOF can do JNDI, but that's not going to do anything to fix your problem.

    The connection pool in cayenne had some changes somewhat recently so it's
    entirely possible there are bugs.

    In practice it turns out many people don't use the connection pool built-in
    to Cayenne at all, and rather use a third-party connection pool, of which
    there are several. The cayenne one is decent, but it is very limited in
    functionality and less robust due to having a smaller user base and being a
    non-core feature.

    You can use another pool like:
    hikari <https://github.com/brettwooldridge/HikariCP> - If I was starting a
    new project I'd use this
    tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html> -
    This is what I currently use
    commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
    c3po <http://www.mchange.com/projects/c3p0/>

    The main reason I turned to a third-party connection pool was to get
    fair-scheduling which will provide connections to whoever has been waiting
    the longest, which helps avoid unnecessary errors caused by serving
    requests out of order.

    John
    On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry wrote:

    Well, I'm not sure what you are using to run your web application, but
    Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups of DB
    connection pools. You just tell Cayenne Modeler to use JNDI lookup and
    give it the JNDI name, then configure the container to provide the DB
    connection.

    Is your WO application using EOF or Cayenne? Been a while since I used WO,
    but I'd be stunned if EOF cannot use a JNDI lookup as well.

    mrg

    On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson wrote:

    Hi Michael,
    does using JNDI change anything about the connection itself, isn’t it just
    a different method of looking up connection information?

    But I probably can’t use it anyway since one of the apps is a WebObjects
    app and doesn’t provide a JNDI service (at least I’ve never used it).

    Thanks,
    - hugi

    On 7. mar. 2016, at 19:13, Michael Gentry <mgentry@masslight.net>
    wrote:
    Hi Hugi,

    Since this appears to be a web-based application, can you switch to
    using
    JNDI?

    mrg


    On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    Hi all,
    This is still happening, even after I added a validationQuery, our app
    is
    dying quite frequently :(. I’m not quite sure how to debug this, is
    there
    any way for me to catch where connections are being opened in the code
    and
    at what location they’re hanging?

    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik <andrus@objectstyle.org>
    wrote:
    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    What does validationQuery do?
    Periodically executes for each pooled connection, and kills
    connections
    that throw during validation. So it ensures that all pooled
    connections
    are
    in a good state.
    Andrus
  • Hugi Thordarson at Mar 7, 2016 at 9:03 pm
    Well, that was easy! Up and running in production.

    HikariConfig config = new HikariConfig();
    config.setJdbcUrl( "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0" );
    config.setUsername( “myUsername" );
    config.setPassword( “myPassword" );

    HikariDataSource dataSource = new HikariDataSource( config );
    serverRuntimeBuilder = serverRuntimeBuilder.dataSource( dataSource );

    Thanks,
    - hugi

    On 7. mar. 2016, at 20:51, Andrus Adamchik wrote:

    Yep. Cayenne built-in pool is intentionally basic with a minimal number of features (Here we may be dealing with a bug though, and I'd like to fix it, but that's a separate issue). So yeah, using a third party DS may be a good idea. Here is an example how you can set it up:

    DataSource ds = // instantiate it via API specific to you DS provider

    ServerRuntime runtime = ServerRuntimeBuilder.builder().dataSource(ds).build();
    // of course add any other things you need to add to the builder to get a working Cayenne stack.

    Andrus

    On Mar 7, 2016, at 12:45 PM, Hugi Thordarson wrote:

    Thanks John! I’m going to try my hand at HikariCP.

    Are there any examples anywhere on how to configure Cayenne to use a third party connection pool?

    Cheers,
    - hugi



    On 7. mar. 2016, at 20:39, John Huss wrote:

    EOF can do JNDI, but that's not going to do anything to fix your problem.

    The connection pool in cayenne had some changes somewhat recently so it's
    entirely possible there are bugs.

    In practice it turns out many people don't use the connection pool built-in
    to Cayenne at all, and rather use a third-party connection pool, of which
    there are several. The cayenne one is decent, but it is very limited in
    functionality and less robust due to having a smaller user base and being a
    non-core feature.

    You can use another pool like:
    hikari <https://github.com/brettwooldridge/HikariCP> - If I was starting a
    new project I'd use this
    tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html> -
    This is what I currently use
    commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
    c3po <http://www.mchange.com/projects/c3p0/>

    The main reason I turned to a third-party connection pool was to get
    fair-scheduling which will provide connections to whoever has been waiting
    the longest, which helps avoid unnecessary errors caused by serving
    requests out of order.

    John
    On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry wrote:

    Well, I'm not sure what you are using to run your web application, but
    Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups of DB
    connection pools. You just tell Cayenne Modeler to use JNDI lookup and
    give it the JNDI name, then configure the container to provide the DB
    connection.

    Is your WO application using EOF or Cayenne? Been a while since I used WO,
    but I'd be stunned if EOF cannot use a JNDI lookup as well.

    mrg

    On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson wrote:

    Hi Michael,
    does using JNDI change anything about the connection itself, isn’t it just
    a different method of looking up connection information?

    But I probably can’t use it anyway since one of the apps is a WebObjects
    app and doesn’t provide a JNDI service (at least I’ve never used it).

    Thanks,
    - hugi

    On 7. mar. 2016, at 19:13, Michael Gentry <mgentry@masslight.net>
    wrote:
    Hi Hugi,

    Since this appears to be a web-based application, can you switch to
    using
    JNDI?

    mrg


    On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    Hi all,
    This is still happening, even after I added a validationQuery, our app
    is
    dying quite frequently :(. I’m not quite sure how to debug this, is
    there
    any way for me to catch where connections are being opened in the code
    and
    at what location they’re hanging?

    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik <andrus@objectstyle.org>
    wrote:
    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    What does validationQuery do?
    Periodically executes for each pooled connection, and kills
    connections
    that throw during validation. So it ensures that all pooled
    connections
    are
    in a good state.
    Andrus
  • Michael Gentry at Mar 7, 2016 at 9:14 pm
    Hi Hugi,

    It looks to me like this makes it much harder to deploy your application in
    development/test/etc type environments since your URL/etc are in the code.
    The advantage of JNDI is you only reference a logical name that is
    configured external to the WAR, making it much easier to have one build
    that can be deployed in different environments. I took a brief glance at
    Hikari and don't think it includes JNDI natively.

    mrg

    On Mon, Mar 7, 2016 at 4:03 PM, Hugi Thordarson wrote:

    Well, that was easy! Up and running in production.

    HikariConfig config = new HikariConfig();
    config.setJdbcUrl(
    "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0"
    );
    config.setUsername( “myUsername" );
    config.setPassword( “myPassword" );

    HikariDataSource dataSource = new HikariDataSource( config );
    serverRuntimeBuilder = serverRuntimeBuilder.dataSource( dataSource );

    Thanks,
    - hugi

    On 7. mar. 2016, at 20:51, Andrus Adamchik wrote:

    Yep. Cayenne built-in pool is intentionally basic with a minimal number
    of features (Here we may be dealing with a bug though, and I'd like to fix
    it, but that's a separate issue). So yeah, using a third party DS may be a
    good idea. Here is an example how you can set it up:
    DataSource ds = // instantiate it via API specific to you DS provider

    ServerRuntime runtime =
    ServerRuntimeBuilder.builder().dataSource(ds).build();
    // of course add any other things you need to add to the builder to get
    a working Cayenne stack.
    Andrus

    On Mar 7, 2016, at 12:45 PM, Hugi Thordarson wrote:

    Thanks John! I’m going to try my hand at HikariCP.

    Are there any examples anywhere on how to configure Cayenne to use a
    third party connection pool?
    Cheers,
    - hugi



    On 7. mar. 2016, at 20:39, John Huss wrote:

    EOF can do JNDI, but that's not going to do anything to fix your
    problem.
    The connection pool in cayenne had some changes somewhat recently so
    it's
    entirely possible there are bugs.

    In practice it turns out many people don't use the connection pool
    built-in
    to Cayenne at all, and rather use a third-party connection pool, of
    which
    there are several. The cayenne one is decent, but it is very limited
    in
    functionality and less robust due to having a smaller user base and
    being a
    non-core feature.

    You can use another pool like:
    hikari <https://github.com/brettwooldridge/HikariCP> - If I was
    starting a
    new project I'd use this
    tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html>
    -
    This is what I currently use
    commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
    c3po <http://www.mchange.com/projects/c3p0/>

    The main reason I turned to a third-party connection pool was to get
    fair-scheduling which will provide connections to whoever has been
    waiting
    the longest, which helps avoid unnecessary errors caused by serving
    requests out of order.

    John
    On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry wrote:

    Well, I'm not sure what you are using to run your web application, but
    Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups
    of DB
    connection pools. You just tell Cayenne Modeler to use JNDI lookup
    and
    give it the JNDI name, then configure the container to provide the DB
    connection.

    Is your WO application using EOF or Cayenne? Been a while since I
    used WO,
    but I'd be stunned if EOF cannot use a JNDI lookup as well.

    mrg

    On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson wrote:

    Hi Michael,
    does using JNDI change anything about the connection itself, isn’t it just
    a different method of looking up connection information?

    But I probably can’t use it anyway since one of the apps is a
    WebObjects
    app and doesn’t provide a JNDI service (at least I’ve never used it).

    Thanks,
    - hugi

    On 7. mar. 2016, at 19:13, Michael Gentry <mgentry@masslight.net>
    wrote:
    Hi Hugi,

    Since this appears to be a web-based application, can you switch to
    using
    JNDI?

    mrg


    On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    Hi all,
    This is still happening, even after I added a validationQuery, our
    app
    is
    dying quite frequently :(. I’m not quite sure how to debug this,
    is
    there
    any way for me to catch where connections are being opened in the
    code
    and
    at what location they’re hanging?

    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik <
    andrus@objectstyle.org>
    wrote:
    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    What does validationQuery do?
    Periodically executes for each pooled connection, and kills
    connections
    that throw during validation. So it ensures that all pooled
    connections
    are
    in a good state.
    Andrus
  • Andrus Adamchik at Mar 7, 2016 at 9:19 pm

    It looks to me like this makes it much harder to deploy your application in
    development/test/etc type environments since your URL/etc are in the code.
    Unless you use Bootique, or your own property-based config mechanism. "Make jar, not war" :)

    Andrus

    On Mar 7, 2016, at 1:13 PM, Michael Gentry wrote:

    Hi Hugi,

    It looks to me like this makes it much harder to deploy your application in
    development/test/etc type environments since your URL/etc are in the code.
    The advantage of JNDI is you only reference a logical name that is
    configured external to the WAR, making it much easier to have one build
    that can be deployed in different environments. I took a brief glance at
    Hikari and don't think it includes JNDI natively.

    mrg

    On Mon, Mar 7, 2016 at 4:03 PM, Hugi Thordarson wrote:

    Well, that was easy! Up and running in production.

    HikariConfig config = new HikariConfig();
    config.setJdbcUrl(
    "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0"
    );
    config.setUsername( “myUsername" );
    config.setPassword( “myPassword" );

    HikariDataSource dataSource = new HikariDataSource( config );
    serverRuntimeBuilder = serverRuntimeBuilder.dataSource( dataSource );

    Thanks,
    - hugi

    On 7. mar. 2016, at 20:51, Andrus Adamchik <andrus@objectstyle.org> wrote:
    Yep. Cayenne built-in pool is intentionally basic with a minimal number
    of features (Here we may be dealing with a bug though, and I'd like to fix
    it, but that's a separate issue). So yeah, using a third party DS may be a
    good idea. Here is an example how you can set it up:
    DataSource ds = // instantiate it via API specific to you DS provider

    ServerRuntime runtime =
    ServerRuntimeBuilder.builder().dataSource(ds).build();
    // of course add any other things you need to add to the builder to get
    a working Cayenne stack.
    Andrus

    On Mar 7, 2016, at 12:45 PM, Hugi Thordarson wrote:

    Thanks John! I’m going to try my hand at HikariCP.

    Are there any examples anywhere on how to configure Cayenne to use a
    third party connection pool?
    Cheers,
    - hugi



    On 7. mar. 2016, at 20:39, John Huss wrote:

    EOF can do JNDI, but that's not going to do anything to fix your
    problem.
    The connection pool in cayenne had some changes somewhat recently so
    it's
    entirely possible there are bugs.

    In practice it turns out many people don't use the connection pool
    built-in
    to Cayenne at all, and rather use a third-party connection pool, of
    which
    there are several. The cayenne one is decent, but it is very limited
    in
    functionality and less robust due to having a smaller user base and
    being a
    non-core feature.

    You can use another pool like:
    hikari <https://github.com/brettwooldridge/HikariCP> - If I was
    starting a
    new project I'd use this
    tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html>
    -
    This is what I currently use
    commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
    c3po <http://www.mchange.com/projects/c3p0/>

    The main reason I turned to a third-party connection pool was to get
    fair-scheduling which will provide connections to whoever has been
    waiting
    the longest, which helps avoid unnecessary errors caused by serving
    requests out of order.

    John

    On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <mgentry@masslight.net>
    wrote:
    Well, I'm not sure what you are using to run your web application, but
    Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups
    of DB
    connection pools. You just tell Cayenne Modeler to use JNDI lookup
    and
    give it the JNDI name, then configure the container to provide the DB
    connection.

    Is your WO application using EOF or Cayenne? Been a while since I
    used WO,
    but I'd be stunned if EOF cannot use a JNDI lookup as well.

    mrg


    On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    Hi Michael,
    does using JNDI change anything about the connection itself, isn’t it just
    a different method of looking up connection information?

    But I probably can’t use it anyway since one of the apps is a
    WebObjects
    app and doesn’t provide a JNDI service (at least I’ve never used it).

    Thanks,
    - hugi

    On 7. mar. 2016, at 19:13, Michael Gentry <mgentry@masslight.net>
    wrote:
    Hi Hugi,

    Since this appears to be a web-based application, can you switch to
    using
    JNDI?

    mrg


    On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    Hi all,
    This is still happening, even after I added a validationQuery, our
    app
    is
    dying quite frequently :(. I’m not quite sure how to debug this,
    is
    there
    any way for me to catch where connections are being opened in the
    code
    and
    at what location they’re hanging?

    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik <
    andrus@objectstyle.org>
    wrote:
    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    What does validationQuery do?
    Periodically executes for each pooled connection, and kills
    connections
    that throw during validation. So it ensures that all pooled
    connections
    are
    in a good state.
    Andrus
  • Michael Gentry at Mar 7, 2016 at 9:24 pm
    I didn't name it! :-)

    On Mon, Mar 7, 2016 at 4:19 PM, Andrus Adamchik wrote:

    It looks to me like this makes it much harder to deploy your application in
    development/test/etc type environments since your URL/etc are in the
    code.

    Unless you use Bootique, or your own property-based config mechanism.
    "Make jar, not war" :)

    Andrus

    On Mar 7, 2016, at 1:13 PM, Michael Gentry wrote:

    Hi Hugi,

    It looks to me like this makes it much harder to deploy your application in
    development/test/etc type environments since your URL/etc are in the code.
    The advantage of JNDI is you only reference a logical name that is
    configured external to the WAR, making it much easier to have one build
    that can be deployed in different environments. I took a brief glance at
    Hikari and don't think it includes JNDI natively.

    mrg

    On Mon, Mar 7, 2016 at 4:03 PM, Hugi Thordarson wrote:

    Well, that was easy! Up and running in production.

    HikariConfig config = new HikariConfig();
    config.setJdbcUrl(
    "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0"
    );
    config.setUsername( “myUsername" );
    config.setPassword( “myPassword" );

    HikariDataSource dataSource = new HikariDataSource( config );
    serverRuntimeBuilder = serverRuntimeBuilder.dataSource( dataSource );

    Thanks,
    - hugi

    On 7. mar. 2016, at 20:51, Andrus Adamchik <andrus@objectstyle.org> wrote:
    Yep. Cayenne built-in pool is intentionally basic with a minimal number
    of features (Here we may be dealing with a bug though, and I'd like to
    fix
    it, but that's a separate issue). So yeah, using a third party DS may
    be a
    good idea. Here is an example how you can set it up:
    DataSource ds = // instantiate it via API specific to you DS provider

    ServerRuntime runtime =
    ServerRuntimeBuilder.builder().dataSource(ds).build();
    // of course add any other things you need to add to the builder to get
    a working Cayenne stack.
    Andrus

    On Mar 7, 2016, at 12:45 PM, Hugi Thordarson wrote:

    Thanks John! I’m going to try my hand at HikariCP.

    Are there any examples anywhere on how to configure Cayenne to use a
    third party connection pool?
    Cheers,
    - hugi



    On 7. mar. 2016, at 20:39, John Huss wrote:

    EOF can do JNDI, but that's not going to do anything to fix your
    problem.
    The connection pool in cayenne had some changes somewhat recently so
    it's
    entirely possible there are bugs.

    In practice it turns out many people don't use the connection pool
    built-in
    to Cayenne at all, and rather use a third-party connection pool, of
    which
    there are several. The cayenne one is decent, but it is very limited
    in
    functionality and less robust due to having a smaller user base and
    being a
    non-core feature.

    You can use another pool like:
    hikari <https://github.com/brettwooldridge/HikariCP> - If I was
    starting a
    new project I'd use this
    tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html
    -
    This is what I currently use
    commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
    c3po <http://www.mchange.com/projects/c3p0/>

    The main reason I turned to a third-party connection pool was to get
    fair-scheduling which will provide connections to whoever has been
    waiting
    the longest, which helps avoid unnecessary errors caused by serving
    requests out of order.

    John

    On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <mgentry@masslight.net
    wrote:
    Well, I'm not sure what you are using to run your web application,
    but
    Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI
    lookups
    of DB
    connection pools. You just tell Cayenne Modeler to use JNDI lookup
    and
    give it the JNDI name, then configure the container to provide the
    DB
    connection.

    Is your WO application using EOF or Cayenne? Been a while since I
    used WO,
    but I'd be stunned if EOF cannot use a JNDI lookup as well.

    mrg


    On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    Hi Michael,
    does using JNDI change anything about the connection itself, isn’t
    it
    just
    a different method of looking up connection information?

    But I probably can’t use it anyway since one of the apps is a
    WebObjects
    app and doesn’t provide a JNDI service (at least I’ve never used
    it).
    Thanks,
    - hugi

    On 7. mar. 2016, at 19:13, Michael Gentry <mgentry@masslight.net>
    wrote:
    Hi Hugi,

    Since this appears to be a web-based application, can you switch
    to
    using
    JNDI?

    mrg


    On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hugi@karlmenn.is
    wrote:
    Hi all,
    This is still happening, even after I added a validationQuery,
    our
    app
    is
    dying quite frequently :(. I’m not quite sure how to debug this,
    is
    there
    any way for me to catch where connections are being opened in the
    code
    and
    at what location they’re hanging?

    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik <
    andrus@objectstyle.org>
    wrote:
    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hugi@karlmenn.is
    wrote:
    What does validationQuery do?
    Periodically executes for each pooled connection, and kills
    connections
    that throw during validation. So it ensures that all pooled
    connections
    are
    in a good state.
    Andrus
  • Hugi Thordarson at Mar 7, 2016 at 9:27 pm

    It looks to me like this makes it much harder to deploy your application in
    development/test/etc type environments since your URL/etc are in the code.
    Yeah, I see what you mean. We use a homebuilt property system for that which returns configuration based on environment. It’s not JNDI but works :)
    Unless you use Bootique, or your own property-based config mechanism.
    Is bootique worth checking out? I’m just noticing it now for the first time and so happens I’m looking into a new basis for our web services/APIs (current favorite being spark framework).
    "Make jar, not war" :)
    Ha ha ha :)

    - hugi

    On Mar 7, 2016, at 1:13 PM, Michael Gentry wrote:

    Hi Hugi,

    It looks to me like this makes it much harder to deploy your application in
    development/test/etc type environments since your URL/etc are in the code.
    The advantage of JNDI is you only reference a logical name that is
    configured external to the WAR, making it much easier to have one build
    that can be deployed in different environments. I took a brief glance at
    Hikari and don't think it includes JNDI natively.

    mrg

    On Mon, Mar 7, 2016 at 4:03 PM, Hugi Thordarson wrote:

    Well, that was easy! Up and running in production.

    HikariConfig config = new HikariConfig();
    config.setJdbcUrl(
    "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0"
    );
    config.setUsername( “myUsername" );
    config.setPassword( “myPassword" );

    HikariDataSource dataSource = new HikariDataSource( config );
    serverRuntimeBuilder = serverRuntimeBuilder.dataSource( dataSource );

    Thanks,
    - hugi

    On 7. mar. 2016, at 20:51, Andrus Adamchik <andrus@objectstyle.org> wrote:
    Yep. Cayenne built-in pool is intentionally basic with a minimal number
    of features (Here we may be dealing with a bug though, and I'd like to fix
    it, but that's a separate issue). So yeah, using a third party DS may be a
    good idea. Here is an example how you can set it up:
    DataSource ds = // instantiate it via API specific to you DS provider

    ServerRuntime runtime =
    ServerRuntimeBuilder.builder().dataSource(ds).build();
    // of course add any other things you need to add to the builder to get
    a working Cayenne stack.
    Andrus

    On Mar 7, 2016, at 12:45 PM, Hugi Thordarson wrote:

    Thanks John! I’m going to try my hand at HikariCP.

    Are there any examples anywhere on how to configure Cayenne to use a
    third party connection pool?
    Cheers,
    - hugi



    On 7. mar. 2016, at 20:39, John Huss wrote:

    EOF can do JNDI, but that's not going to do anything to fix your
    problem.
    The connection pool in cayenne had some changes somewhat recently so
    it's
    entirely possible there are bugs.

    In practice it turns out many people don't use the connection pool
    built-in
    to Cayenne at all, and rather use a third-party connection pool, of
    which
    there are several. The cayenne one is decent, but it is very limited
    in
    functionality and less robust due to having a smaller user base and
    being a
    non-core feature.

    You can use another pool like:
    hikari <https://github.com/brettwooldridge/HikariCP> - If I was
    starting a
    new project I'd use this
    tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html>
    -
    This is what I currently use
    commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
    c3po <http://www.mchange.com/projects/c3p0/>

    The main reason I turned to a third-party connection pool was to get
    fair-scheduling which will provide connections to whoever has been
    waiting
    the longest, which helps avoid unnecessary errors caused by serving
    requests out of order.

    John

    On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <mgentry@masslight.net>
    wrote:
    Well, I'm not sure what you are using to run your web application, but
    Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups
    of DB
    connection pools. You just tell Cayenne Modeler to use JNDI lookup
    and
    give it the JNDI name, then configure the container to provide the DB
    connection.

    Is your WO application using EOF or Cayenne? Been a while since I
    used WO,
    but I'd be stunned if EOF cannot use a JNDI lookup as well.

    mrg


    On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    Hi Michael,
    does using JNDI change anything about the connection itself, isn’t it just
    a different method of looking up connection information?

    But I probably can’t use it anyway since one of the apps is a
    WebObjects
    app and doesn’t provide a JNDI service (at least I’ve never used it).

    Thanks,
    - hugi

    On 7. mar. 2016, at 19:13, Michael Gentry <mgentry@masslight.net>
    wrote:
    Hi Hugi,

    Since this appears to be a web-based application, can you switch to
    using
    JNDI?

    mrg


    On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    Hi all,
    This is still happening, even after I added a validationQuery, our
    app
    is
    dying quite frequently :(. I’m not quite sure how to debug this,
    is
    there
    any way for me to catch where connections are being opened in the
    code
    and
    at what location they’re hanging?

    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik <
    andrus@objectstyle.org>
    wrote:
    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    What does validationQuery do?
    Periodically executes for each pooled connection, and kills
    connections
    that throw during validation. So it ensures that all pooled
    connections
    are
    in a good state.
    Andrus
  • Lon Varscsak at Mar 7, 2016 at 10:18 pm
    OT: I’m planning to build jar not war…now I’m not sure how to deploy. :P

    -Lon
    On Mon, Mar 7, 2016 at 2:27 PM, Hugi Thordarson wrote:

    It looks to me like this makes it much harder to deploy your
    application in
    development/test/etc type environments since your URL/etc are in the
    code.

    Yeah, I see what you mean. We use a homebuilt property system for that
    which returns configuration based on environment. It’s not JNDI but works :)
    Unless you use Bootique, or your own property-based config mechanism.
    Is bootique worth checking out? I’m just noticing it now for the first
    time and so happens I’m looking into a new basis for our web services/APIs
    (current favorite being spark framework).
    "Make jar, not war" :)
    Ha ha ha :)

    - hugi

    On Mar 7, 2016, at 1:13 PM, Michael Gentry wrote:

    Hi Hugi,

    It looks to me like this makes it much harder to deploy your
    application in
    development/test/etc type environments since your URL/etc are in the
    code.
    The advantage of JNDI is you only reference a logical name that is
    configured external to the WAR, making it much easier to have one build
    that can be deployed in different environments. I took a brief glance
    at
    Hikari and don't think it includes JNDI natively.

    mrg

    On Mon, Mar 7, 2016 at 4:03 PM, Hugi Thordarson wrote:

    Well, that was easy! Up and running in production.

    HikariConfig config = new HikariConfig();
    config.setJdbcUrl(
    "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0"
    );
    config.setUsername( “myUsername" );
    config.setPassword( “myPassword" );

    HikariDataSource dataSource = new HikariDataSource( config );
    serverRuntimeBuilder = serverRuntimeBuilder.dataSource( dataSource );

    Thanks,
    - hugi

    On 7. mar. 2016, at 20:51, Andrus Adamchik <andrus@objectstyle.org> wrote:
    Yep. Cayenne built-in pool is intentionally basic with a minimal
    number
    of features (Here we may be dealing with a bug though, and I'd like to
    fix
    it, but that's a separate issue). So yeah, using a third party DS may
    be a
    good idea. Here is an example how you can set it up:
    DataSource ds = // instantiate it via API specific to you DS provider

    ServerRuntime runtime =
    ServerRuntimeBuilder.builder().dataSource(ds).build();
    // of course add any other things you need to add to the builder to
    get
    a working Cayenne stack.
    Andrus

    On Mar 7, 2016, at 12:45 PM, Hugi Thordarson wrote:

    Thanks John! I’m going to try my hand at HikariCP.

    Are there any examples anywhere on how to configure Cayenne to use a
    third party connection pool?
    Cheers,
    - hugi



    On 7. mar. 2016, at 20:39, John Huss wrote:

    EOF can do JNDI, but that's not going to do anything to fix your
    problem.
    The connection pool in cayenne had some changes somewhat recently so
    it's
    entirely possible there are bugs.

    In practice it turns out many people don't use the connection pool
    built-in
    to Cayenne at all, and rather use a third-party connection pool, of
    which
    there are several. The cayenne one is decent, but it is very
    limited
    in
    functionality and less robust due to having a smaller user base and
    being a
    non-core feature.

    You can use another pool like:
    hikari <https://github.com/brettwooldridge/HikariCP> - If I was
    starting a
    new project I'd use this
    tomcat-jdbc <
    https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html>
    -
    This is what I currently use
    commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
    c3po <http://www.mchange.com/projects/c3p0/>

    The main reason I turned to a third-party connection pool was to get
    fair-scheduling which will provide connections to whoever has been
    waiting
    the longest, which helps avoid unnecessary errors caused by serving
    requests out of order.

    John

    On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <
    mgentry@masslight.net>
    wrote:
    Well, I'm not sure what you are using to run your web application,
    but
    Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI
    lookups
    of DB
    connection pools. You just tell Cayenne Modeler to use JNDI lookup
    and
    give it the JNDI name, then configure the container to provide the
    DB
    connection.

    Is your WO application using EOF or Cayenne? Been a while since I
    used WO,
    but I'd be stunned if EOF cannot use a JNDI lookup as well.

    mrg


    On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    Hi Michael,
    does using JNDI change anything about the connection itself,
    isn’t it
    just
    a different method of looking up connection information?

    But I probably can’t use it anyway since one of the apps is a
    WebObjects
    app and doesn’t provide a JNDI service (at least I’ve never used
    it).
    Thanks,
    - hugi

    On 7. mar. 2016, at 19:13, Michael Gentry <mgentry@masslight.net
    wrote:
    Hi Hugi,

    Since this appears to be a web-based application, can you switch
    to
    using
    JNDI?

    mrg


    On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <
    hugi@karlmenn.is>
    wrote:
    Hi all,
    This is still happening, even after I added a validationQuery,
    our
    app
    is
    dying quite frequently :(. I’m not quite sure how to debug
    this,
    is
    there
    any way for me to catch where connections are being opened in
    the
    code
    and
    at what location they’re hanging?

    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik <
    andrus@objectstyle.org>
    wrote:
    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <
    hugi@karlmenn.is>
    wrote:
    What does validationQuery do?
    Periodically executes for each pooled connection, and kills
    connections
    that throw during validation. So it ensures that all pooled
    connections
    are
    in a good state.
    Andrus
  • Michael Gentry at Mar 7, 2016 at 10:31 pm
    Just embed Jetty in your application...

    On Mon, Mar 7, 2016 at 5:18 PM, Lon Varscsak wrote:

    OT: I’m planning to build jar not war…now I’m not sure how to deploy. :P

    -Lon
    On Mon, Mar 7, 2016 at 2:27 PM, Hugi Thordarson wrote:

    It looks to me like this makes it much harder to deploy your
    application in
    development/test/etc type environments since your URL/etc are in the
    code.

    Yeah, I see what you mean. We use a homebuilt property system for that
    which returns configuration based on environment. It’s not JNDI but
    works :)
    Unless you use Bootique, or your own property-based config mechanism.
    Is bootique worth checking out? I’m just noticing it now for the first
    time and so happens I’m looking into a new basis for our web
    services/APIs
    (current favorite being spark framework).
    "Make jar, not war" :)
    Ha ha ha :)

    - hugi

    On Mar 7, 2016, at 1:13 PM, Michael Gentry <mgentry@masslight.net>
    wrote:
    Hi Hugi,

    It looks to me like this makes it much harder to deploy your
    application in
    development/test/etc type environments since your URL/etc are in the
    code.
    The advantage of JNDI is you only reference a logical name that is
    configured external to the WAR, making it much easier to have one
    build
    that can be deployed in different environments. I took a brief glance
    at
    Hikari and don't think it includes JNDI natively.

    mrg


    On Mon, Mar 7, 2016 at 4:03 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    Well, that was easy! Up and running in production.

    HikariConfig config = new HikariConfig();
    config.setJdbcUrl(
    "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0"
    );
    config.setUsername( “myUsername" );
    config.setPassword( “myPassword" );

    HikariDataSource dataSource = new HikariDataSource( config );
    serverRuntimeBuilder = serverRuntimeBuilder.dataSource( dataSource );

    Thanks,
    - hugi

    On 7. mar. 2016, at 20:51, Andrus Adamchik <andrus@objectstyle.org> wrote:
    Yep. Cayenne built-in pool is intentionally basic with a minimal
    number
    of features (Here we may be dealing with a bug though, and I'd like
    to
    fix
    it, but that's a separate issue). So yeah, using a third party DS may
    be a
    good idea. Here is an example how you can set it up:
    DataSource ds = // instantiate it via API specific to you DS
    provider
    ServerRuntime runtime =
    ServerRuntimeBuilder.builder().dataSource(ds).build();
    // of course add any other things you need to add to the builder to
    get
    a working Cayenne stack.
    Andrus

    On Mar 7, 2016, at 12:45 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    Thanks John! I’m going to try my hand at HikariCP.

    Are there any examples anywhere on how to configure Cayenne to use
    a
    third party connection pool?
    Cheers,
    - hugi



    On 7. mar. 2016, at 20:39, John Huss wrote:

    EOF can do JNDI, but that's not going to do anything to fix your
    problem.
    The connection pool in cayenne had some changes somewhat recently
    so
    it's
    entirely possible there are bugs.

    In practice it turns out many people don't use the connection pool
    built-in
    to Cayenne at all, and rather use a third-party connection pool,
    of
    which
    there are several. The cayenne one is decent, but it is very
    limited
    in
    functionality and less robust due to having a smaller user base
    and
    being a
    non-core feature.

    You can use another pool like:
    hikari <https://github.com/brettwooldridge/HikariCP> - If I was
    starting a
    new project I'd use this
    tomcat-jdbc <
    https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html>
    -
    This is what I currently use
    commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
    c3po <http://www.mchange.com/projects/c3p0/>

    The main reason I turned to a third-party connection pool was to
    get
    fair-scheduling which will provide connections to whoever has been
    waiting
    the longest, which helps avoid unnecessary errors caused by
    serving
    requests out of order.

    John

    On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <
    mgentry@masslight.net>
    wrote:
    Well, I'm not sure what you are using to run your web
    application,
    but
    Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI
    lookups
    of DB
    connection pools. You just tell Cayenne Modeler to use JNDI
    lookup
    and
    give it the JNDI name, then configure the container to provide
    the
    DB
    connection.

    Is your WO application using EOF or Cayenne? Been a while since
    I
    used WO,
    but I'd be stunned if EOF cannot use a JNDI lookup as well.

    mrg


    On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <
    hugi@karlmenn.is>
    wrote:
    Hi Michael,
    does using JNDI change anything about the connection itself,
    isn’t it
    just
    a different method of looking up connection information?

    But I probably can’t use it anyway since one of the apps is a
    WebObjects
    app and doesn’t provide a JNDI service (at least I’ve never used
    it).
    Thanks,
    - hugi

    On 7. mar. 2016, at 19:13, Michael Gentry <
    mgentry@masslight.net
    wrote:
    Hi Hugi,

    Since this appears to be a web-based application, can you
    switch
    to
    using
    JNDI?

    mrg


    On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <
    hugi@karlmenn.is>
    wrote:
    Hi all,
    This is still happening, even after I added a validationQuery,
    our
    app
    is
    dying quite frequently :(. I’m not quite sure how to debug
    this,
    is
    there
    any way for me to catch where connections are being opened in
    the
    code
    and
    at what location they’re hanging?

    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik <
    andrus@objectstyle.org>
    wrote:
    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <
    hugi@karlmenn.is>
    wrote:
    What does validationQuery do?
    Periodically executes for each pooled connection, and kills
    connections
    that throw during validation. So it ensures that all pooled
    connections
    are
    in a good state.
    Andrus
  • Michael Gentry at Mar 7, 2016 at 10:31 pm
    http://www.eclipse.org/jetty/documentation/current/embedding-jetty.html

    (sent too soon)

    On Mon, Mar 7, 2016 at 5:30 PM, Michael Gentry wrote:

    Just embed Jetty in your application...

    On Mon, Mar 7, 2016 at 5:18 PM, Lon Varscsak wrote:

    OT: I’m planning to build jar not war…now I’m not sure how to deploy. :P

    -Lon
    On Mon, Mar 7, 2016 at 2:27 PM, Hugi Thordarson wrote:

    It looks to me like this makes it much harder to deploy your
    application in
    development/test/etc type environments since your URL/etc are in the
    code.

    Yeah, I see what you mean. We use a homebuilt property system for that
    which returns configuration based on environment. It’s not JNDI but
    works :)
    Unless you use Bootique, or your own property-based config mechanism.
    Is bootique worth checking out? I’m just noticing it now for the first
    time and so happens I’m looking into a new basis for our web
    services/APIs
    (current favorite being spark framework).
    "Make jar, not war" :)
    Ha ha ha :)

    - hugi

    On Mar 7, 2016, at 1:13 PM, Michael Gentry <mgentry@masslight.net>
    wrote:
    Hi Hugi,

    It looks to me like this makes it much harder to deploy your
    application in
    development/test/etc type environments since your URL/etc are in the
    code.
    The advantage of JNDI is you only reference a logical name that is
    configured external to the WAR, making it much easier to have one
    build
    that can be deployed in different environments. I took a brief
    glance
    at
    Hikari and don't think it includes JNDI natively.

    mrg


    On Mon, Mar 7, 2016 at 4:03 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    Well, that was easy! Up and running in production.

    HikariConfig config = new HikariConfig();
    config.setJdbcUrl(
    "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0"
    );
    config.setUsername( “myUsername" );
    config.setPassword( “myPassword" );

    HikariDataSource dataSource = new HikariDataSource( config );
    serverRuntimeBuilder = serverRuntimeBuilder.dataSource( dataSource
    );
    Thanks,
    - hugi

    On 7. mar. 2016, at 20:51, Andrus Adamchik <andrus@objectstyle.org wrote:
    Yep. Cayenne built-in pool is intentionally basic with a minimal
    number
    of features (Here we may be dealing with a bug though, and I'd like
    to
    fix
    it, but that's a separate issue). So yeah, using a third party DS
    may
    be a
    good idea. Here is an example how you can set it up:
    DataSource ds = // instantiate it via API specific to you DS
    provider
    ServerRuntime runtime =
    ServerRuntimeBuilder.builder().dataSource(ds).build();
    // of course add any other things you need to add to the builder to
    get
    a working Cayenne stack.
    Andrus

    On Mar 7, 2016, at 12:45 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    Thanks John! I’m going to try my hand at HikariCP.

    Are there any examples anywhere on how to configure Cayenne to
    use a
    third party connection pool?
    Cheers,
    - hugi



    On 7. mar. 2016, at 20:39, John Huss <johnthuss@gmail.com>
    wrote:
    EOF can do JNDI, but that's not going to do anything to fix your
    problem.
    The connection pool in cayenne had some changes somewhat
    recently so
    it's
    entirely possible there are bugs.

    In practice it turns out many people don't use the connection
    pool
    built-in
    to Cayenne at all, and rather use a third-party connection pool,
    of
    which
    there are several. The cayenne one is decent, but it is very
    limited
    in
    functionality and less robust due to having a smaller user base
    and
    being a
    non-core feature.

    You can use another pool like:
    hikari <https://github.com/brettwooldridge/HikariCP> - If I was
    starting a
    new project I'd use this
    tomcat-jdbc <
    https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html>
    -
    This is what I currently use
    commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
    c3po <http://www.mchange.com/projects/c3p0/>

    The main reason I turned to a third-party connection pool was to
    get
    fair-scheduling which will provide connections to whoever has
    been
    waiting
    the longest, which helps avoid unnecessary errors caused by
    serving
    requests out of order.

    John

    On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <
    mgentry@masslight.net>
    wrote:
    Well, I'm not sure what you are using to run your web
    application,
    but
    Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI
    lookups
    of DB
    connection pools. You just tell Cayenne Modeler to use JNDI
    lookup
    and
    give it the JNDI name, then configure the container to provide
    the
    DB
    connection.

    Is your WO application using EOF or Cayenne? Been a while
    since I
    used WO,
    but I'd be stunned if EOF cannot use a JNDI lookup as well.

    mrg


    On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <
    hugi@karlmenn.is>
    wrote:
    Hi Michael,
    does using JNDI change anything about the connection itself,
    isn’t it
    just
    a different method of looking up connection information?

    But I probably can’t use it anyway since one of the apps is a
    WebObjects
    app and doesn’t provide a JNDI service (at least I’ve never
    used
    it).
    Thanks,
    - hugi

    On 7. mar. 2016, at 19:13, Michael Gentry <
    mgentry@masslight.net
    wrote:
    Hi Hugi,

    Since this appears to be a web-based application, can you
    switch
    to
    using
    JNDI?

    mrg


    On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <
    hugi@karlmenn.is>
    wrote:
    Hi all,
    This is still happening, even after I added a
    validationQuery,
    our
    app
    is
    dying quite frequently :(. I’m not quite sure how to debug
    this,
    is
    there
    any way for me to catch where connections are being opened in
    the
    code
    and
    at what location they’re hanging?

    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik <
    andrus@objectstyle.org>
    wrote:
    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <
    hugi@karlmenn.is>
    wrote:
    What does validationQuery do?
    Periodically executes for each pooled connection, and kills
    connections
    that throw during validation. So it ensures that all pooled
    connections
    are
    in a good state.
    Andrus
  • Lon Varscsak at Mar 7, 2016 at 10:32 pm
    Well, I actually have embedded Jetty in my application. But I’m not sure
    how to manage creating instances/stoping/starting, etc. In WebObjects we
    had a tool called Monitor which would allow you to do it all on the fly. :D

    -Lon
    On Mon, Mar 7, 2016 at 3:30 PM, Michael Gentry wrote:

    http://www.eclipse.org/jetty/documentation/current/embedding-jetty.html

    (sent too soon)

    On Mon, Mar 7, 2016 at 5:30 PM, Michael Gentry wrote:

    Just embed Jetty in your application...


    On Mon, Mar 7, 2016 at 5:18 PM, Lon Varscsak <lon.varscsak@gmail.com>
    wrote:
    OT: I’m planning to build jar not war…now I’m not sure how to deploy. :P

    -Lon
    On Mon, Mar 7, 2016 at 2:27 PM, Hugi Thordarson wrote:

    It looks to me like this makes it much harder to deploy your
    application in
    development/test/etc type environments since your URL/etc are in
    the
    code.

    Yeah, I see what you mean. We use a homebuilt property system for that
    which returns configuration based on environment. It’s not JNDI but
    works :)
    Unless you use Bootique, or your own property-based config
    mechanism.
    Is bootique worth checking out? I’m just noticing it now for the first
    time and so happens I’m looking into a new basis for our web
    services/APIs
    (current favorite being spark framework).
    "Make jar, not war" :)
    Ha ha ha :)

    - hugi

    On Mar 7, 2016, at 1:13 PM, Michael Gentry <mgentry@masslight.net>
    wrote:
    Hi Hugi,

    It looks to me like this makes it much harder to deploy your
    application in
    development/test/etc type environments since your URL/etc are in
    the
    code.
    The advantage of JNDI is you only reference a logical name that is
    configured external to the WAR, making it much easier to have one
    build
    that can be deployed in different environments. I took a brief
    glance
    at
    Hikari and don't think it includes JNDI natively.

    mrg


    On Mon, Mar 7, 2016 at 4:03 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    Well, that was easy! Up and running in production.

    HikariConfig config = new HikariConfig();
    config.setJdbcUrl(
    "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0"
    );
    config.setUsername( “myUsername" );
    config.setPassword( “myPassword" );

    HikariDataSource dataSource = new HikariDataSource( config );
    serverRuntimeBuilder = serverRuntimeBuilder.dataSource( dataSource
    );
    Thanks,
    - hugi

    On 7. mar. 2016, at 20:51, Andrus Adamchik <
    andrus@objectstyle.org
    wrote:
    Yep. Cayenne built-in pool is intentionally basic with a minimal
    number
    of features (Here we may be dealing with a bug though, and I'd
    like
    to
    fix
    it, but that's a separate issue). So yeah, using a third party DS
    may
    be a
    good idea. Here is an example how you can set it up:
    DataSource ds = // instantiate it via API specific to you DS
    provider
    ServerRuntime runtime =
    ServerRuntimeBuilder.builder().dataSource(ds).build();
    // of course add any other things you need to add to the builder
    to
    get
    a working Cayenne stack.
    Andrus

    On Mar 7, 2016, at 12:45 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    Thanks John! I’m going to try my hand at HikariCP.

    Are there any examples anywhere on how to configure Cayenne to
    use a
    third party connection pool?
    Cheers,
    - hugi



    On 7. mar. 2016, at 20:39, John Huss <johnthuss@gmail.com>
    wrote:
    EOF can do JNDI, but that's not going to do anything to fix
    your
    problem.
    The connection pool in cayenne had some changes somewhat
    recently so
    it's
    entirely possible there are bugs.

    In practice it turns out many people don't use the connection
    pool
    built-in
    to Cayenne at all, and rather use a third-party connection
    pool,
    of
    which
    there are several. The cayenne one is decent, but it is very
    limited
    in
    functionality and less robust due to having a smaller user base
    and
    being a
    non-core feature.

    You can use another pool like:
    hikari <https://github.com/brettwooldridge/HikariCP> - If I
    was
    starting a
    new project I'd use this
    tomcat-jdbc <
    https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html>
    -
    This is what I currently use
    commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/
    c3po <http://www.mchange.com/projects/c3p0/>

    The main reason I turned to a third-party connection pool was
    to
    get
    fair-scheduling which will provide connections to whoever has
    been
    waiting
    the longest, which helps avoid unnecessary errors caused by
    serving
    requests out of order.

    John

    On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <
    mgentry@masslight.net>
    wrote:
    Well, I'm not sure what you are using to run your web
    application,
    but
    Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI
    lookups
    of DB
    connection pools. You just tell Cayenne Modeler to use JNDI
    lookup
    and
    give it the JNDI name, then configure the container to provide
    the
    DB
    connection.

    Is your WO application using EOF or Cayenne? Been a while
    since I
    used WO,
    but I'd be stunned if EOF cannot use a JNDI lookup as well.

    mrg


    On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <
    hugi@karlmenn.is>
    wrote:
    Hi Michael,
    does using JNDI change anything about the connection itself,
    isn’t it
    just
    a different method of looking up connection information?

    But I probably can’t use it anyway since one of the apps is a
    WebObjects
    app and doesn’t provide a JNDI service (at least I’ve never
    used
    it).
    Thanks,
    - hugi

    On 7. mar. 2016, at 19:13, Michael Gentry <
    mgentry@masslight.net
    wrote:
    Hi Hugi,

    Since this appears to be a web-based application, can you
    switch
    to
    using
    JNDI?

    mrg


    On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <
    hugi@karlmenn.is>
    wrote:
    Hi all,
    This is still happening, even after I added a
    validationQuery,
    our
    app
    is
    dying quite frequently :(. I’m not quite sure how to debug
    this,
    is
    there
    any way for me to catch where connections are being opened
    in
    the
    code
    and
    at what location they’re hanging?

    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik <
    andrus@objectstyle.org>
    wrote:
    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <
    hugi@karlmenn.is>
    wrote:
    What does validationQuery do?
    Periodically executes for each pooled connection, and
    kills
    connections
    that throw during validation. So it ensures that all pooled
    connections
    are
    in a good state.
    Andrus
  • John Huss at Mar 7, 2016 at 10:38 pm
    Amazon elastic beanstalk! On Mon, Mar 7, 2016 at 4:32 PM Lon Varscsak wrote:

    Well, I actually have embedded Jetty in my application. But I’m not sure
    how to manage creating instances/stoping/starting, etc. In WebObjects we
    had a tool called Monitor which would allow you to do it all on the fly.
    :D

    -Lon
    On Mon, Mar 7, 2016 at 3:30 PM, Michael Gentry wrote:

    http://www.eclipse.org/jetty/documentation/current/embedding-jetty.html

    (sent too soon)


    On Mon, Mar 7, 2016 at 5:30 PM, Michael Gentry <mgentry@masslight.net>
    wrote:
    Just embed Jetty in your application...


    On Mon, Mar 7, 2016 at 5:18 PM, Lon Varscsak <lon.varscsak@gmail.com>
    wrote:
    OT: I’m planning to build jar not war…now I’m not sure how to deploy.
    :P
    -Lon

    On Mon, Mar 7, 2016 at 2:27 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    It looks to me like this makes it much harder to deploy your
    application in
    development/test/etc type environments since your URL/etc are in
    the
    code.

    Yeah, I see what you mean. We use a homebuilt property system for
    that
    which returns configuration based on environment. It’s not JNDI but
    works :)
    Unless you use Bootique, or your own property-based config
    mechanism.
    Is bootique worth checking out? I’m just noticing it now for the
    first
    time and so happens I’m looking into a new basis for our web
    services/APIs
    (current favorite being spark framework).
    "Make jar, not war" :)
    Ha ha ha :)

    - hugi

    On Mar 7, 2016, at 1:13 PM, Michael Gentry <
    mgentry@masslight.net>
    wrote:
    Hi Hugi,

    It looks to me like this makes it much harder to deploy your
    application in
    development/test/etc type environments since your URL/etc are in
    the
    code.
    The advantage of JNDI is you only reference a logical name that
    is
    configured external to the WAR, making it much easier to have one
    build
    that can be deployed in different environments. I took a brief
    glance
    at
    Hikari and don't think it includes JNDI natively.

    mrg


    On Mon, Mar 7, 2016 at 4:03 PM, Hugi Thordarson <
    hugi@karlmenn.is>
    wrote:
    Well, that was easy! Up and running in production.

    HikariConfig config = new HikariConfig();
    config.setJdbcUrl(
    "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0"
    );
    config.setUsername( “myUsername" );
    config.setPassword( “myPassword" );

    HikariDataSource dataSource = new HikariDataSource( config );
    serverRuntimeBuilder = serverRuntimeBuilder.dataSource(
    dataSource
    );
    Thanks,
    - hugi

    On 7. mar. 2016, at 20:51, Andrus Adamchik <
    andrus@objectstyle.org
    wrote:
    Yep. Cayenne built-in pool is intentionally basic with a
    minimal
    number
    of features (Here we may be dealing with a bug though, and I'd
    like
    to
    fix
    it, but that's a separate issue). So yeah, using a third party
    DS
    may
    be a
    good idea. Here is an example how you can set it up:
    DataSource ds = // instantiate it via API specific to you DS
    provider
    ServerRuntime runtime =
    ServerRuntimeBuilder.builder().dataSource(ds).build();
    // of course add any other things you need to add to the
    builder
    to
    get
    a working Cayenne stack.
    Andrus

    On Mar 7, 2016, at 12:45 PM, Hugi Thordarson <
    hugi@karlmenn.is>
    wrote:
    Thanks John! I’m going to try my hand at HikariCP.

    Are there any examples anywhere on how to configure Cayenne to
    use a
    third party connection pool?
    Cheers,
    - hugi



    On 7. mar. 2016, at 20:39, John Huss <johnthuss@gmail.com>
    wrote:
    EOF can do JNDI, but that's not going to do anything to fix
    your
    problem.
    The connection pool in cayenne had some changes somewhat
    recently so
    it's
    entirely possible there are bugs.

    In practice it turns out many people don't use the connection
    pool
    built-in
    to Cayenne at all, and rather use a third-party connection
    pool,
    of
    which
    there are several. The cayenne one is decent, but it is very
    limited
    in
    functionality and less robust due to having a smaller user
    base
    and
    being a
    non-core feature.

    You can use another pool like:
    hikari <https://github.com/brettwooldridge/HikariCP> - If I
    was
    starting a
    new project I'd use this
    tomcat-jdbc <
    https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html>
    -
    This is what I currently use
    commonds-dbcp <
    https://commons.apache.org/proper/commons-dbcp/
    c3po <http://www.mchange.com/projects/c3p0/>

    The main reason I turned to a third-party connection pool was
    to
    get
    fair-scheduling which will provide connections to whoever has
    been
    waiting
    the longest, which helps avoid unnecessary errors caused by
    serving
    requests out of order.

    John

    On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <
    mgentry@masslight.net>
    wrote:
    Well, I'm not sure what you are using to run your web
    application,
    but
    Tomcat, Jetty, JBoss, etc all have mechanisms to provide
    JNDI
    lookups
    of DB
    connection pools. You just tell Cayenne Modeler to use JNDI
    lookup
    and
    give it the JNDI name, then configure the container to
    provide
    the
    DB
    connection.

    Is your WO application using EOF or Cayenne? Been a while
    since I
    used WO,
    but I'd be stunned if EOF cannot use a JNDI lookup as well.

    mrg


    On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <
    hugi@karlmenn.is>
    wrote:
    Hi Michael,
    does using JNDI change anything about the connection
    itself,
    isn’t it
    just
    a different method of looking up connection information?

    But I probably can’t use it anyway since one of the apps
    is a
    WebObjects
    app and doesn’t provide a JNDI service (at least I’ve never
    used
    it).
    Thanks,
    - hugi

    On 7. mar. 2016, at 19:13, Michael Gentry <
    mgentry@masslight.net
    wrote:
    Hi Hugi,

    Since this appears to be a web-based application, can you
    switch
    to
    using
    JNDI?

    mrg


    On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <
    hugi@karlmenn.is>
    wrote:
    Hi all,
    This is still happening, even after I added a
    validationQuery,
    our
    app
    is
    dying quite frequently :(. I’m not quite sure how to
    debug
    this,
    is
    there
    any way for me to catch where connections are being
    opened
    in
    the
    code
    and
    at what location they’re hanging?

    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik <
    andrus@objectstyle.org>
    wrote:
    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <
    hugi@karlmenn.is>
    wrote:
    What does validationQuery do?
    Periodically executes for each pooled connection, and
    kills
    connections
    that throw during validation. So it ensures that all
    pooled
    connections
    are
    in a good state.
    Andrus
  • Lon Varscsak at Mar 7, 2016 at 10:41 pm
    lol, the name makes it seem like a joke. :P Unfortunately (not really) we
    deploy internally.
    On Mon, Mar 7, 2016 at 3:38 PM, John Huss wrote:

    Amazon elastic beanstalk!
    On Mon, Mar 7, 2016 at 4:32 PM Lon Varscsak wrote:

    Well, I actually have embedded Jetty in my application. But I’m not sure
    how to manage creating instances/stoping/starting, etc. In WebObjects we
    had a tool called Monitor which would allow you to do it all on the fly.
    :D

    -Lon

    On Mon, Mar 7, 2016 at 3:30 PM, Michael Gentry <mgentry@masslight.net>
    wrote:
    http://www.eclipse.org/jetty/documentation/current/embedding-jetty.html
    (sent too soon)


    On Mon, Mar 7, 2016 at 5:30 PM, Michael Gentry <mgentry@masslight.net>
    wrote:
    Just embed Jetty in your application...


    On Mon, Mar 7, 2016 at 5:18 PM, Lon Varscsak <lon.varscsak@gmail.com
    wrote:
    OT: I’m planning to build jar not war…now I’m not sure how to
    deploy.
    :P
    -Lon

    On Mon, Mar 7, 2016 at 2:27 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    It looks to me like this makes it much harder to deploy your
    application in
    development/test/etc type environments since your URL/etc are
    in
    the
    code.

    Yeah, I see what you mean. We use a homebuilt property system for
    that
    which returns configuration based on environment. It’s not JNDI
    but
    works :)
    Unless you use Bootique, or your own property-based config
    mechanism.
    Is bootique worth checking out? I’m just noticing it now for the
    first
    time and so happens I’m looking into a new basis for our web
    services/APIs
    (current favorite being spark framework).
    "Make jar, not war" :)
    Ha ha ha :)

    - hugi

    On Mar 7, 2016, at 1:13 PM, Michael Gentry <
    mgentry@masslight.net>
    wrote:
    Hi Hugi,

    It looks to me like this makes it much harder to deploy your
    application in
    development/test/etc type environments since your URL/etc are
    in
    the
    code.
    The advantage of JNDI is you only reference a logical name that
    is
    configured external to the WAR, making it much easier to have
    one
    build
    that can be deployed in different environments. I took a brief
    glance
    at
    Hikari and don't think it includes JNDI natively.

    mrg


    On Mon, Mar 7, 2016 at 4:03 PM, Hugi Thordarson <
    hugi@karlmenn.is>
    wrote:
    Well, that was easy! Up and running in production.

    HikariConfig config = new HikariConfig();
    config.setJdbcUrl(
    "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0"
    );
    config.setUsername( “myUsername" );
    config.setPassword( “myPassword" );

    HikariDataSource dataSource = new HikariDataSource( config );
    serverRuntimeBuilder = serverRuntimeBuilder.dataSource(
    dataSource
    );
    Thanks,
    - hugi

    On 7. mar. 2016, at 20:51, Andrus Adamchik <
    andrus@objectstyle.org
    wrote:
    Yep. Cayenne built-in pool is intentionally basic with a
    minimal
    number
    of features (Here we may be dealing with a bug though, and I'd
    like
    to
    fix
    it, but that's a separate issue). So yeah, using a third party
    DS
    may
    be a
    good idea. Here is an example how you can set it up:
    DataSource ds = // instantiate it via API specific to you DS
    provider
    ServerRuntime runtime =
    ServerRuntimeBuilder.builder().dataSource(ds).build();
    // of course add any other things you need to add to the
    builder
    to
    get
    a working Cayenne stack.
    Andrus

    On Mar 7, 2016, at 12:45 PM, Hugi Thordarson <
    hugi@karlmenn.is>
    wrote:
    Thanks John! I’m going to try my hand at HikariCP.

    Are there any examples anywhere on how to configure Cayenne
    to
    use a
    third party connection pool?
    Cheers,
    - hugi



    On 7. mar. 2016, at 20:39, John Huss <johnthuss@gmail.com>
    wrote:
    EOF can do JNDI, but that's not going to do anything to fix
    your
    problem.
    The connection pool in cayenne had some changes somewhat
    recently so
    it's
    entirely possible there are bugs.

    In practice it turns out many people don't use the
    connection
    pool
    built-in
    to Cayenne at all, and rather use a third-party connection
    pool,
    of
    which
    there are several. The cayenne one is decent, but it is
    very
    limited
    in
    functionality and less robust due to having a smaller user
    base
    and
    being a
    non-core feature.

    You can use another pool like:
    hikari <https://github.com/brettwooldridge/HikariCP> - If
    I
    was
    starting a
    new project I'd use this
    tomcat-jdbc <
    https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html>
    -
    This is what I currently use
    commonds-dbcp <
    https://commons.apache.org/proper/commons-dbcp/
    c3po <http://www.mchange.com/projects/c3p0/>

    The main reason I turned to a third-party connection pool
    was
    to
    get
    fair-scheduling which will provide connections to whoever
    has
    been
    waiting
    the longest, which helps avoid unnecessary errors caused by
    serving
    requests out of order.

    John

    On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <
    mgentry@masslight.net>
    wrote:
    Well, I'm not sure what you are using to run your web
    application,
    but
    Tomcat, Jetty, JBoss, etc all have mechanisms to provide
    JNDI
    lookups
    of DB
    connection pools. You just tell Cayenne Modeler to use
    JNDI
    lookup
    and
    give it the JNDI name, then configure the container to
    provide
    the
    DB
    connection.

    Is your WO application using EOF or Cayenne? Been a while
    since I
    used WO,
    but I'd be stunned if EOF cannot use a JNDI lookup as
    well.
    mrg


    On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <
    hugi@karlmenn.is>
    wrote:
    Hi Michael,
    does using JNDI change anything about the connection
    itself,
    isn’t it
    just
    a different method of looking up connection information?

    But I probably can’t use it anyway since one of the apps
    is a
    WebObjects
    app and doesn’t provide a JNDI service (at least I’ve
    never
    used
    it).
    Thanks,
    - hugi

    On 7. mar. 2016, at 19:13, Michael Gentry <
    mgentry@masslight.net
    wrote:
    Hi Hugi,

    Since this appears to be a web-based application, can
    you
    switch
    to
    using
    JNDI?

    mrg


    On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <
    hugi@karlmenn.is>
    wrote:
    Hi all,
    This is still happening, even after I added a
    validationQuery,
    our
    app
    is
    dying quite frequently :(. I’m not quite sure how to
    debug
    this,
    is
    there
    any way for me to catch where connections are being
    opened
    in
    the
    code
    and
    at what location they’re hanging?

    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik <
    andrus@objectstyle.org>
    wrote:
    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <
    hugi@karlmenn.is>
    wrote:
    What does validationQuery do?
    Periodically executes for each pooled connection, and
    kills
    connections
    that throw during validation. So it ensures that all
    pooled
    connections
    are
    in a good state.
    Andrus
  • Andrus Adamchik at Mar 7, 2016 at 11:05 pm
    Simple bash scripts. Much easier then container deployment.

    scp my.jar my.server:/tmp
    ssh my.server java -jar /tmp/my.jar &
    ssh my.server pkill my.jar

    Andrus
    On Mar 7, 2016, at 2:41 PM, Lon Varscsak wrote:

    lol, the name makes it seem like a joke. :P Unfortunately (not really) we
    deploy internally.
    On Mon, Mar 7, 2016 at 3:38 PM, John Huss wrote:

    Amazon elastic beanstalk!
    On Mon, Mar 7, 2016 at 4:32 PM Lon Varscsak <lon.varscsak@gmail.com>
    wrote:
    Well, I actually have embedded Jetty in my application. But I’m not sure
    how to manage creating instances/stoping/starting, etc. In WebObjects we
    had a tool called Monitor which would allow you to do it all on the fly.
    :D

    -Lon

    On Mon, Mar 7, 2016 at 3:30 PM, Michael Gentry <mgentry@masslight.net>
    wrote:
    http://www.eclipse.org/jetty/documentation/current/embedding-jetty.html
    (sent too soon)


    On Mon, Mar 7, 2016 at 5:30 PM, Michael Gentry <mgentry@masslight.net>
    wrote:
    Just embed Jetty in your application...


    On Mon, Mar 7, 2016 at 5:18 PM, Lon Varscsak <lon.varscsak@gmail.com
    wrote:
    OT: I’m planning to build jar not war…now I’m not sure how to
    deploy.
    :P
    -Lon

    On Mon, Mar 7, 2016 at 2:27 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    It looks to me like this makes it much harder to deploy your
    application in
    development/test/etc type environments since your URL/etc are
    in
    the
    code.

    Yeah, I see what you mean. We use a homebuilt property system for
    that
    which returns configuration based on environment. It’s not JNDI
    but
    works :)
    Unless you use Bootique, or your own property-based config
    mechanism.
    Is bootique worth checking out? I’m just noticing it now for the
    first
    time and so happens I’m looking into a new basis for our web
    services/APIs
    (current favorite being spark framework).
    "Make jar, not war" :)
    Ha ha ha :)

    - hugi

    On Mar 7, 2016, at 1:13 PM, Michael Gentry <
    mgentry@masslight.net>
    wrote:
    Hi Hugi,

    It looks to me like this makes it much harder to deploy your
    application in
    development/test/etc type environments since your URL/etc are
    in
    the
    code.
    The advantage of JNDI is you only reference a logical name that
    is
    configured external to the WAR, making it much easier to have
    one
    build
    that can be deployed in different environments. I took a brief
    glance
    at
    Hikari and don't think it includes JNDI natively.

    mrg


    On Mon, Mar 7, 2016 at 4:03 PM, Hugi Thordarson <
    hugi@karlmenn.is>
    wrote:
    Well, that was easy! Up and running in production.

    HikariConfig config = new HikariConfig();
    config.setJdbcUrl(
    "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0"
    );
    config.setUsername( “myUsername" );
    config.setPassword( “myPassword" );

    HikariDataSource dataSource = new HikariDataSource( config );
    serverRuntimeBuilder = serverRuntimeBuilder.dataSource(
    dataSource
    );
    Thanks,
    - hugi

    On 7. mar. 2016, at 20:51, Andrus Adamchik <
    andrus@objectstyle.org
    wrote:
    Yep. Cayenne built-in pool is intentionally basic with a
    minimal
    number
    of features (Here we may be dealing with a bug though, and I'd
    like
    to
    fix
    it, but that's a separate issue). So yeah, using a third party
    DS
    may
    be a
    good idea. Here is an example how you can set it up:
    DataSource ds = // instantiate it via API specific to you DS
    provider
    ServerRuntime runtime =
    ServerRuntimeBuilder.builder().dataSource(ds).build();
    // of course add any other things you need to add to the
    builder
    to
    get
    a working Cayenne stack.
    Andrus

    On Mar 7, 2016, at 12:45 PM, Hugi Thordarson <
    hugi@karlmenn.is>
    wrote:
    Thanks John! I’m going to try my hand at HikariCP.

    Are there any examples anywhere on how to configure Cayenne
    to
    use a
    third party connection pool?
    Cheers,
    - hugi



    On 7. mar. 2016, at 20:39, John Huss <johnthuss@gmail.com>
    wrote:
    EOF can do JNDI, but that's not going to do anything to fix
    your
    problem.
    The connection pool in cayenne had some changes somewhat
    recently so
    it's
    entirely possible there are bugs.

    In practice it turns out many people don't use the
    connection
    pool
    built-in
    to Cayenne at all, and rather use a third-party connection
    pool,
    of
    which
    there are several. The cayenne one is decent, but it is
    very
    limited
    in
    functionality and less robust due to having a smaller user
    base
    and
    being a
    non-core feature.

    You can use another pool like:
    hikari <https://github.com/brettwooldridge/HikariCP> - If
    I
    was
    starting a
    new project I'd use this
    tomcat-jdbc <
    https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html>
    -
    This is what I currently use
    commonds-dbcp <
    https://commons.apache.org/proper/commons-dbcp/
    c3po <http://www.mchange.com/projects/c3p0/>

    The main reason I turned to a third-party connection pool
    was
    to
    get
    fair-scheduling which will provide connections to whoever
    has
    been
    waiting
    the longest, which helps avoid unnecessary errors caused by
    serving
    requests out of order.

    John

    On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <
    mgentry@masslight.net>
    wrote:
    Well, I'm not sure what you are using to run your web
    application,
    but
    Tomcat, Jetty, JBoss, etc all have mechanisms to provide
    JNDI
    lookups
    of DB
    connection pools. You just tell Cayenne Modeler to use
    JNDI
    lookup
    and
    give it the JNDI name, then configure the container to
    provide
    the
    DB
    connection.

    Is your WO application using EOF or Cayenne? Been a while
    since I
    used WO,
    but I'd be stunned if EOF cannot use a JNDI lookup as
    well.
    mrg


    On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <
    hugi@karlmenn.is>
    wrote:
    Hi Michael,
    does using JNDI change anything about the connection
    itself,
    isn’t it
    just
    a different method of looking up connection information?

    But I probably can’t use it anyway since one of the apps
    is a
    WebObjects
    app and doesn’t provide a JNDI service (at least I’ve
    never
    used
    it).
    Thanks,
    - hugi

    On 7. mar. 2016, at 19:13, Michael Gentry <
    mgentry@masslight.net
    wrote:
    Hi Hugi,

    Since this appears to be a web-based application, can
    you
    switch
    to
    using
    JNDI?

    mrg


    On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <
    hugi@karlmenn.is>
    wrote:
    Hi all,
    This is still happening, even after I added a
    validationQuery,
    our
    app
    is
    dying quite frequently :(. I’m not quite sure how to
    debug
    this,
    is
    there
    any way for me to catch where connections are being
    opened
    in
    the
    code
    and
    at what location they’re hanging?

    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik <
    andrus@objectstyle.org>
    wrote:
    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <
    hugi@karlmenn.is>
    wrote:
    What does validationQuery do?
    Periodically executes for each pooled connection, and
    kills
    connections
    that throw during validation. So it ensures that all
    pooled
    connections
    are
    in a good state.
    Andrus
  • Andrus Adamchik at Mar 7, 2016 at 11:15 pm

    On Mar 7, 2016, at 1:27 PM, Hugi Thordarson wrote:
    Unless you use Bootique, or your own property-based config mechanism.
    Is bootique worth checking out? I’m just noticing it now for the first time and so happens I’m looking into a new basis for our web services/APIs (current favorite being spark framework).
    Definitely. Bootique is a new project, and my hope is it will make it as far as Cayenne and further. I am doing a presentation at WOWODC this summer and at ApacheCon in May. In a few words, it is a flexible modular framework (or platform?) that allows you to build Java apps that run without containers (hence the jar/war meme that that I quoted from SpringBoo folks). It is very easy to create web services [1] and such, but also apps of any type and complexity. There's a Cayenne integration module, as well a dozen other modules (the list is quickly growing).

    For those who haven't seen it yet, we just launched a new site at http://bootique.io/ .

    Andrus

    [1] http://bootique.io/docs/0/getting-started/index.html
  • Hugi Thordarson at Mar 8, 2016 at 11:15 am

    Unless you use Bootique, or your own property-based config mechanism.
    Is bootique worth checking out? I’m just noticing it now for the first time and so happens I’m looking into a new basis for our web services/APIs (current favorite being spark framework).
    Definitely. Bootique is a new project, and my hope is it will make it as far as Cayenne and further. I am doing a presentation at WOWODC this summer and at ApacheCon in May. In a few words, it is a flexible modular framework (or platform?) that allows you to build Java apps that run without containers (hence the jar/war meme that that I quoted from SpringBoo folks). It is very easy to create web services [1] and such, but also apps of any type and complexity. There's a Cayenne integration module, as well a dozen other modules (the list is quickly growing).

    For those who haven't seen it yet, we just launched a new site at http://bootique.io/ .
    Looks nice! Definitely checking it out.

    - hugi
  • Hugi Thordarson at Mar 8, 2016 at 11:20 am
    Not quite done :).

    I have a project that uses multiple Cayenne models connected to multiple databases. The connection information is currently stored in the models and I’m constructing the ServerRuntime like this:

    ServerRuntimeBuilder b = new ServerRuntimeBuilder( "Netbokhald" );
    b.addConfig( "cayenne-core/cayenne-project.xml" );
    b.addConfig( "cayenne-reporting/cayenne-project.xml" );

    How would I go about programmatically configuring separate DataSources for each model?

    Cheers,
    - hugi


    On 7. mar. 2016, at 21:03, Hugi Thordarson wrote:

    Well, that was easy! Up and running in production.

    HikariConfig config = new HikariConfig();
    config.setJdbcUrl( "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0" );
    config.setUsername( “myUsername" );
    config.setPassword( “myPassword" );

    HikariDataSource dataSource = new HikariDataSource( config );
    serverRuntimeBuilder = serverRuntimeBuilder.dataSource( dataSource );

    Thanks,
    - hugi

    On 7. mar. 2016, at 20:51, Andrus Adamchik wrote:

    Yep. Cayenne built-in pool is intentionally basic with a minimal number of features (Here we may be dealing with a bug though, and I'd like to fix it, but that's a separate issue). So yeah, using a third party DS may be a good idea. Here is an example how you can set it up:

    DataSource ds = // instantiate it via API specific to you DS provider

    ServerRuntime runtime = ServerRuntimeBuilder.builder().dataSource(ds).build();
    // of course add any other things you need to add to the builder to get a working Cayenne stack.

    Andrus

    On Mar 7, 2016, at 12:45 PM, Hugi Thordarson wrote:

    Thanks John! I’m going to try my hand at HikariCP.

    Are there any examples anywhere on how to configure Cayenne to use a third party connection pool?

    Cheers,
    - hugi



    On 7. mar. 2016, at 20:39, John Huss wrote:

    EOF can do JNDI, but that's not going to do anything to fix your problem.

    The connection pool in cayenne had some changes somewhat recently so it's
    entirely possible there are bugs.

    In practice it turns out many people don't use the connection pool built-in
    to Cayenne at all, and rather use a third-party connection pool, of which
    there are several. The cayenne one is decent, but it is very limited in
    functionality and less robust due to having a smaller user base and being a
    non-core feature.

    You can use another pool like:
    hikari <https://github.com/brettwooldridge/HikariCP> - If I was starting a
    new project I'd use this
    tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html> -
    This is what I currently use
    commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
    c3po <http://www.mchange.com/projects/c3p0/>

    The main reason I turned to a third-party connection pool was to get
    fair-scheduling which will provide connections to whoever has been waiting
    the longest, which helps avoid unnecessary errors caused by serving
    requests out of order.

    John
    On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry wrote:

    Well, I'm not sure what you are using to run your web application, but
    Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups of DB
    connection pools. You just tell Cayenne Modeler to use JNDI lookup and
    give it the JNDI name, then configure the container to provide the DB
    connection.

    Is your WO application using EOF or Cayenne? Been a while since I used WO,
    but I'd be stunned if EOF cannot use a JNDI lookup as well.

    mrg

    On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson wrote:

    Hi Michael,
    does using JNDI change anything about the connection itself, isn’t it just
    a different method of looking up connection information?

    But I probably can’t use it anyway since one of the apps is a WebObjects
    app and doesn’t provide a JNDI service (at least I’ve never used it).

    Thanks,
    - hugi

    On 7. mar. 2016, at 19:13, Michael Gentry <mgentry@masslight.net>
    wrote:
    Hi Hugi,

    Since this appears to be a web-based application, can you switch to
    using
    JNDI?

    mrg


    On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    Hi all,
    This is still happening, even after I added a validationQuery, our app
    is
    dying quite frequently :(. I’m not quite sure how to debug this, is
    there
    any way for me to catch where connections are being opened in the code
    and
    at what location they’re hanging?

    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik <andrus@objectstyle.org>
    wrote:
    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    What does validationQuery do?
    Periodically executes for each pooled connection, and kills
    connections
    that throw during validation. So it ensures that all pooled
    connections
    are
    in a good state.
    Andrus
  • Andrus Adamchik at Mar 8, 2016 at 2:37 pm
    Also pretty easy - define a custom DataSourceFactory:

    builder.addModule(b -> b.bind(DataSourceFactory.class).to(MyImpl.class));

    Andrus
    On Mar 8, 2016, at 3:20 AM, Hugi Thordarson wrote:

    Not quite done :).

    I have a project that uses multiple Cayenne models connected to multiple databases. The connection information is currently stored in the models and I’m constructing the ServerRuntime like this:

    ServerRuntimeBuilder b = new ServerRuntimeBuilder( "Netbokhald" );
    b.addConfig( "cayenne-core/cayenne-project.xml" );
    b.addConfig( "cayenne-reporting/cayenne-project.xml" );

    How would I go about programmatically configuring separate DataSources for each model?

    Cheers,
    - hugi


    On 7. mar. 2016, at 21:03, Hugi Thordarson wrote:

    Well, that was easy! Up and running in production.

    HikariConfig config = new HikariConfig();
    config.setJdbcUrl( "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0" );
    config.setUsername( “myUsername" );
    config.setPassword( “myPassword" );

    HikariDataSource dataSource = new HikariDataSource( config );
    serverRuntimeBuilder = serverRuntimeBuilder.dataSource( dataSource );

    Thanks,
    - hugi

    On 7. mar. 2016, at 20:51, Andrus Adamchik wrote:

    Yep. Cayenne built-in pool is intentionally basic with a minimal number of features (Here we may be dealing with a bug though, and I'd like to fix it, but that's a separate issue). So yeah, using a third party DS may be a good idea. Here is an example how you can set it up:

    DataSource ds = // instantiate it via API specific to you DS provider

    ServerRuntime runtime = ServerRuntimeBuilder.builder().dataSource(ds).build();
    // of course add any other things you need to add to the builder to get a working Cayenne stack.

    Andrus

    On Mar 7, 2016, at 12:45 PM, Hugi Thordarson wrote:

    Thanks John! I’m going to try my hand at HikariCP.

    Are there any examples anywhere on how to configure Cayenne to use a third party connection pool?

    Cheers,
    - hugi



    On 7. mar. 2016, at 20:39, John Huss wrote:

    EOF can do JNDI, but that's not going to do anything to fix your problem.

    The connection pool in cayenne had some changes somewhat recently so it's
    entirely possible there are bugs.

    In practice it turns out many people don't use the connection pool built-in
    to Cayenne at all, and rather use a third-party connection pool, of which
    there are several. The cayenne one is decent, but it is very limited in
    functionality and less robust due to having a smaller user base and being a
    non-core feature.

    You can use another pool like:
    hikari <https://github.com/brettwooldridge/HikariCP> - If I was starting a
    new project I'd use this
    tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html> -
    This is what I currently use
    commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
    c3po <http://www.mchange.com/projects/c3p0/>

    The main reason I turned to a third-party connection pool was to get
    fair-scheduling which will provide connections to whoever has been waiting
    the longest, which helps avoid unnecessary errors caused by serving
    requests out of order.

    John
    On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry wrote:

    Well, I'm not sure what you are using to run your web application, but
    Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups of DB
    connection pools. You just tell Cayenne Modeler to use JNDI lookup and
    give it the JNDI name, then configure the container to provide the DB
    connection.

    Is your WO application using EOF or Cayenne? Been a while since I used WO,
    but I'd be stunned if EOF cannot use a JNDI lookup as well.

    mrg

    On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson wrote:

    Hi Michael,
    does using JNDI change anything about the connection itself, isn’t it just
    a different method of looking up connection information?

    But I probably can’t use it anyway since one of the apps is a WebObjects
    app and doesn’t provide a JNDI service (at least I’ve never used it).

    Thanks,
    - hugi

    On 7. mar. 2016, at 19:13, Michael Gentry <mgentry@masslight.net>
    wrote:
    Hi Hugi,

    Since this appears to be a web-based application, can you switch to
    using
    JNDI?

    mrg


    On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    Hi all,
    This is still happening, even after I added a validationQuery, our app
    is
    dying quite frequently :(. I’m not quite sure how to debug this, is
    there
    any way for me to catch where connections are being opened in the code
    and
    at what location they’re hanging?

    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik <andrus@objectstyle.org>
    wrote:
    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    What does validationQuery do?
    Periodically executes for each pooled connection, and kills
    connections
    that throw during validation. So it ensures that all pooled
    connections
    are
    in a good state.
    Andrus
  • Hugi Thordarson at Mar 9, 2016 at 8:52 am
    Nice, works like a charm :).

    On a side note, websites that I’ve switched to HikariCP have been up since the switch, so it does seem to have been a problem with Cayenne’s connection pool.

    Also, the websites I’ve switched over feel like they’ve had a caffeine enema or something of the ilk. They feel vastly faster in many cases. But that may also have something to do with configuration (HikariCP has great pages about DB specific configuration for the most common DBs).

    https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration

    Cheers,
    - hugi


    On 8. mar. 2016, at 14:37, Andrus Adamchik wrote:

    Also pretty easy - define a custom DataSourceFactory:

    builder.addModule(b -> b.bind(DataSourceFactory.class).to(MyImpl.class));

    Andrus
    On Mar 8, 2016, at 3:20 AM, Hugi Thordarson wrote:

    Not quite done :).

    I have a project that uses multiple Cayenne models connected to multiple databases. The connection information is currently stored in the models and I’m constructing the ServerRuntime like this:

    ServerRuntimeBuilder b = new ServerRuntimeBuilder( "Netbokhald" );
    b.addConfig( "cayenne-core/cayenne-project.xml" );
    b.addConfig( "cayenne-reporting/cayenne-project.xml" );

    How would I go about programmatically configuring separate DataSources for each model?

    Cheers,
    - hugi


    On 7. mar. 2016, at 21:03, Hugi Thordarson wrote:

    Well, that was easy! Up and running in production.

    HikariConfig config = new HikariConfig();
    config.setJdbcUrl( "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0" );
    config.setUsername( “myUsername" );
    config.setPassword( “myPassword" );

    HikariDataSource dataSource = new HikariDataSource( config );
    serverRuntimeBuilder = serverRuntimeBuilder.dataSource( dataSource );

    Thanks,
    - hugi

    On 7. mar. 2016, at 20:51, Andrus Adamchik wrote:

    Yep. Cayenne built-in pool is intentionally basic with a minimal number of features (Here we may be dealing with a bug though, and I'd like to fix it, but that's a separate issue). So yeah, using a third party DS may be a good idea. Here is an example how you can set it up:

    DataSource ds = // instantiate it via API specific to you DS provider

    ServerRuntime runtime = ServerRuntimeBuilder.builder().dataSource(ds).build();
    // of course add any other things you need to add to the builder to get a working Cayenne stack.

    Andrus

    On Mar 7, 2016, at 12:45 PM, Hugi Thordarson wrote:

    Thanks John! I’m going to try my hand at HikariCP.

    Are there any examples anywhere on how to configure Cayenne to use a third party connection pool?

    Cheers,
    - hugi



    On 7. mar. 2016, at 20:39, John Huss wrote:

    EOF can do JNDI, but that's not going to do anything to fix your problem.

    The connection pool in cayenne had some changes somewhat recently so it's
    entirely possible there are bugs.

    In practice it turns out many people don't use the connection pool built-in
    to Cayenne at all, and rather use a third-party connection pool, of which
    there are several. The cayenne one is decent, but it is very limited in
    functionality and less robust due to having a smaller user base and being a
    non-core feature.

    You can use another pool like:
    hikari <https://github.com/brettwooldridge/HikariCP> - If I was starting a
    new project I'd use this
    tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html> -
    This is what I currently use
    commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
    c3po <http://www.mchange.com/projects/c3p0/>

    The main reason I turned to a third-party connection pool was to get
    fair-scheduling which will provide connections to whoever has been waiting
    the longest, which helps avoid unnecessary errors caused by serving
    requests out of order.

    John
    On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry wrote:

    Well, I'm not sure what you are using to run your web application, but
    Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups of DB
    connection pools. You just tell Cayenne Modeler to use JNDI lookup and
    give it the JNDI name, then configure the container to provide the DB
    connection.

    Is your WO application using EOF or Cayenne? Been a while since I used WO,
    but I'd be stunned if EOF cannot use a JNDI lookup as well.

    mrg

    On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson wrote:

    Hi Michael,
    does using JNDI change anything about the connection itself, isn’t it just
    a different method of looking up connection information?

    But I probably can’t use it anyway since one of the apps is a WebObjects
    app and doesn’t provide a JNDI service (at least I’ve never used it).

    Thanks,
    - hugi

    On 7. mar. 2016, at 19:13, Michael Gentry <mgentry@masslight.net>
    wrote:
    Hi Hugi,

    Since this appears to be a web-based application, can you switch to
    using
    JNDI?

    mrg


    On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    Hi all,
    This is still happening, even after I added a validationQuery, our app
    is
    dying quite frequently :(. I’m not quite sure how to debug this, is
    there
    any way for me to catch where connections are being opened in the code
    and
    at what location they’re hanging?

    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik <andrus@objectstyle.org>
    wrote:
    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    What does validationQuery do?
    Periodically executes for each pooled connection, and kills
    connections
    that throw during validation. So it ensures that all pooled
    connections
    are
    in a good state.
    Andrus
  • Andrus Adamchik at Mar 9, 2016 at 1:34 pm

    On Mar 9, 2016, at 12:52 AM, Hugi Thordarson wrote:

    Nice, works like a charm :).

    On a side note, websites that I’ve switched to HikariCP have been up since the switch, so it does seem to have been a problem with Cayenne’s connection pool.
    Yeah, I'll jira that. Will need to investigate.
    Also, the websites I’ve switched over feel like they’ve had a caffeine enema or something of the ilk. They feel vastly faster in many cases. But that may also have something to do with configuration (HikariCP has great pages about DB specific configuration for the most common DBs).

    https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration
    Nice. So perhaps their claims at http://brettwooldridge.github.io/HikariCP/ are true after all :)

    Andrus
  • Andrus Adamchik at Mar 9, 2016 at 7:41 pm

    On Mar 9, 2016, at 7:34 AM, Andrus Adamchik wrote:
    On Mar 9, 2016, at 12:52 AM, Hugi Thordarson wrote:

    Nice, works like a charm :).

    On a side note, websites that I’ve switched to HikariCP have been up since the switch, so it does seem to have been a problem with Cayenne’s connection pool.
    Yeah, I'll jira that. Will need to investigate.
    The problem wasn't what I originally thought it was. Instead what happened is this: at the moments when the DB was down, UnmanagedPoolingDataSource.createUnchecked(..) would decrement a semaphore controlling max pool size without creating a connection. So any DB hiccup would result in permanent pool shrinkage.

    Just fixed it per https://issues.apache.org/jira/browse/CAY-2067 .

    (Lack of) fair scheduling limitation mentioned by John still exists. So when there is a contention, failure rate may be higher then it would be with fair scheduling (I observed this in my unit tests, even though I wasn't specifically testing this condition). Shouldn't be an issue if the pool has enough connections.

    Still a third party pool is probably a better choice for production. Like I said, our pool is intentionally basic.

    Andrus
  • Lon Varscsak at Mar 9, 2016 at 8:51 pm
    This was a great thread (even though I tried to hijack it :P). I’m now
    using Hikari too. :D

    -Lon
    On Wed, Mar 9, 2016 at 12:40 PM, Andrus Adamchik wrote:

    On Mar 9, 2016, at 7:34 AM, Andrus Adamchik wrote:


    On Mar 9, 2016, at 12:52 AM, Hugi Thordarson wrote:

    Nice, works like a charm :).

    On a side note, websites that I’ve switched to HikariCP have been up
    since the switch, so it does seem to have been a problem with Cayenne’s
    connection pool.
    Yeah, I'll jira that. Will need to investigate.
    The problem wasn't what I originally thought it was. Instead what happened
    is this: at the moments when the DB was down,
    UnmanagedPoolingDataSource.createUnchecked(..) would decrement a semaphore
    controlling max pool size without creating a connection. So any DB hiccup
    would result in permanent pool shrinkage.

    Just fixed it per https://issues.apache.org/jira/browse/CAY-2067 .

    (Lack of) fair scheduling limitation mentioned by John still exists. So
    when there is a contention, failure rate may be higher then it would be
    with fair scheduling (I observed this in my unit tests, even though I
    wasn't specifically testing this condition). Shouldn't be an issue if the
    pool has enough connections.

    Still a third party pool is probably a better choice for production. Like
    I said, our pool is intentionally basic.

    Andrus
  • Michael Gentry at Mar 7, 2016 at 8:55 pm
    Cayenne is pretty easy. In Cayenne Modeler, under the DataNode
    configuration, select the JNDI DataSource Factory option and give it a name
    like "jdbc/myDataSource".

    Configuring Tomcat/Jetty/etc is a bit harder, but plenty of examples out
    there. Which container are you using?

    On Mon, Mar 7, 2016 at 3:45 PM, Hugi Thordarson wrote:

    Thanks John! I’m going to try my hand at HikariCP.

    Are there any examples anywhere on how to configure Cayenne to use a third
    party connection pool?

    Cheers,
    - hugi



    On 7. mar. 2016, at 20:39, John Huss wrote:

    EOF can do JNDI, but that's not going to do anything to fix your problem.

    The connection pool in cayenne had some changes somewhat recently so it's
    entirely possible there are bugs.

    In practice it turns out many people don't use the connection pool built-in
    to Cayenne at all, and rather use a third-party connection pool, of which
    there are several. The cayenne one is decent, but it is very limited in
    functionality and less robust due to having a smaller user base and being a
    non-core feature.

    You can use another pool like:
    hikari <https://github.com/brettwooldridge/HikariCP> - If I was
    starting a
    new project I'd use this
    tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html> -
    This is what I currently use
    commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
    c3po <http://www.mchange.com/projects/c3p0/>

    The main reason I turned to a third-party connection pool was to get
    fair-scheduling which will provide connections to whoever has been waiting
    the longest, which helps avoid unnecessary errors caused by serving
    requests out of order.

    John
    On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry wrote:

    Well, I'm not sure what you are using to run your web application, but
    Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups
    of DB
    connection pools. You just tell Cayenne Modeler to use JNDI lookup and
    give it the JNDI name, then configure the container to provide the DB
    connection.

    Is your WO application using EOF or Cayenne? Been a while since I used
    WO,
    but I'd be stunned if EOF cannot use a JNDI lookup as well.

    mrg

    On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson wrote:

    Hi Michael,
    does using JNDI change anything about the connection itself, isn’t it just
    a different method of looking up connection information?

    But I probably can’t use it anyway since one of the apps is a
    WebObjects
    app and doesn’t provide a JNDI service (at least I’ve never used it).

    Thanks,
    - hugi

    On 7. mar. 2016, at 19:13, Michael Gentry <mgentry@masslight.net>
    wrote:
    Hi Hugi,

    Since this appears to be a web-based application, can you switch to
    using
    JNDI?

    mrg


    On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    Hi all,
    This is still happening, even after I added a validationQuery, our
    app
    is
    dying quite frequently :(. I’m not quite sure how to debug this, is
    there
    any way for me to catch where connections are being opened in the
    code
    and
    at what location they’re hanging?

    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik <andrus@objectstyle.org
    wrote:
    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    What does validationQuery do?
    Periodically executes for each pooled connection, and kills
    connections
    that throw during validation. So it ensures that all pooled
    connections
    are
    in a good state.
    Andrus
  • Hugi Thordarson at Mar 7, 2016 at 9:06 pm
    Thanks Michael, I chose to do this programmatically since I don’t think WO provides JNDI lookup (and my WO applications don’t run inside a container).
    EOF does allow you to use JNDI, but I haven’t seen that used unless you’re running the WO application inside a container.

    Cheers,
    - hugi

    On 7. mar. 2016, at 20:54, Michael Gentry wrote:

    Cayenne is pretty easy. In Cayenne Modeler, under the DataNode
    configuration, select the JNDI DataSource Factory option and give it a name
    like "jdbc/myDataSource".

    Configuring Tomcat/Jetty/etc is a bit harder, but plenty of examples out
    there. Which container are you using?

    On Mon, Mar 7, 2016 at 3:45 PM, Hugi Thordarson wrote:

    Thanks John! I’m going to try my hand at HikariCP.

    Are there any examples anywhere on how to configure Cayenne to use a third
    party connection pool?

    Cheers,
    - hugi



    On 7. mar. 2016, at 20:39, John Huss wrote:

    EOF can do JNDI, but that's not going to do anything to fix your problem.

    The connection pool in cayenne had some changes somewhat recently so it's
    entirely possible there are bugs.

    In practice it turns out many people don't use the connection pool built-in
    to Cayenne at all, and rather use a third-party connection pool, of which
    there are several. The cayenne one is decent, but it is very limited in
    functionality and less robust due to having a smaller user base and being a
    non-core feature.

    You can use another pool like:
    hikari <https://github.com/brettwooldridge/HikariCP> - If I was
    starting a
    new project I'd use this
    tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html> -
    This is what I currently use
    commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
    c3po <http://www.mchange.com/projects/c3p0/>

    The main reason I turned to a third-party connection pool was to get
    fair-scheduling which will provide connections to whoever has been waiting
    the longest, which helps avoid unnecessary errors caused by serving
    requests out of order.

    John

    On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <mgentry@masslight.net>
    wrote:
    Well, I'm not sure what you are using to run your web application, but
    Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups
    of DB
    connection pools. You just tell Cayenne Modeler to use JNDI lookup and
    give it the JNDI name, then configure the container to provide the DB
    connection.

    Is your WO application using EOF or Cayenne? Been a while since I used
    WO,
    but I'd be stunned if EOF cannot use a JNDI lookup as well.

    mrg


    On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    Hi Michael,
    does using JNDI change anything about the connection itself, isn’t it just
    a different method of looking up connection information?

    But I probably can’t use it anyway since one of the apps is a
    WebObjects
    app and doesn’t provide a JNDI service (at least I’ve never used it).

    Thanks,
    - hugi

    On 7. mar. 2016, at 19:13, Michael Gentry <mgentry@masslight.net>
    wrote:
    Hi Hugi,

    Since this appears to be a web-based application, can you switch to
    using
    JNDI?

    mrg


    On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    Hi all,
    This is still happening, even after I added a validationQuery, our
    app
    is
    dying quite frequently :(. I’m not quite sure how to debug this, is
    there
    any way for me to catch where connections are being opened in the
    code
    and
    at what location they’re hanging?

    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik <andrus@objectstyle.org
    wrote:
    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    What does validationQuery do?
    Periodically executes for each pooled connection, and kills
    connections
    that throw during validation. So it ensures that all pooled
    connections
    are
    in a good state.
    Andrus
  • Michael Gentry at Mar 7, 2016 at 8:46 pm
    I looked at the built-in Cayenne connection pooling years ago and it was
    OK, but I felt a third-party one would be more reliable and handle error
    conditions better. I've always used Apache Commons DBCP with Jetty/Tomcat
    and it seems to work fine, but I haven't explored other external providers.

    On Mon, Mar 7, 2016 at 3:39 PM, John Huss wrote:

    EOF can do JNDI, but that's not going to do anything to fix your problem.

    The connection pool in cayenne had some changes somewhat recently so it's
    entirely possible there are bugs.

    In practice it turns out many people don't use the connection pool built-in
    to Cayenne at all, and rather use a third-party connection pool, of which
    there are several. The cayenne one is decent, but it is very limited in
    functionality and less robust due to having a smaller user base and being a
    non-core feature.

    You can use another pool like:
    hikari <https://github.com/brettwooldridge/HikariCP> - If I was starting a
    new project I'd use this
    tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html> -
    This is what I currently use
    commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
    c3po <http://www.mchange.com/projects/c3p0/>

    The main reason I turned to a third-party connection pool was to get
    fair-scheduling which will provide connections to whoever has been waiting
    the longest, which helps avoid unnecessary errors caused by serving
    requests out of order.

    John
    On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry wrote:

    Well, I'm not sure what you are using to run your web application, but
    Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups of DB
    connection pools. You just tell Cayenne Modeler to use JNDI lookup and
    give it the JNDI name, then configure the container to provide the DB
    connection.

    Is your WO application using EOF or Cayenne? Been a while since I used WO,
    but I'd be stunned if EOF cannot use a JNDI lookup as well.

    mrg

    On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson wrote:

    Hi Michael,
    does using JNDI change anything about the connection itself, isn’t it just
    a different method of looking up connection information?

    But I probably can’t use it anyway since one of the apps is a
    WebObjects
    app and doesn’t provide a JNDI service (at least I’ve never used it).

    Thanks,
    - hugi

    On 7. mar. 2016, at 19:13, Michael Gentry <mgentry@masslight.net>
    wrote:
    Hi Hugi,

    Since this appears to be a web-based application, can you switch to
    using
    JNDI?

    mrg


    On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    Hi all,
    This is still happening, even after I added a validationQuery, our
    app
    is
    dying quite frequently :(. I’m not quite sure how to debug this, is
    there
    any way for me to catch where connections are being opened in the
    code
    and
    at what location they’re hanging?

    https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
    Cheer,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/
    // s. 895-6688


    On 29. feb. 2016, at 11:25, Andrus Adamchik <
    andrus@objectstyle.org>
    wrote:
    On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hugi@karlmenn.is>
    wrote:
    What does validationQuery do?
    Periodically executes for each pooled connection, and kills
    connections
    that throw during validation. So it ensures that all pooled
    connections
    are
    in a good state.
    Andrus
  • Aristedes Maniatis at Feb 29, 2016 at 10:59 am

    On 29/02/2016 9:53pm, Hugi Thordarson wrote:
    Hi all.
    We had some DB problems last night (MariaDB with the ConnectorJ driver). As soon as I had started the DB back up, our EOF applications were up and running, but the Cayenne apps were still down and required a restart to start running again.

    Is there any way to tell Cayenne to reconnect to the DB after an event like this?
    This should be a property of your JDBC adaptor, not Cayenne. Something like autoReconnect=true in the connection string.

    Ari




    --
    -------------------------->
    Aristedes Maniatis
    GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriescayenne
postedFeb 29, '16 at 10:54a
activeMar 9, '16 at 8:51p
posts43
users6
websitecayenne.apache.org

People

Translate

site design / logo © 2021 Grokbase