dimanche 31 mai 2015

Oops: PersistenceException. How to properly configure Play 1.3?

When I working with my application I often get the following exception:

Oops: PersistenceException An unexpected error occured caused by exception PersistenceException: org.hibernate.exception.GenericJDBCException: Could not open connection

This exception has been logged with id 6mb2ocokg

... 6 more Caused by: java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.
        at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:118)
        at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:77)
        at org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:141)
        at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:301)
        at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:214)
        ... 11 more Caused by: com.mchange.v2.resourcepool.TimeoutException: A client timed out while waiting to acquire a resource from com.mchange.v2.resourcepool.BasicResourcePool@42623a9d -- timeout at awaitAvailable()
        at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1461)
        at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:639)
        at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:549)
        ... 14 more

Just a few requests and my application stop working... I want to ask how to properly configure Play application?

Maybe I need to use DTO pattern before rendering? I'm asked about it here -

Do I need to use DTO in Play Framework before data rendering?

My application.conf (relevant part):

# This is the main configuration file for the application.
# ~~~~~


# Application mode
# ~~~~~
# Set to dev to enable instant reloading and other development help.
# Otherwise set to prod.
application.mode=dev
%prod.application.mode=prod

# Server configuration
# ~~~~~
# If you need to change the HTTP port, uncomment this (default is set to 9000)
# http.port=9000

http.port=80


# Session configuration
# ~~~~~~~~~~~~~~~~~~~~~~
# By default, session will be written to the transient PLAY_SESSION cookie.
# The cookies are not secured by default, only set it to true
# if you're serving your pages through https.
# application.session.cookie=PLAY
# application.session.maxAge=1h
# application.session.secure=false


# JVM configuration
# ~~~~~
# Define which port is used by JPDA when application is in debug mode (default is set to 8000)
# jpda.port=8000
jpda.port=8080
#
# Java source level => 1.6, 1.7 or 1.8 (experimental)
# java.source=1.6


# Database configuration
# ~~~~~ 
# Enable a database engine if needed.
#
# To quickly set up a development database, use either:
#   - mem : for a transient in memory database (H2 in memory)
#   - fs  : for a simple file written database (H2 file stored)
# db.default=mem
#
# To connect to a local MySQL5 database, use:
# db.default=mysql://user:pwd@host/database
#
# To connect to a local PostgreSQL9 database, use:
# db=postgres://user:pwd@host/database
#
# If you need a full JDBC configuration use the following :
# db.default.url=jdbc:postgresql:database_name
# db.default.driver=org.postgresql.Driver
# db.default.user=root
# db.default.pass=secret
#
# Connections pool configuration :
# db.default.pool.timeout=1000
# db.default.pool.maxSize=30
# db.default.pool.minSize=10
#
# If you want to reuse an existing Datasource from your application server, use:
# db.default=java:/comp/env/jdbc/myDatasource
#
# When using an existing Datasource, it's sometimes needed to destroy it when
# the application is stopped. Depending on the datasource, you can define a
# generic "destroy" method :
# db.default.destroyMethod=close


########### db.default.logStatements=true
########### logger.org.hibernate=DEBUG


# JPA Configuration (Hibernate)
# ~~~~~
#
# Specify the custom JPA dialect to use here (default to guess):
# jpa.default.dialect=org.hibernate.dialect.PostgreSQLDialect
#
# Specify the ddl generation pattern to use. Set to none to disable it 
# (default to update in DEV mode, and none in PROD mode):
# jpa.default.ddl=update
#
# Debug SQL statements (logged using DEBUG level):
# jpa.default.debugSQL=true
#
# You can even specify additional hibernate properties here:
# default.hibernate.use_sql_comments=true
# ...
#
# Store path for Blob content
attachments.path=data/attachments

# Memcached configuration
# ~~~~~ 
# Enable memcached if needed. Otherwise a local cache is used.
# memcached=enabled
#
# Specify memcached host (default to 127.0.0.1:11211)
# memcached.host=127.0.0.1:11211
#
# Or you can specify multiple host to build a distributed cache
# memcached.1.host=127.0.0.1:11211
# memcached.2.host=127.0.0.1:11212
#
# Use plain SASL to authenticate for memcached
# memcached.user=
# memcached.password=


# Execution pool
# ~~~~~
# Default to 1 thread in DEV mode or (nb processors + 1) threads in PROD mode.
# Try to keep a low as possible. 1 thread will serialize all requests (very useful for debugging purpose)
# play.pool=3

jpa.debugSQL=true
jpa.meteo.debugSQL=true
jpa.ddl=none

#~~~~~~~~~~ SQL Server JTDS config ~~~~~~~~~

jpa.dialect=org.hibernate.dialect.SQLServerDialect
db.default.url=jdbc:jtds:http://sqlserverip2_here/sid3_here
db.default.driver=net.sourceforge.jtds.jdbc.Driver
db.default.user=...
db.default.pass=...
db.default.dialect=org.hibernate.dialect.SQLServerDialect
db.default.pool.timeout=30000
db.default.pool.maxSize=300
db.default.pool.minSize=100

db.info.dialect=org.hibernate.dialect.SQLServerDialect
db.info.url=jdbc:jtds:http://sqlserverip2_here/sid2_here
db.info.driver=net.sourceforge.jtds.jdbc.Driver
db.info.user=...
db.info.pass=...
db.info.pool.timeout=30000
db.info.pool.maxSize=300
db.info.pool.minSize=100
jpa.info.dialect=org.hibernate.dialect.SQLServerDialect

db.meteo.dialect=org.hibernate.dialect.SQLServerDialect
db.meteo.url=jdbc:jtds:http://sqlserverip1_here/sid1_here
db.meteo.driver=net.sourceforge.jtds.jdbc.Driver
db.meteo.user=...
db.meteo.pass=...
db.meteo.pool.timeout=30000
db.meteo.pool.maxSize=300
db.meteo.pool.minSize=100
jpa.meteo.dialect=org.hibernate.dialect.SQLServerDialect

play.pool=3
hibernate.temp.use_jdbc_metadata_defaults=false
module.secure=${play.path}/modules/secure

I would be very grateful for the information. Thanks to all.

Aucun commentaire:

Enregistrer un commentaire