Pessoal, bom dia!
Estou montando uma aplicação com struts2, e para a parte de login estou utilizando o JAAS, para deixar o toncat responsável por efetuar esta tarefa. Minha aplicação ainda é basica, porem estou com uma dificuldade que nao consigo superar.
A lógica é a seguinte:
Ao entrar no site, o usuário é redirecionado para uma página protegida, e precisa fazer login para ter acesso a esta página. Apos o login, ele pode efetuar acesso normalmente ao site, porem nao é isso que acontece. Durante o redirecionamento, é gerada uma exception e não consigo de jeito nenhum arrumar! Alguem tem alguma ideia?
Seguem códigos:
index.jsp
<% response.sendRedirect("/S2Starter/jsp/home.jsp"); %>
jsp/home.jsp
<body>
Welcome <s:property value="id"/>
</body>
login.jsp
<head>
<title>Sign In</title>
<s:head />
</head>
<body>
<s:form action="j_security_check">
<s:textfield label="Fratechs login" name="j_username" />
<s:password label="Password" name="j_password" />
<s:submit />
</s:form>
</body>
web.xml
<web-app id="starter" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>S2Sterter - Task Control System</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext*.xml</param-value>
</context-param>
<!-- Filters -->
<filter>
<filter-name>action2-cleanup</filter-name>
<filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
</filter>
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
</filter>
<filter>
<filter-name>action2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>action2-cleanup</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>action2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Listeners -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Servlets -->
<servlet>
<servlet-name>jspSupportServlet</servlet-name>
<servlet-class>org.apache.struts2.views.JspSupportServlet</servlet-class>
<load-on-startup>5</load-on-startup>
</servlet>
<!-- Welcome file lists -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<security-constraint>
<web-resource-collection>
<web-resource-name>AllPages</web-resource-name>
<description>All Pages under jsp directory</description>
<url-pattern>/jsp/*</url-pattern>
<http-method>POST</http-method>
<http-method>GET</http-method>
</web-resource-collection>
<auth-constraint>
<description>All roles can access that</description>
<role-name>ADMIN</role-name>
<role-name>RESOURCE</role-name>
<role-name>CLIENT</role-name>
<role-name>MANAGER</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<role-name>ADMIN</role-name>
</security-role>
<security-role>
<role-name>RESOURCE</role-name>
</security-role>
<security-role>
<role-name>MANAGER</role-name>
</security-role>
<security-role>
<role-name>CLIENT</role-name>
</security-role>
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/login.jsp</form-error-page>
</form-login-config>
</login-config>
</web-app>
context.xml
<Resource
name="meuBD"
auth="Container"
type="javax.sql.DataSource"
driverClassName="org.gjt.mm.mysql.Driver"
url="jdbc:mysql://localhost/s2starter?autoReconnect=true"
username="root"
password=""
maxActive="30"
maxIdle="10"
maxWait="-1"/>
<Realm className="org.apache.catalina.realm.DataSourceRealm"
name="meuDBjdbc"
localDataSource="true"
debug="99"
dataSourceName="meuBD"
driverName="org.gjt.mm.mysql.Driver"
connectionURL="jdbc:mysql://localhost/s2starter?autoReconnect=true"
connectionName="root"
connectionPassword=""
userTable="user"
userNameCol="login"
userCredCol="password"
userRoleTable="user"
roleNameCol="role"/>
</Context>
Lembrando que caso eu utilize apenas o Struts a aplicação funciona normalmente. Fiz um teste apenas com JAAS e tambem funciona. Só nao estou conseguindo integrar os 2 frameworks… alguma ideia?