Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Need to figure out how to properly configure EclipseLink(Need to understand how to properly configure EclipseLink to use with Tomcat and MySQL, java SE)
Need to figure out how to properly configure EclipseLink [message #634184] Wed, 20 October 2010 17:27 Go to next message
Patricia Goldweic is currently offline Patricia GoldweicFriend
Messages: 34
Registered: October 2010
Member
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 19:15 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 817
Registered: July 2009
Senior Member
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 #634217 is a reply to message #634209] Wed, 20 October 2010 19:36 Go to previous messageGo to next message
Patricia Goldweic is currently offline Patricia GoldweicFriend
Messages: 34
Registered: October 2010
Member
Thanks for your reply Tom. We actually haven't explicitly defined any connection pool at this point (we are using the simplest EclipseLink configuration one can come up with). Are you in the same situation, and are therefore just referring to Eclipselink's internal connection pool? Or are you referring to some -additional- and explicit connection pool configuration one needs to provide?
Re: Need to figure out how to properly configure EclipseLink [message #634277 is a reply to message #634217] Thu, 21 October 2010 06:04 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 817
Registered: July 2009
Senior Member
The problem is with the default internal pool.
Re: Need to figure out how to properly configure EclipseLink [message #634685 is a reply to message #634277] Fri, 22 October 2010 18:01 Go to previous messageGo to next message
Patricia Goldweic is currently offline Patricia GoldweicFriend
Messages: 34
Registered: October 2010
Member
I wonder if you've been able to come up for a solution to this, or somebody else can offer a working example? The environment includes:
- java 6 SE
- Tomcat 6
- MySQL
- eclipselink

working configuration files would be ideal to see. 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 19:22 Go to previous messageGo to next message
Patricia Goldweic is currently offline Patricia GoldweicFriend
Messages: 34
Registered: October 2010
Member
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 #635089 is a reply to message #634706] Mon, 25 October 2010 15:35 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Check if you are still setting a user/password in your persistence.xml. If you are then remove it, the BasicDataSource may not support a user/password. Or if not, try adding it, maybe BasicDataSource requires user/password.


James : Wiki : Book : Blog : Twitter
Re: Need to figure out how to properly configure EclipseLink [message #635390 is a reply to message #635089] Tue, 26 October 2010 16:08 Go to previous messageGo to next message
Patricia Goldweic is currently offline Patricia GoldweicFriend
Messages: 34
Registered: October 2010
Member
You were right about the fact that I was still using a user/password in persistence.xml. The exception went away when I removed it. However, even though the app can successfully connect to the data source, I am now getting again the 'Communications Link Failure' exceptions that prompted me to try the JNDI datasource approach, instead of the direct connection approach. These exceptions are thrown when the database is accessed after a period of inactivity. What are the right parameters to use in the JNDI resource definitions to avoid this?
Current parameters are as follows:
<Resource name="ds/MySQLGint" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000" username="user" password="pass"
driverClassName="com.mysql.jdbc.Driver" url=" jdbc:mysql://somehost:3306/gintdashboarddev?autoReconnect=tr ue" />

I understand that the MySQL timeout value is set at 200.
Thanks in advance for any help!
Re: Need to figure out how to properly configure EclipseLink [message #635628 is a reply to message #635390] Wed, 27 October 2010 14:44 Go to previous message
Patricia Goldweic is currently offline Patricia GoldweicFriend
Messages: 34
Registered: October 2010
Member
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.
Previous Topic:Stored Procedure Call
Next Topic:OneToOne + MySQL issue
Goto Forum:
  


Current Time: Fri Mar 29 11:15:07 GMT 2024

Powered by FUDForum. Page generated in 0.03265 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top