Announcement Announcement Module
Collapse
No announcement yet.
Spring + Hibernate/C3P0 leaving behind threads and pools Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring + Hibernate/C3P0 leaving behind threads and pools

    Hello!
    I've been struggling for some time with a problem during load testing an app and it seems that for some strange reason a SessionFactory with an associated C3P0 datasource will not close properly, leaving several threads and a pool with open connections after each test. I wonder if anyone has come across this situation.

    Even more specifically, this only happens if the C3P0 integration is done via a dataSource bean, but NOT if done via hibernate's c3p0 properties.

    I managed to narrow the issue to this JUnit test (The dumpThreads method is not relevant to the problem, it's just a debugging aid)
    Code:
    package com.planetalia.webng.hibernate;
    
    import org.hibernate.Session;
    import org.hibernate.SessionFactory;
    import org.hibernate.Transaction;
    import org.hibernate.cfg.AnnotationConfiguration;
    import org.hibernate.cfg.Configuration;
    import org.junit.Before;
    import org.junit.Test;
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.FileSystemXmlApplicationContext;
    
    public class ConnectionTest{
    	private static final int HIBERNATE = 1;
    	private static final int SPRING= 2;
    	
    	private int mode = HIBERNATE;
    	
    	private void dumpThreads() {
    		StringBuilder sb = new StringBuilder("THREAD COUNT IS  ");
    		sb.append(Thread.activeCount());
    		sb.append(": ");
    		Thread[] liveThreads = new Thread[Thread.activeCount()];
    		long id = Thread.currentThread().getId();
    		Thread.enumerate(liveThreads);
    		for (int i = 0; i < liveThreads.length; i++) {
    			long tid = liveThreads[i].getId();
    			sb.append(tid);
    			sb.append((tid==id)?"*(":"(");
    			StackTraceElement[] stack = liveThreads[i].getStackTrace();
    			int lastElement = stack.length-1;
    			if (lastElement >=0) {
    				sb.append(stack[lastElement].getClassName());
    				sb.append(".");
    				sb.append(stack[lastElement].getMethodName());
    				sb.append(")");
    				
    			}
    			sb.append(liveThreads[i].getState());
    			sb.append("\t");
    		}
    		System.out.println(sb);
    	}
    	
    	@Before
    	public void start() throws Exception {
    		SessionFactory sessionFactory = null;
    		switch (mode) {
    			case HIBERNATE: {
    				Configuration configuration = new AnnotationConfiguration();
    				configuration.configure("hibernate.cfg.xml");
    				sessionFactory = configuration.buildSessionFactory();
    				break;
    			}
    			case SPRING: {
    				ApplicationContext ctx = new FileSystemXmlApplicationContext("wiring.xml");
    				sessionFactory = (SessionFactory)ctx.getBean("sessionFactory");
    				break;
    			}
    		}
    		Session session = sessionFactory.getCurrentSession();
    		Transaction tx = session.beginTransaction();
    		tx.commit();
    		sessionFactory.close();
    		
    		dumpThreads();
    	}
    	
    	@Test public void test1() throws Exception {Thread.sleep(500);}
    	@Test public void test2() throws Exception {Thread.sleep(500);}
    	@Test public void test3() throws Exception {Thread.sleep(500);}
    	@Test public void test4() throws Exception {Thread.sleep(500);}
    	@Test public void test5() throws Exception {Thread.sleep(500);}
    	@Test public void test6() throws Exception {Thread.sleep(500);}
    	@Test public void test7() throws Exception {Thread.sleep(500);}
    	@Test public void test8() throws Exception {Thread.sleep(500);}
    }
    This test uses only Hibernate or Spring+Hibernate.

    For the first mode, the following configuration file is used (hibernate.cfg.xml):
    Code:
    <hibernate-configuration>
    	<session-factory>
    		<property name='connection.driver_class'>com.mysql.jdbc.Driver</property>
    		<property name='connection.url'>jdbc:mysql://localhost/test</property>
    		<property name='connection.username'>test</property>
    		<property name='connection.password'>test</property>
    		<property name='dialect'>org.hibernate.dialect.MySQLInnoDBDialect</property>
    		<property name='current_session_context_class'>thread</property>
    		<property name='cache.provider_class'>org.hibernate.cache.NoCacheProvider</property>
    		<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
    		
    		<property name="hibernate.c3p0.min_size">15</property>
    		<property name="hibernate.c3p0.max_size">200</property>
    		<property name="hibernate.c3p0.max_statements">100</property>
    	</session-factory>
    </hibernate-configuration>
    And for the second (Spring+Hibernate) mode, the following file is used (wiring.xml):
    Code:
      <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
    		<property name="driverClass" value="com.mysql.jdbc.Driver"/>
    		<property name="jdbcUrl" value="jdbc:mysql://localhost/test"/>
    		<property name="user" value="test"/>
    		<property name="password" value="test"/>
    		
    		<property name="minPoolSize" value="15"/>
    		<property name="maxPoolSize" value="200"/>
    		<property name="maxStatements" value="100"/>
    	</bean>
    	
    	 <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>		
        <property name="hibernateProperties">
          <value>
          <!-- 
          	hibernate.connection.driver_class = com.mysql.jdbc.Driver
          	hibernate.connection.url=jdbc:mysql://localhost/test
          	hibernate.connection.username=test
          	hibernate.connection.password=test
          	
          	hibernate.connection.provider_class = org.hibernate.connection.C3P0ConnectionProvider
          	hibernate.c3p0.min_size=15
          	hibernate.c3p0.max_size=200
          	hibernate.c3p0.max_statements=100
          	 -->
            hibernate.dialect = org.hibernate.dialect.MySQLInnoDBDialect
            hibernate.cache.provider_class = org.hibernate.cache.NoCacheProvider
            hibernate.show_sql = false
            hibernate.current_session_context_class=thread
          </value>
        </property>
      </bean>
    If the test is run in the SPRING mode, each consecutive test leaves behind 4 threads and a fully built (and connected) pool, regardless of the sessionFactory.close() method. According to the dump, the threads are basically waiting on some monitor. But this only happens if the C3P0 initialization is performed using <property name="dataSource" ref="dataSource"/>. If I remove that property and instead initialize C3P0 using the commented hibernate properties, it works properly.

    If the test is run in the HIBERNATE mode, there are no "leftover" threads and/or pools. However, if in this mode I "forget" to call sessionFactory.close(), I get exactly the same behaviour as the SPRING mode WITH sessionFactory.close();

    (Versions are: Hibernate: 3, C3P0: 0.9.1, Spring: 2.5.6.SEC01 (2009-04-22) )

    Any ideas or similar problems? Thanks!

  • #2
    Well I suggest the forum search... If you use spring to configure hibernate DON'T set the hibernate.current_session_context_class UNLESS you are using JTA. So remove it...

    Next to that make sure that the hibernate.cfg.xml isn't loaded by the sessionfactory, because that will override the settings in spring.

    Comment


    • #3
      Thanks; from what I've been reading, removing hibernate.current_session_context_class puts me on a slippery slope that forces me to use Spring for transaction management (otherwise I get the typical "No Hibernate session bound to thread"), something that I cannot do.

      Although I've read in many places (incl. the docs) that I can in theory use the naked Hibernate API and manage the transactions myself, I haven't still figured out how or found any working example outside of JTA (i.e. plain vanilla JDBC transactions).

      Seems to me that an easier way would be to drop the LocalSessionFactory bean altogether and do the job myself using only the Spring container and not the Hibernate integration classes.

      Comment


      • #4
        If you use spring to wire your classes then why wouldn't you use springs tx management?! It is far easier and less error prone then managing tx yourself... I rarely do that anymore only in a few corner cases, although I tend to use TransactionTemplate to have more control in those situations.

        Comment


        • #5
          Well, as I suspected, it turns out that even after using Spring Transaction Management and Hibernate integration according to the "canon", it is still leaking threads...
          And this is no longer Spring 2, but the latest Spring (3.0.4) and Hibernate (3.5.5) releases ....

          Here's the test class:

          Code:
          import org.hibernate.Session;
          import org.hibernate.SessionFactory;
          import org.junit.Before;
          import org.junit.Test;
          import org.springframework.context.support.ClassPathXmlApplicationContext;
          import org.springframework.transaction.annotation.Propagation;
          import org.springframework.transaction.annotation.Transactional;
          
          public class ConnectionTest{
          	public static class TXClass {
          		private SessionFactory sessionFactory;
          		
          		public SessionFactory getSessionFactory() {
          			return sessionFactory;
          		}
          
          		public void setSessionFactory(SessionFactory sessionFactory) {
          			this.sessionFactory = sessionFactory;
          		}
          
          		
          		@Transactional(propagation=Propagation.REQUIRES_NEW)
          		public void doJob() {
          			Session session = sessionFactory.getCurrentSession();
          			// Just a stupid test to make sure everything is setup properly
          			session.createSQLQuery("select 1 from mysql.db").list();
          		}
          	}
          
          	
          	@Before
          	public void start() throws Exception {
          		ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("spring-wiring.xml");
          		TXClass tx =(TXClass)ctx.getBean("bean");
          		tx.doJob();
          		System.out.println("Thread count : "+Thread.activeCount());
          	}
          	
          	@Test public void test1() throws Exception {Thread.sleep(500);}
          	@Test public void test2() throws Exception {Thread.sleep(500);}
          	@Test public void test3() throws Exception {Thread.sleep(500);}
          	@Test public void test4() throws Exception {Thread.sleep(500);}
          	@Test public void test5() throws Exception {Thread.sleep(500);}
          	@Test public void test6() throws Exception {Thread.sleep(500);}
          	@Test public void test7() throws Exception {Thread.sleep(500);}
          	@Test public void test8() throws Exception {Thread.sleep(500);}
          
          }
          And here's the wiring:

          Code:
          <beans xmlns="http://www.springframework.org/schema/beans"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:tx="http://www.springframework.org/schema/tx"
               xsi:schemaLocation="
               http://www.springframework.org/schema/beans 
               http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
               http://www.springframework.org/schema/tx 
               http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
          
           <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
              <property name="driverClass" value="com.mysql.jdbc.Driver"/>
              <property name="jdbcUrl" value="jdbc:mysql://localhost/test"/>
              <property name="user" value="test"/>
              <property name="password" value="test"/>
              <property name="minPoolSize" value="15"/>
              <property name="maxPoolSize" value="200"/>
              <property name="maxStatements" value="100"/>
           </bean>
          	
           <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" >
              <property name="dataSource" ref="dataSource"/>		
              <property name="hibernateProperties">
                <value>
                  hibernate.dialect = org.hibernate.dialect.MySQLInnoDBDialect
                  hibernate.cache.provider_class = org.hibernate.cache.NoCacheProvider
                  hibernate.show_sql = false
                </value>
              </property>
            </bean>
          
           <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
          	<property name="sessionFactory" ref="sessionFactory"/>
           </bean>
          
           <tx:annotation-driven transaction-manager="txManager"/>
          
           <bean id="bean" class="ConnectionTest$TXClass"	>
          	<property name="sessionFactory" ref="sessionFactory" />
           </bean>
          
          
          </beans>
          Result:
          Code:
          Thread count : 6
          Thread count : 10
          Thread count : 14
          Thread count : 18
          Thread count : 22
          Thread count : 26
          Thread count : 30
          Thread count : 34
          Last edited by alex314; Sep 3rd, 2010, 09:03 AM. Reason: typo

          Comment


          • #6
            Because what you are doing is something you shouldn't be doing... You are creating a SessionFactory and ApplicationContext for each thread, which you shouldn't be doing...

            If you really want to do that you also have to CLOSE the context, which you also aren't doing, which means your connectionpool isn't going to close properly... So basically after each test method you still have an active connection pool, active sessionfactory and active applicationcontext.... Also I'm not sure what you are trying to test, but that is probably me being stupid....
            Last edited by Marten Deinum; Sep 3rd, 2010, 09:27 AM.

            Comment


            • #7
              Exactly where am I doing that? "Each thread"? There is only one thread during each of the tests!

              Comment


              • #8
                One user thread, I mean. Whatever threads Spring+Hibernate+c3P0 create, I don't know but they definitely should NOT leak to the next test.

                Comment


                • #9
                  Sigh... You don't close the context, so the connection pool doesn't get the signal to close, those threads remain (probaly some monitoring thread etc.). If you use plain hibernate and call close on the sessionfactory that is going to ripple through till the connection pool because well it is managed by hibernate. Now you have a applicationcontext, which you don't properly close and hence those threads hang around...

                  If you don't stop the threads, or signal the mechanism that should stop those threads those are going to stay around...

                  You can see for yourself if you do a thread dump.
                  Last edited by Marten Deinum; Sep 3rd, 2010, 09:44 AM.

                  Comment


                  • #10
                    Marten, I would close() the ApplicationContext if anywhere in the Spring reference documentation it was mentioned that the application context needed closing AND if I could call that method, which I can't since it is not part of the ApplicationContext interface. Of course I will call that method in one way or another (casting, reflection, whatever...), but that's a different issue.

                    None of the examples in the Spring doc bothers to do it (e.g: pp 49,107,132-137,146,242, etc... of the Spring 3 PDF), not even those dealing with tx examples, and the only place that talks about shutting gracefully the IoC container in nonWeb apps suggests registerShutdownHook() which doesn't work in my case anyway since AFAIK the JVM isn't restarted between test runs in the IDE I'm using.

                    As an epilogue, I must also say that while I appreciate your answers, I don't appreciate the "Sigh". You may or may not reply to me, that's your choice, but if you do, I expect some respect, just as I respect you and don't "Sigh" on the misguided statements you've made. Having said that, I repeat that I appreciate your effort in helping me with this issue.

                    Cheers

                    Alex

                    Comment


                    • #11
                      Normally you don't need to close the context OR you aren't in control and the closing is done for you.

                      Only at closing the application context the destroy methods are called. Which, I agree, isn't that clearly mentioned in the documentation. However it is mentioned that on destruction of the applicationcontext (chapter 3.6) the destroy-method is called, and destruction is something else as getting garbage collection.

                      The close method is part of the AbstractApplicationContext and should be called to invoke proper context shutdown.

                      Originally posted by alex314
                      Well, as I suspected, it turns out that even after using Spring Transaction Management and Hibernate integration according to the "canon", it is still leaking threads...
                      You are stating that you know things better and everything is as you expected and you are calling the resources which are trying to help you "canon", which basically means IMHO you aren't showing respect either... Hence my sighing...

                      Comment


                      • #12
                        You are stating that you know things better and everything is as you expected
                        What I'm stating is only what I've written: That after following the official way of doing things and your advice, it still exhibited the same problem, and that this was in line with my belief (as per the OP) that the problem had to do with resource disposal rather than the other things you suggested. This has nothing to do with respect. If I didn't respect your opinion, I wouldn't have followed your suggestion in the first place, don't you think?

                        Please take a step back and look at the frequency with which you sigh at people in your posts.


                        Regarding the issue at hand, IMHO if there are situations in which an ApplicationContext needs special shutdown operations then the close() method should belong to that interface and not to some subinterface, and it should be mentioned explicitly in the documentation, especially considering that ApplicationContext is "THE" Spring Interface.

                        Cheers

                        Alex

                        Comment


                        • #13
                          Regarding the issue at hand, IMHO if there are situations in which an ApplicationContext needs special shutdown operations then the close() method should belong to that interface and not to some subinterface, and it should be mentioned explicitly in the documentation, especially considering that ApplicationContext is "THE" Spring Interface.
                          Then create a [url=jira.springsource.orgJIRA issue[/url] for that so that the spring people can improve the documentation.

                          What I don't understand is that you know that you need to clean-up after yourself when using plain hibernate (closing the sessionfactory). But you expect spring to magically close everything for you even if you don't trigger/tell it to or you expect hibernate to cleanup resources that it doesn't manage (the external connection pool).

                          Maybe I should sign of here, leave to forum, spring and the community. I'm not sure, well see what the future holds...

                          Comment


                          • #14
                            What can i do ? please

                            hi dear friends.
                            i have some exceptions such as The connection is closed or Can not checkout connection like :
                            Code:
                            =org.hibernate.jdbc.AbstractBatcher 2011-03-09 12:31:12,187 -- WARN -- exception clearing maxRows/queryTimeout
                            com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.
                            	at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:171)
                            	at com.microsoft.sqlserver.jdbc.SQLServerConnection.checkClosed(SQLServerConnection.java:319)
                            	at com.microsoft.sqlserver.jdbc.SQLServerStatement.checkClosed(SQLServerStatement.java:956)
                            	at com.microsoft.sqlserver.jdbc.SQLServerStatement.getMaxRows(SQLServerStatement.java:989)
                            	at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.getMaxRows(NewProxyPreparedStatement.java:1200)
                            	at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:298)
                            	at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:234)
                            	at org.hibernate.loader.Loader.getResultSet(Loader.java:1967)
                            	at org.hibernate.loader.Loader.doQuery(Loader.java:802)
                            	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
                            	at org.hibernate.loader.Loader.loadCollection(Loader.java:2166)
                            	at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:62)
                            	at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:627)
                            	at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:83)
                            	at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1863)
                            	at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:479)
                            	at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:900)
                            	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:279)
                            	at org.hibernate.loader.Loader.doList(Loader.java:2533)
                            	at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
                            	at org.hibernate.loader.Loader.list(Loader.java:2271)
                            	at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:452)
                            	at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
                            	at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
                            	at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268)
                            	at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
                            	at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:859)
                            ... DA layer of my application (simple query to load an object)
                            	at sun.reflect.GeneratedMethodAccessor381.invoke(Unknown Source)
                            	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                            	at java.lang.reflect.Method.invoke(Method.java:597)
                            	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
                            	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
                            	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
                            	at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50)
                            	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
                            	at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50)
                            	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
                            	at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50)
                            	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
                            	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
                            	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
                            	at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:55)
                            	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
                            	at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:80)
                            	at sun.reflect.GeneratedMethodAccessor145.invoke(Unknown Source)
                            	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                            	at java.lang.reflect.Method.invoke(Method.java:597)
                            	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)
                            	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)
                            	at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:65)
                            	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
                            	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
                            	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
                            	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
                            	at $Proxy10. MYMETHODNAME (Unknown Source)
                            	at sun.reflect.GeneratedMethodAccessor381.invoke(Unknown Source)
                            	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                            	at java.lang.reflect.Method.invoke(Method.java:597)
                            	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
                            	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
                            	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
                            	at org.springframework.remoting.support.RemoteInvocationTraceInterceptor.invoke(RemoteInvocationTraceInterceptor.java:77)
                            	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
                            	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
                            	at $Proxy10. MYMETHODNAME (Unknown Source)
                            	at sun.reflect.GeneratedMethodAccessor680.invoke(Unknown Source)
                            	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                            	at java.lang.reflect.Method.invoke(Method.java:597)
                            	at org.springframework.remoting.support.RemoteInvocation.invoke(RemoteInvocation.java:205)
                            	at org.springframework.security.remoting.rmi.ContextPropagatingRemoteInvocation.invoke(ContextPropagatingRemoteInvocation.java:103)
                            	at org.springframework.remoting.support.DefaultRemoteInvocationExecutor.invoke(DefaultRemoteInvocationExecutor.java:38)
                            	at org.springframework.remoting.support.RemoteInvocationBasedExporter.invoke(RemoteInvocationBasedExporter.java:78)
                            	at org.springframework.remoting.rmi.RmiBasedExporter.invoke(RmiBasedExporter.java:73)
                            	at org.springframework.remoting.rmi.RmiInvocationWrapper.invoke(RmiInvocationWrapper.java:72)
                            	at sun.reflect.GeneratedMethodAccessor144.invoke(Unknown Source)
                            	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                            	at java.lang.reflect.Method.invoke(Method.java:597)
                            	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305)
                            	at sun.rmi.transport.Transport$1.run(Transport.java:159)
                            	at java.security.AccessController.doPrivileged(Native Method)
                            	at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
                            	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
                            	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
                            	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
                            	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:662)

                            Comment


                            • #15
                              ... What can i do ? Please

                              I use spring 3.0.5, hibernate 3.6.0, c3p0 0.9.1
                              my configuration :

                              Code:
                              <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
                                      <property name="driverClass"                            value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
                                      <property name="jdbcUrl"                                value="jdbc:sqlserver://127.0.0.1:1433;databaseName=MYDB"/>
                                      <property name="user"                                   value="sa"/>
                                      <property name="password"                               value="pass"/>
                              
                                      <property name="acquireIncrement"                       value="10"/>
                                      <property name="acquireRetryAttempts"                   value="30"/>
                                      <property name="acquireRetryDelay"                      value="1000"/>
                                      <property name="autoCommitOnClose"                      value="false"/>
                                      <property name="debugUnreturnedConnectionStackTraces"   value="true"/>
                                      <property name="idleConnectionTestPeriod"               value="100"/>
                                      <property name="initialPoolSize"                        value="10"/>
                                      <property name="maxConnectionAge"                       value="1000"/>
                                      <property name="maxIdleTime"                            value="200"/>
                                      <property name="maxIdleTimeExcessConnections"           value="3600"/>
                                      <property name="maxPoolSize"                            value="300"/>
                                      <property name="minPoolSize"                            value="10"/>
                                      <property name="preferredTestQuery"                     value="select 1"/>
                                      <property name="testConnectionOnCheckin"                value="false"/>
                                      <property name="unreturnedConnectionTimeout"            value="1000"/>
                                  </bean>
                              
                              <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
                                      <property name="dataSource"     ref="dataSource"/>
                                      <property name="schemaUpdate"   value="false"/>
                                      <property name="mappingResources">
                                          <list>
                                               ...
                                          </list>
                                      </property>
                                      <property name="hibernateProperties">
                                          <props>
                                              <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
                                              <prop key="hibernate.show_sql">false</prop>
                                              <prop key="hibernate.hbm2ddl.auto">update</prop>
                                              <prop key="hibernate.generate_statistics">false</prop>
                                              <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
                                              <prop key="hibernate.cache.use_query_cache">true</prop>
                                              <prop key="hibernate.cache.use_second_level_cache">true</prop>
                                              <prop key="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</prop>
                                          </props>
                                      </property>
                                      <property name="eventListeners">
                                          <map>
                                              <entry key="merge">
                                                  <bean class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener"/>
                                              </entry>
                                          </map>
                                      </property>
                              </bean>

                              Comment

                              Working...
                              X