Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19

Thread: application freeze when trying to save an object

  1. #11
    Join Date
    Feb 2007
    Posts
    9

    Default

    I succeed to reproduce the case in a testCase. So I can run it under eclipse !!

    I change configuration like said above but it didn't solved the problem.
    However, I see that my problem is clearly a connexion leak.

    In applicationContext, I tried :

    <property name="maxPoolSize"><value>100</value></property>
    I monitored number of connexion with mysqlAdministrator and I see that I had something like 4 connexion on beginning and it increases to 100. The treatment freez like always on 100 :
    DEBUG : opening user JDBC connection, application must close it

    I notice that sometimes hibernate release session :
    DEBUG Finalizer org.hibernate.jdbc.ConnectionManager running Session.finalize()

    but it is not enough.

    I understand the problem, I search the solution now. If you have a clue, I take it ^^

  2. #12
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,425

    Default

    If you have managed to reproduce and isolate the problem, it would be useful to see the required code and TestCase.

  3. #13
    Join Date
    Feb 2007
    Posts
    9

    Default

    Hi,
    I tried to delete the maximum that is not related to the test.

    I let in the zip :
    the bean : Accounts.java
    the mapping file
    the dao
    the service
    the manager that implement the login method
    the test that call 50 times the login method of loginmanager.

    You need a database and those data :

    Code:
    DROP TABLE IF EXISTS `accounts`;
    CREATE TABLE IF NOT EXISTS `accounts` (
      `login` varchar(45) NOT NULL default '',
      `password` varchar(45) default NULL,
      `lastactive` decimal(20,0) default NULL,
      `access_level` int(11) default NULL,
      `lastIP` varchar(20) default NULL,
      PRIMARY KEY  (`login`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    
    
    
    INSERT INTO `accounts` (`login`, `password`, `lastactive`, `access_level`, `lastIP`) VALUES ('corwin', 'qUqP5cyxm6YcTAhz05Hph5gvu9M=', '1172698101359', 0, '127.0.0.1'),
    ('toto', 'qUqP5cyxm6YcTAhz05Hph5gvu9M=', '1172691596546', 0, '127.0.0.1');
    and you need maven2 to get the dependencies : mvn eclipse:eclipse
    Attached Files Attached Files

  4. #14
    Join Date
    Dec 2005
    Posts
    269

    Default

    why don't you put the LoginManager into the appContext.xml as well?
    I'd also apply TX semantics on the whole loginValid() as well, because all operations there form a single transaction. In this case you don't need to call _service.addOrUpdateAccount(acc).

  5. #15
    Join Date
    Feb 2007
    Posts
    9

    Default

    I try to keep some logic from old application when I migrate it. I firstly create DAO, beans and let the manager as it is. But you're right, I can embed it in applicationContext.
    For the test, I tried to do it, I appli TX semantics to loginValid and remove addOrUpdateAccount but same result.
    I simplify the method and now, I just have :

    Code:
    	/**
    	 * user name is not case sensitive any more
    	 * @param user
    	 * @param password
    	 * @param address
    	 * @return
    	 */
    	public boolean loginValid(String user, String password)
    	{
            // o find Account
            // -------------
    		Accounts acc = _service.getAccountById(user);
            
            // If account is not found
            // try to create it if AUTO_CREATE_ACCOUNTS is activated
            // or return false
            // ------------------------------------------------------
    		if (acc == null)
    		{
    			_log.warn("case delete from unit test" );
    		}
            // o account is found
            // ---------------------------------------------
            else
            {
    			_log.warn("before updating info" );
    			acc.setLastactive(new BigDecimal(System.currentTimeMillis()));
                acc.setLastIp("127.0.0.1");
                //_service.addOrUpdateAccount(acc);
                _log.warn("after updating info" );
    		}
    		return true;
    	}
    This is really basic but this test :

    Code:
        public void testConnection() throws IOException
        {
            for (int i=0;i<50;i++)
            {
            	System.out.println(i);
            	assertTrue(loginManager.loginValid("corwin", "test"));
            }
        }
    freeze

    I really don't understand

  6. #16
    Join Date
    Feb 2007
    Posts
    9

    Default

    I tried to upgrade hibernate in 3.2.2.ga (instead of hibernate 3.1rc2) and my problem disappeared. I have to test on the real application but I think it's good now.

  7. #17
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,425

    Default

    Fingers crossed it works! It is a strange one one however, it's a good tip for the future.

  8. #18
    Join Date
    Feb 2007
    Posts
    9

    Default

    yes, I tried in real environment and it seems to work.
    I was affraid to lose all my hairs ^^

  9. #19
    Join Date
    Dec 2005
    Posts
    269

    Default

    yep, it's usually a good idea to move from an RC to a *real* release

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •