spring - Hibernate Security error - No Session found for current thread -


i'm trying authenticate user username , password, after keying in user details error page come error:

  login attempt not successful, try again.    reason: no session found current thread 

servlet

   <?xml version="1.0" encoding="utf-8"?>    <beans:beans xmlns="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemalocation="http://www.springframework.org/schema/mvc                 http://www.springframework.org/schema/mvc/spring-mvc.xsd     http://www.springframework.org/schema/beans http://www.springframework.org       /schema/beans/spring-beans.xsd     http://www.springframework.org/schema/tx http://www.springframework.org       /schema/tx/spring-tx.xsd     http://www.springframework.org/schema/context            http://www.springframework.org/schema/context/spring-context.xsd">  <!-- enables spring mvc @controller programming model --> <annotation-driven />  <!-- handles http requests /resources/** efficiently serving static       resources in ${webapproot}/resources directory --> <resources mapping="/resources/**" location="/resources/" />  <!-- resolves views selected rendering @controllers .jsp resources in       /web-inf/views directory --> <beans:bean       class="org.springframework.web.servlet.view.internalresourceviewresolver">     <beans:property name="prefix" value="/web-inf/views/" />     <beans:property name="suffix" value=".jsp" /> </beans:bean>  <context:component-scan base-package="com.myproject.app" />  <!-- activates various annotations detected in bean classes --> <context:annotation-config /> <tx:annotation-driven transaction-manager="transactionmanager" ></tx:annotation-     driven>     </beans:beans> 

applicationcontext

    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:lang="http://www.springframework.org/schema/lang" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p" xmlns:task="http://www.springframework.org/schema/task" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util" xsi:schemalocation = ///// cont    <!-- activates various annotations detected in bean classes --> <context:annotation-config />  <context:component-scan base-package="com.myproject.app.dao" />   <!-- datasource --> <!-- <context:property-placeholder location="classpath:jdbc.properties" /> -->  <bean id="datasource" class="org.springframework.jdbc.datasource.drivermanagerdatasource">  <property name="driverclassname" value="com.mysql.jdbc.driver" /> <property name="url" value="jdbc:mysql://localhost:3306/sectest" /> <property name="username" value="root" /> <property name="password" value="llco12" />    </bean>  <!-- hibernate --> <bean id="sessionfactory"       class="org.springframework.orm.hibernate4.localsessionfactorybean">     <property name="datasource" ref="datasource" />     <property name="annotatedclasses">         <list>             <value>com.myproject.app.model.userentity</value>             <value>com.myproject.app.model.role</value>         </list>     </property>               <property name="hibernateproperties">         <props>             <prop key="hibernate.dialect">org.hibernate.dialect.mysqldialect</prop>             <prop key="hibernate.hbm2ddl.auto">update</prop>             <prop key="hibernate.show_sql">true</prop>          </props>     </property> </bean> <bean id="transactionmanager" class="org.springframework.orm.hibernate4.hibernatetransactionmanager">      <property name="sessionfactory" ref="sessionfactory" /> </bean>   <!-- beans -->  <bean id="userentitydao" class="com.myproject.app.dao.userentitydaoimpl">     <property name="sessionfactory" ref="sessionfactory" /> </bean>   <bean id="roledao" class="com.myproject.app.dao.roledaoimpl">     <property name="sessionfactory" ref="sessionfactory" /> </bean>  <bean id="roleservice" class="com.myproject.app.service.roleserviceimpl">     <property name="roledao" ref="roledao" /> </bean>   </beans> 

dao class

  @repository   @transactional   public class userdaoimpl implements userdao{  @autowired private sessionfactory sessionfactory;     @override @transactional public user getuserbyname(string username) {     // todo auto-generated method stub     user user = (user) sessionfactory.getcurrentsession().createquery(              "select u userentity u u.username = '' +         username + ''").uniqueresult();              return user; } 

service

   @service("customuserdetailsservice")     public class customuserdetailsservice implements userdetailsservice{  @autowired private userentitydao userentitydao;  @autowired private assembler assembler;  @override @transactional(readonly = true) public userdetails loaduserbyusername(string username)         throws usernamenotfoundexception {     // todo auto-generated method stub     userdetails userdetails = null;      userentity userentity = userentitydao.getuserbyname(username);      if (userentity == null)      throw new usernamenotfoundexception("user not found");      return assembler.builduserfromuser(userentity);     }} 

i know why session not being found?


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -