You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by "sandy.deng" <sa...@skywares.com> on 2017/11/22 03:39:12 UTC
Shiro Issue with spring boot and hibernate
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/
Re: Shiro Issue with spring boot and hibernate
Posted by "sandy.deng" <sa...@skywares.com>.
/<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/