Need to figure out how to properly configure EclipseLink [message #634184] |
Wed, 20 October 2010 13:27  |
Eclipse User |
|
|
|
I need to understand how to properly configure EclipseLink to use in my first JPA application, so that I can resolve the problem of 'Communications Link failure', which happens after a while of application inactivity. I am using Java SE, Tomcat 6 as the container, and MySQL as the database. The persistence.xml file specifies a direct connection to the database (I've included the driver url, user and database properties in the persistence.xml file). How should I modify this configuration to properly handle the communication failures? (I've seen this same Java exception posted about and discussed in many internet posts, but I cannot see anywhere what a solution would look like in my simple configuration). Is it possible to resolve in this "direct-connection' , 'resource-local' configuration? If so, could you please post an example persistence.xml that does it.
Thanks in advance.
|
|
|
Re: Need to figure out how to properly configure EclipseLink [message #634209 is a reply to message #634184] |
Wed, 20 October 2010 15:15   |
Eclipse User |
|
|
|
We have problems with MySQL and Eclipselink on TC6. Maybe your problem has the same cause.
For some reason inactive connection are made invalid by MySql and Eclipselink does not do a good validation that detects this before using these connection again. You then get all kind of errors until these connections are cleared from the pool. Currently we're trying to replace the connection pool with a different implementation.
Tom
On 20-10-2010 19:27, Patricia Goldweic wrote:
> I need to understand how to properly configure EclipseLink to use in my first JPA application, so that I can resolve the problem of 'Communications Link failure', which happens after a while of application inactivity. I am using Java SE, Tomcat 6 as the container, and MySQL as the database. The persistence.xml file specifies a direct connection to the database (I've included the driver url, user and database properties in the persistence.xml file). How should I modify this configuration to properly handle the communication failures? (I've seen this same Java exception posted about and discussed in many internet posts, but I cannot see anywhere what a solution would look like in my simple configuration). Is it possible to resolve in this "direct-connection' , 'resource-local' configuration? If so, could you please post an example persistence.xml that does it. Thanks in advance.
|
|
|
|
|
|
Re: Need to figure out how to properly configure EclipseLink [message #634706 is a reply to message #634685] |
Fri, 22 October 2010 15:22   |
Eclipse User |
|
|
|
I'm now experimenting with the definition of a JNDI datasource (so I can use this instead of the direct connection approach in persistence.xml). I've pretty much followed the article in http://wiki.eclipse.org/EclipseLink/Examples/JPA/Tomcat_Web_ Tutorial#JNDI_Datasource_Setup , using a 'non-jta data source'. Unfortunately, when my code runs, after apparently successfully deploying the data source, it throws an Exception the first time it creates an EntityManager, as follows:
------------------------------------------------------------ -----------------
[EL Severe]: 2010-10-22 14:00:44.872--ServerSession(6200759)--Thread(Thread[main,5,m ain])--java.lang.UnsupportedOperationException: Not supported by BasicDataSource
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(Ba sicDataSource.java:899)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIC onnector.java:135)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIC onnector.java:94)
at org.eclipse.persistence.sessions.DatasourceLogin.connectToDa tasource(DatasourceLogin.java:162)
at org.eclipse.persistence.internal.databaseaccess.DatasourceAc cessor.connectInternal(DatasourceAccessor.java:327)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAcce ssor.connectInternal(DatabaseAccessor.java:294)
at org.eclipse.persistence.internal.databaseaccess.DatasourceAc cessor.connect(DatasourceAccessor.java:415)
at org.eclipse.persistence.sessions.server.ConnectionPool.build Connection(ConnectionPool.java:155)
at org.eclipse.persistence.sessions.server.ExternalConnectionPo ol.startUp(ExternalConnectionPool.java:118)
at org.eclipse.persistence.sessions.server.ServerSession.connec t(ServerSession.java:495)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImp l.login(DatabaseSessionImpl.java:632)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryPro vider.login(EntityManagerFactoryProvider.java:230)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl. deploy(EntityManagerSetupImpl.java:368)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImp l.getServerSession(EntityManagerFactoryImpl.java:151)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImp l.createEntityManagerImpl(EntityManagerFactoryImpl.java:207)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImp l.createEntityManager(EntityManagerFactoryImpl.java:195)
at edu.northwestern.at.ggdashboard.persistence.PersistenceServi ce.getEntityManager(PersistenceService.java:31)
---------------------------------------------------
Any suggestions on what may be causing this? (please keep in mind that I'm using Java SE, Tomcat 6, eclipselink and MySQL)
|
|
|
|
|
Re: Need to figure out how to properly configure EclipseLink [message #635628 is a reply to message #635390] |
Wed, 27 October 2010 10:44  |
Eclipse User |
|
|
|
For the record, I was able to figure out a set of parameters which apparently works well, as follows:
<Resource name="ds/MySQLGint" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="100" removeAbandoned="true" removeAbandonedTimeout="60"
logAbandoned="true" validationQuery="select now()" username="user" password="pass"
driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://host:3306/databaseName" />
This apparently works ok with a unique persistence unit/JNDI datasource in my environment (Tomcat 6, Java SE).
I am however running into trouble when I try to have my app connect to two different persistence units/JNDI datasources (see this other thread: http://www.eclipse.org/forums/index.php?t=msg&th=198997& amp;start=0&S=7b0227a42af2d35c75ed75f1c383aa8d). Although the two datasources/persistence units have been configured in identical ways, there's always a failure when it is time to connect to the second data source(!!!). If anybody has a clue on what could be going on here, or whether this is a limitation/bug of eclipselink, would be great to know.
|
|
|
Powered by
FUDForum. Page generated in 0.08460 seconds