0

我已经下载了 Apache Isis 的简单应用原型 1.15.0。我想按照这个文档将它与 Apache Shiro 集成。但我得到了一些这样的错误:

java.lang.IllegalStateException: Unable to look up javax.sql.DataSource with jndi name 'jdbc/postgres'.

看看我的web.xml

<resource-ref>
<description>db</description>
<res-ref-name>jdbc/postgres</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

和我的shiro.ini

jdbcRealm=org.apache.shiro.realm.jdbc.JdbcRealm        

jof = org.apache.shiro.jndi.JndiObjectFactory          
jof.resourceName = jdbc/postgres
jof.requiredType = javax.sql.DataSource
jof.resourceRef = true

jdbcRealm.dataSource = $jof

jdbcRealm.authenticationQuery =         \
        select password                 \
          from users                    \
         where username = ?

jdbcRealm.userRolesQuery =              \
        select r.label                  \
          from users_roles ur           \
    inner join roles r                  \
            on ur.role_id = r.id        \
         where user_id = (              \
            select id                   \
             from users                 \
            where username = ?);        \

jdbcRealm.permissionsQuery=             \
        select p.permission             \
          from roles_permissions rp     \
    inner join permissions p            \
            on rp.permission_id = p.id  \
         where rp.role_id = (           \
            select id                   \
             from roles                 \
            where label = ?);

jdbcRealm.permissionsLookupEnabled=true

dps = org.apache.shiro.authc.credential.DefaultPasswordService
pm = org.apache.shiro.authc.credential.PasswordMatcher
pm.passwordService = $dps
jdbcRealm.credentialsMatcher = $pm

securityManager.realms = $jdbcRealm

我错过了什么吗?

4

1 回答 1

0

这取决于您的容器。Apache-Isis 文档确实有一个链接到如何在 Tomcat 上配置它:

使用上述配置,您还需要设置一个数据源。细节因 servlet 容器而异,例如这是如何在 Tomcat 8.0 上进行设置

于 2017-11-06T17:50:15.983 回答