Mysql 使用jdbc提供程序在Mule中配置Spring安全性
我有下面的Mule应用程序,我正在尝试使用Spring安全性来保护它,使用数据库为用户提供(jdbc提供程序) 我在Mule应用程序的类路径中正确配置了mysql数据库和mysql jdbc驱动程序,但是当我尝试登录时,我得到了以下错误: 无法获取JDBC连接;嵌套异常为java.sql.SQLException:未找到适合jdbc的驱动程序:mysql://localhost:3306/test (org.springframework.jdbc.CannotGetJdbcConnectionException) org.springframework.jdbc.datasource.DataSourceUtils:80(空) Mule应用程序(基于Mule ESB 3.6.1):Mysql 使用jdbc提供程序在Mule中配置Spring安全性,mysql,spring,security,http,mule,Mysql,Spring,Security,Http,Mule,我有下面的Mule应用程序,我正在尝试使用Spring安全性来保护它,使用数据库为用户提供(jdbc提供程序) 我在Mule应用程序的类路径中正确配置了mysql数据库和mysql jdbc驱动程序,但是当我尝试登录时,我得到了以下错误: 无法获取JDBC连接;嵌套异常为java.sql.SQLException:未找到适合jdbc的驱动程序:mysql://localhost:3306/test (org.springframework.jdbc.CannotGetJdbcConnection
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.6.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mule-ss="http://www.mulesoft.org/schema/mule/spring-security"
xmlns:ss="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/spring-security http://www.mulesoft.org/schema/mule/spring-security/3.1/mule-spring-security.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd
http://www.mulesoft.org/schema/mule/tls http://www.mulesoft.org/schema/mule/tls/current/mule-tls.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.mulesoft.org/schema/mule/https http://www.mulesoft.org/schema/mule/https/current/mule-https.xsd">
<spring:beans>
<spring:bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<spring:property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<spring:property name="url" value="jdbc:mysql://localhost:3306/test"/>
<spring:property name="username" value="root"/>
<spring:property name="password" value="sonar"/>
</spring:bean>
<ss:authentication-manager alias="authenticationManager">
<ss:authentication-provider>
<ss:jdbc-user-service data-source-ref="dataSource"
users-by-username-query=
"select username,password, enabled from users where username=?"
authorities-by-username-query=
"select username, role from user_roles where username =? " />
</ss:authentication-provider>
</ss:authentication-manager>
</spring:beans>
<mule-ss:security-manager>
<mule-ss:delegate-security-provider name="jdbc-provider" delegate-ref="authenticationManager" />
</mule-ss:security-manager>
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration" />
<flow name="SpringExample">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<logger level="INFO" message="## received" doc:name="Logger"/>
<http:basic-security-filter realm="mule-realm" securityProviders="jdbc-provider"/>
<logger level="INFO" message="## passed security" doc:name="Logger"/>
</flow>
</mule>
INFO 2015-03-27 21:31:04,255 [[spring-security-maven].HTTP_Listener_Configuration.worker.01] org.mule.api.processor.LoggerMessageProcessor: ## received
ERROR 2015-03-27 21:31:04,299 [[spring-security-maven].HTTP_Listener_Configuration.worker.01] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Authentication Attempt Failed. Message payload is of type: NullPayload
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. No suitable driver found for jdbc:mysql://localhost:3306/test (java.sql.SQLException)
java.sql.DriverManager:596 (null)
2. Could not get JDBC Connection; nested exception is java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/test (org.springframework.jdbc.CannotGetJdbcConnectionException)
org.springframework.jdbc.datasource.DataSourceUtils:80 (null)
3. Could not get JDBC Connection; nested exception is java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/test (org.springframework.security.authentication.AuthenticationServiceException)
org.springframework.security.authentication.dao.DaoAuthenticationProvider:85 (null)
4. Authentication Attempt Failed. Message payload is of type: NullPayload (org.mule.api.security.UnauthorisedException)
org.mule.security.MuleSecurityManager:91 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/security/UnauthorisedException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/test
at java.sql.DriverManager.getConnection(DriverManager.java:596)
at java.sql.DriverManager.getConnection(DriverManager.java:187)
at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:173)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
这是骡子的问题。将罐子添加到
<MULE_PATH>/mule-standalone-3.x.0/lib/mule
/mule-standalone-3.x.0/lib/mule
及
/AnypointStudio/plugins/org.mule.tooling.server.3.x.xxxx/mule/lib/mule
默认情况下,mole不为各自的数据库连接提供jdbc驱动程序。我们需要显式地将JAR添加到项目开发的类路径中 对我来说是/lib/opt
<MULE_STUDIO_PATH>/AnypointStudio/plugins/org.mule.tooling.server.3.x.xxxx/mule/lib/mule