users@jersey.java.net

Re: [Jersey] Tests eating up too many connections

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Fri, 20 Aug 2010 11:53:34 +0200

Hi Gary,

The GF embedded support is still work in progress, Pavel/Jon are
working on that and can give a status update.

The general pattern for Grizzly tests are that the server will start
and stop for each test. We realize this is not always ideal and Pavel
has some ideas on how to resolve this for developers who do not want/
require such functionality.

What version of Jersey and Grizzly are you using?

Are you managing the JDBC connections yourself or letting Spring do it?

This could perhaps be a Spring/Grizzly integration issue with Grizzly
not communicating shutdown properly? Or maybe hibernate is caching the
connections because all tests are in the same process?

The only other suggestion i can think if this is a blocking issue is
to move to using Jetty with maven and run the tests configured to the
external test container.

Paul.

On Aug 19, 2010, at 5:24 PM, Gary Moore wrote:

> Hey all,
>
> Been stumped on this for a couple of weeks. I have a problem where my
> container tests, when run all together as a suite (or mvn test) eat up
> too many connections to the database. Eventually the DB runs out of
> connections and starts refusing.
>
> This isn't a Hibernate pooling problem. We've tested the app under
> load when deployed to an external container. Connection levels are
> reasonable there.
>
> Usually see something like this for each method in each test
>
> INFO: Starting the Grizzly Web Container...
> Aug 19, 2010 11:01:46 AM
> com.sun.grizzly.http.servlet.ServletContextImpl log
> INFO: Initializing Spring root WebApplicationContext
> 171414 [main] INFO
> org.hibernate.connection.DriverManagerConnectionProvider - Using
> Hibernate built-in connection pool (not for production use!)
> 171414 [main] INFO
> org.hibernate.connection.DriverManagerConnectionProvider - Hibernate
> connection pool size: 20
> 171414 [main] INFO
> org.hibernate.connection.DriverManagerConnectionProvider - autocommit
> mode: true
> 171414 [main] INFO
> org.hibernate.connection.DriverManagerConnectionProvider - using
> driver: com.mysql.jdbc.Driver at URL:
> jdbc:mysql://localhost/ATHENA-Tix
> 171414 [main] INFO
> org.hibernate.connection.DriverManagerConnectionProvider - connection
> properties: {user=root, password=****, autocommit=true,
> release_mode=auto}
> (snip...)
> Aug 19, 2010 11:01:40 AM
> com
> .sun
> .jersey
> .test
> .framework.spi.container.grizzly.web.GrizzlyWebTestContainerFactory
> $GrizzlyWebTestContainer
> stop
> INFO: Stopping the Grizzly Web Container...
> Aug 19, 2010 11:01:41 AM
> com.sun.grizzly.http.servlet.ServletContextImpl log
> INFO: Closing Spring root WebApplicationContext
> 164441 [main] INFO org.hibernate.impl.SessionFactoryImpl - closing
> 164441 [main] INFO
> org.hibernate.connection.DriverManagerConnectionProvider - cleaning up
> connection pool: jdbc:mysql://localhost/ATHENA-Tix
>
> This looks to me like it is initializing a new connection pool in each
> method and somehow they aren't getting cleaned up properly.
>
> I've tried running the tests with
>
> mvn test -
> Dtest
> .containerFactory
> =
> com
> .sun
> .jersey
> .test
> .framework
> .spi.container.external.EmbeddedGlassFishTestContainerFactory
>
> which didn't appear to work. The tests still used Grizzly.
>
> Our project is open source, you can find the code on Github.
>
> Pom: http://github.com/fracturedatlas/parakeet/blob/master/pom.xml
> persistence.xml:
> http://github.com/fracturedatlas/parakeet/blob/master/src/main/resources/META-INF/persistence.xml
> Our test setup:
> http://github.com/fracturedatlas/parakeet/blob/master/src/test/java/org/fracturedatlas/athena/tix/util/BaseTixContainerTest.java
> Sample test: http://github.com/fracturedatlas/parakeet/blob/master/src/test/java/org/fracturedatlas/athena/tix/resource/container/SaveTicketContainerTest.java
>
> Any suggestions?
>
> Thanks much,
> Gary
>
> --
> Gary Moore
> http://www.gmoore.net
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>