Announcement Announcement Module
Collapse
No announcement yet.
No Hibernate Session bound to thread Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • No Hibernate Session bound to thread

    Hello,

    I searched the entire forum, still I could n't fix my problem.
    I believe I don't have to use AOP target. A simple TransactionProxyFactoryBean should be suffice to bound the Hibernate Session transactionally. Let me know if I am missing any other configuration?

    Software:
    Code:
     
    Spring RCP-Richclient 0.2.0
    Spring 2.0
    Hibernate 3.0 
    Oracle 10g
    Jdk1.4
    Mine is a Swing based client using Spring's RCP, means it is a standalone application.

    Code:
     
    
    	<!-- Oracle Implicit Connection Pool DataSource (Not a JNDI datasource)-->     
      	<bean id="dataSource" ref="oracleDataSource" /> 
    	  	
    	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    		<property name="dataSource" ref="dataSource"/>
    		<property name="mappingResources">
    			<list>
    				<value>Test.hbm.xml</value>
    			</list>
    		</property>
    		<property name="hibernateProperties">
    			<props> 
              		<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop> 
             	 	<prop key="current_session_context_class">thread</prop> 
             	 	<prop key="hibernate.show_sql">true</prop> 
           		</props> 		
    		</property>				
    	</bean> 	
      		
    	<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">	
    	 	<property name="sessionFactory" ref="sessionFactory" /> 
    	</bean>	
    	
        <bean id="myDao" class="com.test.MyDao">
            <property name="sessionFactory" ref="sessionFactory"/>  
        </bean>
    
    	<bean id="myService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    		<property name="transactionManager" ref="txManager"/>
    		<property name="target" ref="myDao"/>			
    		<property name="transactionAttributes">
    			<props>
    				<prop key="loadAll*">PROPAGATION_REQUIRED,readOnly</prop>
    			</props>
    		</property>
    	</bean>

    Here is the stack trace.
    Code:
     
    [ERROR,FdmApp,AWT-EventQueue-0] Exception on AWT Event Thread
    org.hibernate.HibernateException: No Hibernate Session bound to thread, and conf
    iguration does not allow creation of non-transactional one here
            at org.springframework.orm.hibernate3.AbstractSessionFactoryBean$Transac
    tionAwareInvocationHandler.invoke(AbstractSessionFactoryBean.java:299)
            at $Proxy0.getCurrentSession(Unknown Source)
    Dao.java
    Code:
     
    
      public void loadAll() {  
        	Session session = sessionFactory.getCurrentSession(); <-- fails here
      }
    Application Log
    Code:
    [INFO,DefaultViewDescriptor,main] This labeled object's display name is not conf
    igured; returning 'displayName'
    [INFO,DefaultApplicationObjectConfigurer,main] Labeled property message code 'in
    itialView.description' does not exist in message bundle; continuing...
    [INFO,DefaultApplicationObjectConfigurer,main] Labelable bean's image 'initialVi
    ew.image' does not exist in image bundle; continuing...
    [INFO,OracleDataSourceWrapper,main] Enabling connection cache
    [INFO,OracleDataSourceWrapper,main] Cache properties:{MinLimit=0, ConnectionWait
    Timeout=120, MaxLimit=1, InitialLimit=0, InactivityTimeout=120}
    [INFO,OracleDataSourceWrapper,main] afterPropertiesSet: (jdbc:oracle:thin:@nycv-
    dev.ny.bzwint.com:1521:cvdnyd01): JDBC driver version is 10.1.0.5.0
    [INFO,Environment,main] Hibernate 3.2.5
    [INFO,Environment,main] hibernate.properties not found
    [INFO,Environment,main] Bytecode provider name : cglib
    [INFO,Environment,main] using JDK 1.4 java.sql.Timestamp handling
    [INFO,HbmBinder,main] Mapping class: xxxxxxx
    [INFO,HbmBinder,main] Mapping class: xxxxxxx
    [INFO,LocalSessionFactoryBean,main] Building new Hibernate SessionFactory
    [INFO,ConnectionProviderFactory,main] Initializing connection provider: org.spri
    ngframework.orm.hibernate3.LocalDataSourceConnectionProvider
    [INFO,SettingsFactory,main] RDBMS: Oracle, version: Oracle Database 10g Enterpri
    se Edition Release 10.1.0.5.0 - 64bit Production
    With the Partitioning and Data Mining options
    [INFO,SettingsFactory,main] JDBC driver: Oracle JDBC driver, version: 10.1.0.5.0
    
    [INFO,Dialect,main] Using dialect: org.hibernate.dialect.OracleDialect
    [WARN,Oracle9Dialect,main] The Oracle9Dialect dialect has been deprecated; use e
    ither Oracle9iDialect or Oracle10gDialect instead
    [WARN,OracleDialect,main] The OracleDialect dialect has been deprecated; use Ora
    cle8iDialect instead
    [INFO,TransactionFactoryFactory,main] Using default transaction strategy (direct
     JDBC transactions)
    [INFO,TransactionManagerLookupFactory,main] No TransactionManagerLookup configur
    ed (in JTA environment, use of read-write or transactional second-level cache is
     not recommended)
    [INFO,SettingsFactory,main] Automatic flush during beforeCompletion(): disabled
    [INFO,SettingsFactory,main] Automatic session close at end of transaction: disab
    led
    [INFO,SettingsFactory,main] JDBC batch size: 15
    [INFO,SettingsFactory,main] JDBC batch updates for versioned data: disabled
    [INFO,SettingsFactory,main] Scrollable result sets: enabled
    [INFO,SettingsFactory,main] JDBC3 getGeneratedKeys(): disabled
    [INFO,SettingsFactory,main] Connection release mode: on_close
    [INFO,SettingsFactory,main] Default batch fetch size: 1
    [INFO,SettingsFactory,main] Generate SQL with comments: disabled
    [INFO,SettingsFactory,main] Order SQL updates by primary key: disabled
    [INFO,SettingsFactory,main] Order SQL inserts for batching: disabled
    [INFO,SettingsFactory,main] Query translator: org.hibernate.hql.ast.ASTQueryTran
    slatorFactory
    [INFO,ASTQueryTranslatorFactory,main] Using ASTQueryTranslatorFactory
    [INFO,SettingsFactory,main] Query language substitutions: {}
    [INFO,SettingsFactory,main] JPA-QL strict compliance: disabled
    [INFO,SettingsFactory,main] Second-level cache: enabled
    [INFO,SettingsFactory,main] Query cache: disabled
    [INFO,SettingsFactory,main] Cache provider: org.hibernate.cache.NoCacheProvider
    [INFO,SettingsFactory,main] Optimize cache for minimal puts: disabled
    [INFO,SettingsFactory,main] Structured second-level cache entries: disabled
    [INFO,SettingsFactory,main] Echoing all SQL to stdout
    [INFO,SettingsFactory,main] Statistics: disabled
    [INFO,SettingsFactory,main] Deleted entity synthetic identifier rollback: disabl
    ed
    [INFO,SettingsFactory,main] Default entity-mode: pojo
    [INFO,SettingsFactory,main] Named query checking : enabled
    [INFO,SessionFactoryImpl,main] building session factory
    [INFO,SessionFactoryObjectFactory,main] Not binding factory to JNDI, no JNDI nam
    e configured
    Thank you.
    Kanugula.

  • #2
    Is it possible to see the full stack trace? Are you using BeanFactory or ApplicaitionContext? Is it possible to see the code that is referencing the transactional bean?

    Comment


    • #3
      That sounds like my problem too

      Originally posted by vkanugula View Post
      Hello,

      I searched the entire forum, still I could n't fix my problem.
      I believe I don't have to use AOP target. A simple TransactionProxyFactoryBean should be suffice to bound the Hibernate Session transactionally. Let me know if I am missing any other configuration?

      Software:
      Code:
       
      Spring RCP-Richclient 0.2.0
      Spring 2.0
      Hibernate 3.0 
      Oracle 10g
      Jdk1.4
      Mine is a Swing based client using Spring's RCP, means it is a standalone application.

      Code:
       
      
      	<!-- Oracle Implicit Connection Pool DataSource (Not a JNDI datasource)-->     
        	<bean id="dataSource" ref="oracleDataSource" /> 
      	  	
      	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
      		<property name="dataSource" ref="dataSource"/>
      		<property name="mappingResources">
      			<list>
      				<value>Test.hbm.xml</value>
      			</list>
      		</property>
      		<property name="hibernateProperties">
      			<props> 
                		<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop> 
               	 	<prop key="current_session_context_class">thread</prop> 
               	 	<prop key="hibernate.show_sql">true</prop> 
             		</props> 		
      		</property>				
      	</bean> 	
        		
      	<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">	
      	 	<property name="sessionFactory" ref="sessionFactory" /> 
      	</bean>	
      	
          <bean id="myDao" class="com.test.MyDao">
              <property name="sessionFactory" ref="sessionFactory"/>  
          </bean>
      
      	<bean id="myService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
      		<property name="transactionManager" ref="txManager"/>
      		<property name="target" ref="myDao"/>			
      		<property name="transactionAttributes">
      			<props>
      				<prop key="loadAll*">PROPAGATION_REQUIRED,readOnly</prop>
      			</props>
      		</property>
      	</bean>

      Here is the stack trace.
      Code:
       
      [ERROR,FdmApp,AWT-EventQueue-0] Exception on AWT Event Thread
      org.hibernate.HibernateException: No Hibernate Session bound to thread, and conf
      iguration does not allow creation of non-transactional one here
              at org.springframework.orm.hibernate3.AbstractSessionFactoryBean$Transac
      tionAwareInvocationHandler.invoke(AbstractSessionFactoryBean.java:299)
              at $Proxy0.getCurrentSession(Unknown Source)
      Dao.java
      Code:
       
      
        public void loadAll() {  
          	Session session = sessionFactory.getCurrentSession(); <-- fails here
        }
      Application Log
      Code:
      [INFO,DefaultViewDescriptor,main] This labeled object's display name is not conf
      igured; returning 'displayName'
      [INFO,DefaultApplicationObjectConfigurer,main] Labeled property message code 'in
      itialView.description' does not exist in message bundle; continuing...
      [INFO,DefaultApplicationObjectConfigurer,main] Labelable bean's image 'initialVi
      ew.image' does not exist in image bundle; continuing...
      [INFO,OracleDataSourceWrapper,main] Enabling connection cache
      [INFO,OracleDataSourceWrapper,main] Cache properties:{MinLimit=0, ConnectionWait
      Timeout=120, MaxLimit=1, InitialLimit=0, InactivityTimeout=120}
      [INFO,OracleDataSourceWrapper,main] afterPropertiesSet: (jdbc:oracle:thin:@nycv-
      dev.ny.bzwint.com:1521:cvdnyd01): JDBC driver version is 10.1.0.5.0
      [INFO,Environment,main] Hibernate 3.2.5
      [INFO,Environment,main] hibernate.properties not found
      [INFO,Environment,main] Bytecode provider name : cglib
      [INFO,Environment,main] using JDK 1.4 java.sql.Timestamp handling
      [INFO,HbmBinder,main] Mapping class: xxxxxxx
      [INFO,HbmBinder,main] Mapping class: xxxxxxx
      [INFO,LocalSessionFactoryBean,main] Building new Hibernate SessionFactory
      [INFO,ConnectionProviderFactory,main] Initializing connection provider: org.spri
      ngframework.orm.hibernate3.LocalDataSourceConnectionProvider
      [INFO,SettingsFactory,main] RDBMS: Oracle, version: Oracle Database 10g Enterpri
      se Edition Release 10.1.0.5.0 - 64bit Production
      With the Partitioning and Data Mining options
      [INFO,SettingsFactory,main] JDBC driver: Oracle JDBC driver, version: 10.1.0.5.0
      
      [INFO,Dialect,main] Using dialect: org.hibernate.dialect.OracleDialect
      [WARN,Oracle9Dialect,main] The Oracle9Dialect dialect has been deprecated; use e
      ither Oracle9iDialect or Oracle10gDialect instead
      [WARN,OracleDialect,main] The OracleDialect dialect has been deprecated; use Ora
      cle8iDialect instead
      [INFO,TransactionFactoryFactory,main] Using default transaction strategy (direct
       JDBC transactions)
      [INFO,TransactionManagerLookupFactory,main] No TransactionManagerLookup configur
      ed (in JTA environment, use of read-write or transactional second-level cache is
       not recommended)
      [INFO,SettingsFactory,main] Automatic flush during beforeCompletion(): disabled
      [INFO,SettingsFactory,main] Automatic session close at end of transaction: disab
      led
      [INFO,SettingsFactory,main] JDBC batch size: 15
      [INFO,SettingsFactory,main] JDBC batch updates for versioned data: disabled
      [INFO,SettingsFactory,main] Scrollable result sets: enabled
      [INFO,SettingsFactory,main] JDBC3 getGeneratedKeys(): disabled
      [INFO,SettingsFactory,main] Connection release mode: on_close
      [INFO,SettingsFactory,main] Default batch fetch size: 1
      [INFO,SettingsFactory,main] Generate SQL with comments: disabled
      [INFO,SettingsFactory,main] Order SQL updates by primary key: disabled
      [INFO,SettingsFactory,main] Order SQL inserts for batching: disabled
      [INFO,SettingsFactory,main] Query translator: org.hibernate.hql.ast.ASTQueryTran
      slatorFactory
      [INFO,ASTQueryTranslatorFactory,main] Using ASTQueryTranslatorFactory
      [INFO,SettingsFactory,main] Query language substitutions: {}
      [INFO,SettingsFactory,main] JPA-QL strict compliance: disabled
      [INFO,SettingsFactory,main] Second-level cache: enabled
      [INFO,SettingsFactory,main] Query cache: disabled
      [INFO,SettingsFactory,main] Cache provider: org.hibernate.cache.NoCacheProvider
      [INFO,SettingsFactory,main] Optimize cache for minimal puts: disabled
      [INFO,SettingsFactory,main] Structured second-level cache entries: disabled
      [INFO,SettingsFactory,main] Echoing all SQL to stdout
      [INFO,SettingsFactory,main] Statistics: disabled
      [INFO,SettingsFactory,main] Deleted entity synthetic identifier rollback: disabl
      ed
      [INFO,SettingsFactory,main] Default entity-mode: pojo
      [INFO,SettingsFactory,main] Named query checking : enabled
      [INFO,SessionFactoryImpl,main] building session factory
      [INFO,SessionFactoryObjectFactory,main] Not binding factory to JNDI, no JNDI nam
      e configured
      Thank you.
      Kanugula.

      Comment


      • #4
        I've answered the other post, I guess you might both be having the same problem and thus the same cause.
        http://forum.springframework.org/sho...d.php?p=147974

        Comment

        Working...
        X