Skip to content
This repository was archived by the owner on Jul 5, 2020. It is now read-only.

shiro with database #25

Open
frodrigues opened this issue Jan 31, 2012 · 1 comment
Open

shiro with database #25

frodrigues opened this issue Jan 31, 2012 · 1 comment
Assignees

Comments

@frodrigues
Copy link

Hello,
I setup shiro.ini to connect with database (mysql) by gives me the following error:

Last cause: No SecurityManager accessible to the calling code, either bound to the org.apache.shiro.util.ThreadContext or as a vm static singleton. This is an invalid application configuration.

my shiro.ini

[main]
jdbcRealm=org.apache.shiro.realm.jdbc.JdbcRealm
jdbcRealm.authenticationQuery = select password from user where username = ?
jdbcRealm.userRolesQuery = select role_id from user_role where user_id = ?

ds = com.mysql.jdbc.Driver
ds.jdbcUrl = jdbc:mysql://localhost:3306/database
ds.username = root
ds.password = ****
ds.databaseName = database
jdbcRealm.dataSource = $ds

@mattbrictson
Copy link
Contributor

@frodrigues, I would have to see the full stack trace to be sure, but that error usually means you are accessing Shiro-related code in your application before the Shiro servlet filter has executed.

Make sure the ShiroFilter is present in your web.xml and that the <filter-mapping> for ShiroFilter it is declared before any other filters that have to do with your application code, like Wicket-, Spring- or Hibernate-related filters.

The Shiro web.xml declarations should look like this:

<filter>
  <filter-name>ShiroFilter</filter-name>
  <filter-class>org.apache.shiro.web.servlet.IniShiroFilter</filter-class>
  <init-param>
    <param-name>configPath</param-name>
    <param-value>classpath:shiro.ini</param-value>
  </init-param>
</filter>

<filter-mapping>
  <filter-name>ShiroFilter</filter-name>
  <url-pattern>/*</url-pattern>
  <dispatcher>REQUEST</dispatcher>
  <dispatcher>ERROR</dispatcher>
</filter-mapping>

@ghost ghost assigned mattbrictson Jan 31, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants