-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: use Spring-CXF, get "No Hibernate Session bound to thread"
PostPosted: Thu May 24, 2012 2:52 am 
Newbie

Joined: Thu May 24, 2012 2:38 am
Posts: 1
Hello everyone, i got a problem
I use spring-cxf in a webservice project.
Server side:Spring+CXF+Hibernate
Client side:Spring+CXF

And I got a exception when my client send a request to server
Code:
org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here 


If i use jdbctemplate instead of hibernate, everything is OK.
Or if i don't use webservice, everything is OK.

springContext.xml
Code:
    <bean id="sessionFactory" 
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> 
        <property name="dataSource" ref="dataSource" /> 
        <property name="hibernateProperties"> 
            <props> 
                <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop> 
                <prop key="hibernate.show_sql">true</prop> 
            </props> 
        </property> 
        <property name="mappingResources"> 
            <list> 
                <value>/hbm/UserInfo.hbm.xml</value> 
            </list> 
        </property> 
    </bean> 
    <bean id="transactionManager" 
        class="org.springframework.orm.hibernate3.HibernateTransactionManager"> 
        <property name="sessionFactory"> 
            <ref local="sessionFactory" /> 
        </property> 
        <property name="nestedTransactionAllowed"> 
            <value>true</value> 
        </property> 
    </bean> 
     
    <tx:advice id="txWorksysAdvice" 
        transaction-manager="transactionManager"> 
        <tx:attributes> 
            <tx:method name="*" propagation="REQUIRED" 
                rollback-for="Exception" /> 
        </tx:attributes> 
    </tx:advice> 
     
    <aop:config proxy-target-class="true"> 
        <aop:advisor 
            pointcut="execution(* com.test.services..*.*Service.*(..))" 
            advice-ref="txWorksysAdvice" /> 
    </aop:config> 


cxf-server.xml
Code:
    <import resource="classpath:META-INF/cxf/cxf.xml" /> 
    <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> 
    <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" /> 
     
    <jaxws:endpoint address="/testservice"> 
        <jaxws:implementor ref="testService" /> 
    </jaxws:endpoint> 
     
    <bean id="testService" class="com.test.ws.impl.TestServiceImpl" /> 


cxf-clent.xml
Code:
    <import resource="classpath:META-INF/cxf/cxf.xml" /> 
    <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> 
    <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" /> 
     
    <jaxws:client id="clientService" serviceClass="com.test.ws.TestService" 
        address="http://localhost:8080/testcxf/ws/testservice" /> 


My dao code
Code:
    public Session getSession() { 
        return sessionFactory.getCurrentSession(); 
    } 


client code
Code:
    public static void main(String[] args) { 
        ApplicationContext ctx = new ClassPathXmlApplicationContext( 
                "spring/haha-ws-client.xml"); 
        SearchService sss = ctx.getBean(SearchService.class); 
        sss.insertData("字符abc123"); 
    } 


Anyone can help me ? thanks a lot.


Top
 Profile  
 
 Post subject: Re: use Spring-CXF, get "No Hibernate Session bound to thread"
PostPosted: Sun Apr 21, 2013 3:10 pm 
Newbie

Joined: Sun Apr 21, 2013 3:08 pm
Posts: 1
hi shingo,

Did you manage to solve the problem?

Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.