Shiro Issue with spring boot and hibernate

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Shiro Issue with spring boot and hibernate

sandy.deng
Hi All,
 
As i interation with spring boot 2, hibernate 5, shiro 1.4, some exception
was happend as below:
 
/Caused by: org.springframework.beans.BeanInstantiationException: Failed to
instantiate [org.apache.shiro.session.mgt.SessionManager]: Factory method
'sessionManager' threw exception; nested exception is
java.lang.ClassCastException:
org.springframework.orm.hibernate5.LocalSessionFactoryBean$$EnhancerBySpringCGLIB$$d6b39340
cannot be cast to org.apache.shiro.session.mgt.SessionFactory/
 
means spring used the hibernate's sessionFactory, i guess that the reason
 
@Bean
    @ConditionalOnMissingBean
    @Override
    protected SessionFactory sessionFactory() {
        return super.sessionFactory();
    }
The above issue happened when used the configuration
/shiro.userNativeSessionManager = true./
 
 
anyone can help me a little tips?
 
thanks



--
Sent from: http://shiro-user.582556.n2.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Shiro Issue with spring boot and hibernate

sandy.deng
/<bean <b>id="sessionFactory"*
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="hibernateProperties">
            <props>
                <prop
key="hibernate.dialect">${spring.jpa.properties.hibernate.dialect}</prop>
                <prop key="hibernate.show_sql">${spring.jpa.show-sql}</prop>
                <prop
key="hibernate.hbm2ddl.auto">${spring.jpa.hbm2ddl}</prop>                
                <prop
key="hibernate.current_session_context_class">${spring.jpa.properties.hibernate.current_session_context_class}</prop>
            </props>
        </property>
    </bean> /

this section was defined in data-source.xml, so, i removed the
*id="sessionFactory"* .
finally, it worked.



--
Sent from: http://shiro-user.582556.n2.nabble.com/