0

I have downloaded the Apache Isis' simple-app archetype 1.15.0. And I would like to integrate it with Apache Shiro following this documentation . But i got some error like this:

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

Have a look at my in my 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>

and my 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

Am i missing something?

paul
  • 372
  • 4
  • 17

1 Answers1

0

This depends on your container. The Apache-Isis doc does have a link to how to configure this on Tomcat though:

Using the above configuration you will also need to setup a DataSource. The details vary by servlet container, for example this is how to do the setup on Tomcat 8.0.

Brian Demers
  • 2,051
  • 1
  • 9
  • 12