【发布时间】:2015-02-06 08:38:23
【问题描述】:
我是第一次实现 Spring Security 认证和授权。
当 Spring Security 通过执行以下查询使用 JDBC-USER-SERVICE 进行身份验证时
select username, password, status as enabled from bbp_user where username=?
我收到以下异常
2014-12-08 21:23:23,852 [http-bio-8090-exec-4] DEBUG org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter -
Authentication request failed:
org.springframework.security.authentication.AuthenticationServiceException: **Could not get JDBC
Connection**; nested exception is org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create
PoolableConnectionFactory (Io exception: **The Network Adapter could not establish the connection)
请查找安全 XML 部分
<form-login
login-page="/inventory/auth/login"
default-target-url="/inventory/landing/loadDashBoardPage"
authentication-failure-url="/inventory/auth/login?error"
username-parameter="username"
password-parameter="password" />
<authentication-manager>
<authentication-provider>
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query="select username, password, status as enabled from bbp_user where username=?"
/>
</authentication-provider>
</authentication-manager>
在使用用户名和密码进行身份验证失败时,我已设计重新发布登录页面,并显示“用户名或密码无效”等错误消息。
但是,如何将 JDBC 类型的底层异常重定向到 web.xml 中提到的特定错误页面
<!-- Application Exceptions -->
<error-page>
<!-- Route all exceptions to error page -->
<exception-type>java.lang.Throwable</exception-type>
<location>/Dashboard/jsp/error.jsp</location>
</error-page>
我正在使用 Spring 3.0.5 和 Spring Security 3.1.0 版,仅供参考。
请指教。提前致谢!!
【问题讨论】:
-
你使用的是哪个版本的 Spring?
-
Spring 3.0.5 和 Spring Security 3.1.0