<h:form prependId="false">
<p:dialog header="Area restrita"
modal="true"
closable="false"
position="center"
widgetVar="modalLogin"
minWidth="300"
width="300"
showEffect="slide"
draggable="false"
resizable="false"
visible="true">
<center>
<p:messages id="mensagens" showDetail="true" showSummary="false" />
<h:panelGrid columns="2">
<h:outputLabel value="Login" />
<h:inputText id="j_username" size="15" />
<h:outputLabel value="Senha" />
<h:inputSecret id="j_password" size="15" />
</h:panelGrid>
<br />
<h:commandButton value="Entrar" action="#{loginMB.logar}" />
</center>
</p:dialog>
</h:form>
public String logar() {
try {
RequestDispatcher dispatcher = FacesUtil.getServletRequest().getRequestDispatcher("/j_spring_security_check");
dispatcher.forward(FacesUtil.getServletRequest(), FacesUtil.getServletResponse());
FacesContext.getCurrentInstance().responseComplete();
} catch (Exception ex) {
FacesUtil.exibirMensagemErro(ex.getMessage());
return null;
}
return null;
}
public String logout() {
FacesUtil.exibirMensagemAlerta("Sess�o finalizada com sucesso");
try {
RequestDispatcher dispatcher = FacesUtil.getServletRequest().getRequestDispatcher("/j_spring_security_logout");
dispatcher.forward(FacesUtil.getServletRequest(), FacesUtil.getServletResponse());
FacesContext.getCurrentInstance().responseComplete();
} catch (Exception ex) {
FacesUtil.exibirMensagemErro("Erro ao sair do sistema");
return null;
}
return null;
}
@Service("hibernateUserDetailsService")
public class HibernateUserDetailsService extends HibernateDaoSupport implements UserDetailsService {
@Autowired
public HibernateUserDetailsService(SessionFactory sessionFactory) {
setSessionFactory(sessionFactory);
}
@SuppressWarnings("unchecked")
@Override
public UserDetails loadUserByUsername(String login) {
DetachedCriteria criteria = DetachedCriteria.forClass(Usuario.class, "usuario");
criteria.add(Restrictions.eq("usuario.login", login));
List resultado = getHibernateTemplate().findByCriteria(criteria);
if(resultado != null && resultado.size() == 0) {
throw new UsernameNotFoundException("Usuario nao encontrado!");
}
return (Usuario)resultado.get(0);
}
}
<bean class="springframework.orm.hibernate3.HibernateExceptionTranslator"/>
<bean id="sessionFactory" class="springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
<value>br.com.exemploseguranca.entity.Usuario</value>
<value>br.com.exemploseguranca.entity.Perfil</value>
<value>br.com.exemploseguranca.entity.Carreta</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-2) Context initialization failed: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'hibernateUserDetailsService' defined in "/C:/jboss-as-7.1.1.Final/standalone/deployments/seguranca.war/WEB-INF/classes/br/com/exemploseguranca/service/HibernateUserDetailsService.class": Unsatisfied dependency expressed through constructor argument with index 0 of type [org.hibernate.SessionFactory]: : Cannot find class [springframework.orm.hibernate3.HibernateExceptionTranslator] for bean with name 'springframework.orm.hibernate3.HibernateExceptionTranslator#0' defined in ServletContext resource [/WEB-INF/spring-config.xml]; nested exception is java.lang.ClassNotFoundException: springframework.orm.hibernate3.HibernateExceptionTranslator from [Module "deployment.seguranca.war:main" from Service Module Loader]; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [springframework.orm.hibernate3.HibernateExceptionTranslator] for bean with name 'springframework.orm.hibernate3.HibernateExceptionTranslator#0' defined in ServletContext resource [/WEB-INF/spring-config.xml]; nested exception is java.lang.ClassNotFoundException: springframework.orm.hibernate3.HibernateExceptionTranslator from [Module "deployment.seguranca.war:main" from Service Module Loader]
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [springframework.orm.hibernate3.HibernateExceptionTranslator] for bean with name 'springframework.orm.hibernate3.HibernateExceptionTranslator#0' defined in ServletContext resource [/WEB-INF/spring-config.xml]; nested exception is java.lang.ClassNotFoundException: springframework.orm.hibernate3.HibernateExceptionTranslator from [Module "deployment.seguranca.war:main" from Service Module Loader]
Caused by: java.lang.ClassNotFoundException: springframework.orm.hibernate3.HibernateExceptionTranslator from [Module "deployment.seguranca.war:main" from Service Module Loader]
Alguém pode me ajudar????