Java EE ベースのアプリケーションで基本的なフォーム ベースの認証を実装しようとしています。保護されたリソースにアクセスしようとすると、ページをログイン ページにリダイレクトできますが、正しい [tomcat-users.xml で利用可能なエントリ] ユーザー名とパスワードを入力しても、エラー ページが読み込まれます。以下のコード スニペットを見つけてください。
Web.xml
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/loginError.jsp</form-error-page>
</form-login-config>
<session-config>
<session-timeout>5</session-timeout>
</session-config>
<security-role>
<role-name>user</role-name>
</security-role>
<security-constraint>
<web-resource-collection>
<web-resource-name>J2EEApp</web-resource-name>
<description> accessible by authorised users </description>
<url-pattern>/user/*</url-pattern>
<http-method>PUT</http-method>
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<description>These are the roles who have access</description>
<role-name>user</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>GuestPages</web-resource-name>
<description> accessible by un-authorised users </description>
<url-pattern>/guest/*</url-pattern>
</web-resource-collection>
</security-constraint>
</web-app>
login.jsp
<div id="container">
<jsp:include page="header.jsp"></jsp:include>
<div id="body">
<form method="post" id="post" action="j_security_check" name="input">
<label id ="label">Username<sup>*</sup> </label>
<input id ="input" type="text" name="j_username" value=""><br><br>
<label id="label">Password<sup>*</sup> </label>
<input id="input" type="password" name="j_password" value=""><br><br>
<input id="input" type="submit" name="submit" value="login">
<a id="link" href="${pageContext.request.contextPath}/guest/menu">Guest</a>
</form>
</div>
サーバー.xml
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase">
</Realm>
tomcat-users.xml
<role rolename="user"/>
<user username="shubham" password="shubham" roles="user"/>
<user username="user1" password="user1" roles="user"/>
localhost:8080/user/menu に移動すると、login.jsp が期待どおりに表示されますが、正しいユーザー名パスワードを使用すると、loginError.jsp に移動します。
問題の特定にご協力ください。