Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Eclipselink swing deadloack

Mohamed,
    I get the same behavior for one of my multithreaded swing applications - if, when I use more threads than there are physical (not HT) cores on the machine without adding at least some wait state of 1 ms.  Since you are not able to add wait states to EclipseLink code - are you spawning separate threads for the JPA code you call? 

    There is some discussion on this strategy here - I use both strategies (sleep and new thread).   
    http://wiki.eclipse.org/EclipseLink/Examples/Distributed#Multicore_Analysis

    The following call will give 8 for an i7-920, for anything non-HT it gives you the correct number
Runtime.getRuntime().availableProcessors()

    I use the following strategy that does not use the GUI event thread - and experience no UI freezing.

    public void paint(Graphics g) {
....
                        Thread thread = new Thread(workUnits.get(core));       
                        threadCompleteList.set(core,false); // 20110323 : key to sychronization
                        thread.start(); // we only start once
....
                // we will need some sleep time to allow the OS to respond to system events (as in don't use 100% CPU)
                try { Thread.sleep(1); } catch (InterruptedException e) { // this will avoid running the host thread at 50% cpu
                    showStatus(e.toString());
                }

    A bit of help.
    / Michael


On 2011-03-30 03:27, mohamed jawath wrote:


---------- Forwarded message ----------
From: mohamed jawath <mjawath@xxxxxxxxx>
Date: Wed, Mar 30, 2011 at 12:55 PM
Subject: Re: How To modify Eclipselink JPA 2.0 Automatic connection retry behaviour ?
To: Peter Krogh <PETER.KROGH@xxxxxxxxxx>


i am using eclipselink in my swing desktop application inside a workgroup with pos printer  (no servers just a mysql server on one pc others are used as clients )  application run well for many transaction like 20-30 bills printed but after it suddenly hangs mouse is working but gui is freezed  i have attached the thread dump of this situation and persistend.xml

this is the one which causing the threads to waiting state
please can u help me to solve them ???


"SwingWorker-pool-1-thread-10" daemon prio=6 tid=0x03143400 nid=0xbec in Object.wait() [0x052ff000]

   java.lang.Thread.State: WAITING (on object monitor)

            at java.lang.Object.wait(Native Method)

            at org.eclipse.persistence.sessions.server.ConnectionPool.acquireConnection(ConnectionPool.java:102)

            - locked <0x27d6d7e0> (a org.eclipse.persistence.sessions.server.ConnectionPool)

            at org.eclipse.persistence.sessions.server.ServerSession.allocateReadConnection(ServerSession.java:477)






On Wed, Mar 30, 2011 at 4:59 AM, Peter Krogh <PETER.KROGH@xxxxxxxxxx> wrote:
Mohamed,
 
Just touching base and making sure that James, or someone else got back to you wrt this. 
-----Original Message-----
From: mohamed jawath [mailto:mjawath@xxxxxxxxx]
Sent: Sunday, March 13, 2011 1:28 PM
To: Peter Krogh
Subject: How To modify Eclipselink JPA 2.0 Automatic connection retry behaviour ?



---------- Forwarded message ----------
From: mohamed jawath <mjawath@xxxxxxxxx>
Date: Sun, Mar 13, 2011 at 4:37 PM
Subject: How To modify Eclipselink JPA 2.0 Automatic connection retry behaviour ?
To: james.sutherland@xxxxxxxxxx


How To modify Eclipselink JPA 2.0 connection retry behaviour .

 

  EntityManager entityManager = Persistence.createEntityManagerFactory("mydb").createEntityManager();

 

Database connection is connected

 

    private void cButton1ActionPerformed(java.awt.event.ActionEvent evt) {

 

        entityManager.createQuery(".....").getResultList();

    }

 

if Database connection is disconnected at this point.

 

 

    private void cButton2ActionPerformed(java.awt.event.ActionEvent evt) {

        entityManager.createQuery(".....").getResultList();

    }

 

 

Eclipselink automatically tries to reconnect it self to  database whenever  it detects a connection failure this causes swing ui to freeze without any responses until it connects to database .

Are there any solution to modify this behavior

Ie is it possible to throw exception when connection fails without retrying

Please help on this issue

I am facing with huge problem.

 

I went throe eclipselink source code and google but I could not find any solution.

 

 

 

 

Statck trace:

[EL Info]: 2011-03-12 16:30:56.5--UnitOfWork(6658066)--Communication failure detected when attempting to perform read query outside of a transaction. Attempting to retry query.

[EL Severe]: 2011-03-12 16:31:00.468--ServerSession(17922592)--Local Exception Stack:

Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.DatabaseException

Internal Exception: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

 

Last packet sent to the server was 0 ms ago.

Error Code: 0

        at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:324)

        at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:319)

        at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:138)

        at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)

        at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connectInternal(DatasourceAccessor.java:327)

        at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.connectInternal(DatabaseAccessor.java:294)

        at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connect(DatasourceAccessor.java:415)

        at org.eclipse.persistence.sessions.server.ConnectionPool.buildConnection(ConnectionPool.java:155)

        at org.eclipse.persistence.sessions.server.ConnectionPool.acquireConnection(ConnectionPool.java:97)

        at org.eclipse.persistence.sessions.server.ServerSession.allocateReadConnection(ServerSession.java:477)

        at org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:525)

        at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:205)

        at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:191)

        at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:262)

        at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:618)

        at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2537)

        at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2496)

        at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:455)

        at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:997)

        at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:675)

        at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:958)

        at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:432)

        at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1021)

        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2863)

        at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1225)

        at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1299)

        at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1207)

        at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1181)

        at org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:453)

        at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultList(EJBQueryImpl.java:669)

        at org.raheemiya.entity.dao.GenericDAO.ExecuteQuery(GenericDAO.java:216)

        at org.raheemiya.entity.dao.BillDAO.getNotPayed(BillDAO.java:37)

        at org.business.rhotel.ui.hotel.CashierUI.testTimeElapse(CashierUI.java:227)

        at org.business.rhotel.ui.hotel.CashierUI$4$1.doInBackground(CashierUI.java:137)

        at javax.swing.SwingWorker$1.call(SwingWorker.java:278)

        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

        at java.util.concurrent.FutureTask.run(FutureTask.java:138)

        at javax.swing.SwingWorker.run(SwingWorker.java:317)

        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

        at java.lang.Thread.run(Thread.java:619)

Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

 

Last packet sent to the server was 0 ms ago.

        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

        at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)

        at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)

        at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2103)

        at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:718)

        at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)

        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

        at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)

        at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302)

        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)

        at java.sql.DriverManager.getConnection(DriverManager.java:582)

        at java.sql.DriverManager.getConnection(DriverManager.java:154)

        at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:98)

        ... 38 more

Caused by: java.net.ConnectException: Connection refused: connect

        at java.net.PlainSocketImpl.socketConnect(Native Method)

        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)

        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)

        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)

        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)

        at java.net.Socket.connect(Socket.java:519)

        at java.net.Socket.connect(Socket.java:469)

        at java.net.Socket.<init>(Socket.java:366)

        at java.net.Socket.<init>(Socket.java:209)

        at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:253)

        at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:280)

        at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2026)

        ... 50 more




_______________________________________________ eclipselink-users mailing list eclipselink-users@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top