0
我試圖驗證用戶使用與Cassandra數據庫的春季安全。我得到以下異常:春季安全與卡桑德拉 - TimedOutException
Authentication request failed: org.springframework.security.authentication.AuthenticationServiceException: PreparedStatementCallback; SQL [select email, lastlogin, password, usertype from login where email=?]; TimedOutException(); nested exception is java.sql.SQLTransientConnectionException: TimedOutException()
我厭倦了增加卡桑德拉超時和所有一致性水平。我不明白是什麼導致了這個錯誤,同樣的查詢在Cassandra DevCenter中運行良好。
下面是配置的詳細信息:
二手版本:
<properties>
<java-version>1.7</java-version>
<org.springframework-version>3.2.9.RELEASE</org.springframework-version>
<org.aspectj-version>1.6.10</org.aspectj-version>
<org.slf4j-version>1.6.6</org.slf4j-version>
<cassandra-driver-core.version>1.0.5-dse</cassandra-driver-core.version>
<jackson.databind-version>2.2.3</jackson.databind-version>
<spring.security.version>3.2.3.RELEASE</spring.security.version>
</properties>
卡桑德拉爲扶養pom.xml中:
<dependency>
<groupId>org.apache-extras.cassandra-jdbc</groupId>
<artifactId>cassandra-jdbc</artifactId>
<version>1.2.5</version>
<scope>compile</scope>
</dependency>
Cussandra數據源定義爲春季安全:
<beans:bean id="cassandraDataSource" class="org.apache.cassandra.cql.jdbc.CassandraDataSource">
<beans:constructor-arg name="host" value="${cassandra.contactpoints}"></beans:constructor-arg>
<beans:constructor-arg name="port" type="int" value="${cassandra.thriftport}"></beans:constructor-arg>
<beans:constructor-arg name="keyspace" value="${cassandra.keyspace}"></beans:constructor-arg>
<beans:constructor-arg name="user" value="${cassandra.user}"></beans:constructor-arg>
<beans:constructor-arg name="password" value="${cassandra.password}"></beans:constructor-arg>
<beans:constructor-arg name="version" value="${cassandra.version}"></beans:constructor-arg>
<beans:constructor-arg name="consistency" value="${cassandra.consistency}"></beans:constructor-arg>
</beans:bean>
個Cussandra屬性:
cassandra.contactpoints=127.0.0.1
cassandra.thriftport=9160
cassandra.port=9042
cassandra.keyspace=styling_bee
cassandra.user=cassandra
cassandra.password=cassandra
cassandra.version=2.0.0
cassandra.consistency=ALL
春季安全配置:
<!-- enable use-expressions -->
<http auto-config="true" use-expressions="true">
<intercept-url pattern="/showyourcloset**" access="hasRole('ROLE_CLIENT')" />
<!-- access denied page -->
<access-denied-handler error-page="/403" />
<form-login
login-page="/login"
default-target-url="/"
authentication-failure-url="/login?error"
username-parameter="email"
password-parameter="password" />
<logout logout-success-url="/login?logout" />
<!-- enable csrf protection -->
<csrf/>
</http>
<!-- Select users and user_roles from database -->
<authentication-manager>
<authentication-provider>
<jdbc-user-service
data-source-ref="cassandraDataSource"
users-by-username-query="select email, lastlogin, password, usertype from login where email=?"
authorities-by-username-query="select roleid, email, rolename from user_roles where email=?" />
</authentication-provider>
</authentication-manager>