При запуске теста я получаю следующую ошибку. Я не понимаю, как я новичок в shiro.Please Помогите мнеИнициализировать ошибку исключения в Apache Shiro
enter code herejava.lang.ExceptionInInitializerError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:534)
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:195)
at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:244)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:241)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.apache.shiro.config.ConfigurationException: Unable to instantiate class [javax.sql.DataSource] for object named 'ds'. Please ensure you've specified the fully qualified class name correctly.
at org.apache.shiro.config.ReflectionBuilder.createNewInstance(ReflectionBuilder.java:151)
at org.apache.shiro.config.ReflectionBuilder.buildObjects(ReflectionBuilder.java:119)
at org.apache.shiro.config.IniSecurityManagerFactory.buildInstances(IniSecurityManagerFactory.java:161)
at org.apache.shiro.config.IniSecurityManagerFactory.createSecurityManager(IniSecurityManagerFactory.java:124)
at org.apache.shiro.config.IniSecurityManagerFactory.createSecurityManager(IniSecurityManagerFactory.java:102)
at org.apache.shiro.config.IniSecurityManagerFactory.createInstance(IniSecurityManagerFactory.java:88)
at org.apache.shiro.config.IniSecurityManagerFactory.createInstance(IniSecurityManagerFactory.java:46)
at org.apache.shiro.config.IniFactorySupport.createInstance(IniFactorySupport.java:123)
at com.advi.test.shiro.TestShiro.<clinit>(TestShiro.java:23)
... 22 more
Caused by: org.apache.shiro.util.InstantiationException: Unable to instantiate class [javax.sql.DataSource]
at org.apache.shiro.util.ClassUtils.newInstance(ClassUtils.java:179)
at org.apache.shiro.util.ClassUtils.newInstance(ClassUtils.java:164)
at org.apache.shiro.config.ReflectionBuilder.createNewInstance(ReflectionBuilder.java:144)
... 30 more
Caused by: java.lang.InstantiationException: javax.sql.DataSource
at java.lang.Class.newInstance(Class.java:359)
at org.apache.shiro.util.ClassUtils.newInstance(ClassUtils.java:177)
... 32 more
и это shiro.ini файл .Please дайте мне знать, что ошибка я сделал
#myRealm = MyRealm
#myRealm.credentialsMatcher = $myRealmCredentialsMatcher
ps = org.apache.shiro.authc.credential.DefaultPasswordService
pm = org.apache.shiro.authc.credential.PasswordMatcher
pm.passwordService = $ps
aa = org.apache.shiro.authc.credential.AllowAllCredentialsMatcher
sm = org.apache.shiro.authc.credential.SimpleCredentialsMatcher
#jof = org.apache.shiro.jndi.JndiObjectFactory
#jof.resourceName = jdbc/UserDB
#jof.requiredType = javax.sql.DataSource
#jof.resourceRef = true
#; Note factories are automatically invoked via getInstance(),
#; see org.apache.shiro.authc.config.ReflectionBuilder::resolveReference
#jdbcRealm.dataSource = $jof
ds = javax.sql.DataSource
ds.url = jdbc:mysql://192.168.1.111:3306/Test
ds.user = dbuser
ds.password = dbuser
jdbcRealm = org.apache.shiro.realm.jdbc.JdbcRealm
#realm.permissionsLookupEnabled = true
jdbcRealm.credentialsMatcher = $pm
jdbcRealm.dataSource = $ds
securityManager.realms = $jdbcRealm
jdbcRealm = org.apache.shiro.realm.jdbc.JdbcRealm
#ds = javax.sql.DataSource
#ds.url = jdbc:mysql://192.168.1.111:3306/Test
#ds.user = dbuser
#ds.password = dbuser
#jdbcRealm.dataSource = $ds
# Configure JDBC realm SQL queries.
jdbcRealm.authenticationQuery = select pass from users where name = ?;
sha256Matcher = org.apache.shiro.authc.credential.HashedCredentialsMatcher
sha256Matcher.hashAlgorithmName=SHA-256
# enable matcher in iniRealm (object responsible for authentication)
iniRealm.credentialsMatcher = $sha256Matcher
Это говорит его не может инициировать java.sql.datasource..what я должен сделать, чтобы начать что
Спасибо за ответ, но когда я использую выше два источника данных codes.And появляется та же ошибка, даже у меня есть MYSQL разъем баночку файл –
действительно такая же ошибка? – burna
да .. но я разрешил ошибку с помощью [this] (http://jolbox.com/) и со ссылкой на http://shiro-user.582556.n2.nabble.com/Shiro-Jdbc-Realm- Mysql-td6519616.html –