You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by wasalto <wa...@hotmail.com> on 2011/08/04 16:30:48 UTC

Unable to use spring embedded database

Hi,

I am trying to use an HSQL database but when i try to log in nothing happen.
It doesn't seem that the database is queried. I am using spring and shiro,
here is my application context file:

        <bean id="shiroFilter"
class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
                <property name="securityManager" ref="securityManager" />

                <property name="loginUrl" value="/login.jsp" />
                <property name="successUrl" value="/index.jsp" />
                <property name="unauthorizedUrl" value="/unauthorized.jsp"
/>

                <property name="filterChainDefinitions">
                        <value>
                                /secure/** = authc
                        </value>
                </property>
        </bean>

        <bean id="securityManager"
class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
                <property name="realm" ref="myRealm" />
                <property name="sessionMode" value="native" />
        </bean>

        <bean id="lifecycleBeanPostProcessor"
class="org.apache.shiro.spring.LifecycleBeanPostProcessor" />

        <bean id="myRealm" class="org.apache.shiro.realm.jdbc.JdbcRealm">
                <property name="dataSource" ref="dataSource" />
                <property name="userRolesQuery"
                        value="select authority from authorities where
username = ?" />
        </bean>

        <jdbc:embedded-database id="dataSource" type="HSQL">
                <jdbc:script location="classpath:security-schema.sql" />
                <jdbc:script location="classpath:test-data.sql" />
        </jdbc:embedded-database>


--
View this message in context: http://shiro-user.582556.n2.nabble.com/Unable-to-use-spring-embedded-database-tp6652955p6652955.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: Unable to use spring embedded database

Posted by wasalto <wa...@hotmail.com>.
Ok thank you that was the problem. Now it works perfectly. :)

--
View this message in context: http://shiro-user.582556.n2.nabble.com/Unable-to-use-spring-embedded-database-tp6652955p6655600.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: Unable to use spring embedded database

Posted by Jared Bunting <ja...@peachjean.com>.
Without more information I can't say for sure, but I think your issue is
related to your filter chains.

In order for the authc filter to process a login, it has to filter the
request to the login page.  So, it appears to me that authc will only
filter request in /secure/**, but /login.jsp doesn't match that.  So,
when /login.jsp is submitted, the authc filter is never invoked, and
therefore your database is never queried.

So, configure your filter chains such that a request to /login.jsp will
hit authc.

-Jared

On 08/04/2011 09:30 AM, wasalto wrote:
> Hi,
>
> I am trying to use an HSQL database but when i try to log in nothing happen.
> It doesn't seem that the database is queried. I am using spring and shiro,
> here is my application context file:
>
>         <bean id="shiroFilter"
> class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
>                 <property name="securityManager" ref="securityManager" />
>
>                 <property name="loginUrl" value="/login.jsp" />
>                 <property name="successUrl" value="/index.jsp" />
>                 <property name="unauthorizedUrl" value="/unauthorized.jsp"
> />
>
>                 <property name="filterChainDefinitions">
>                         <value>
>                                 /secure/** = authc
>                         </value>
>                 </property>
>         </bean>
>
>         <bean id="securityManager"
> class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
>                 <property name="realm" ref="myRealm" />
>                 <property name="sessionMode" value="native" />
>         </bean>
>
>         <bean id="lifecycleBeanPostProcessor"
> class="org.apache.shiro.spring.LifecycleBeanPostProcessor" />
>
>         <bean id="myRealm" class="org.apache.shiro.realm.jdbc.JdbcRealm">
>                 <property name="dataSource" ref="dataSource" />
>                 <property name="userRolesQuery"
>                         value="select authority from authorities where
> username = ?" />
>         </bean>
>
>         <jdbc:embedded-database id="dataSource" type="HSQL">
>                 <jdbc:script location="classpath:security-schema.sql" />
>                 <jdbc:script location="classpath:test-data.sql" />
>         </jdbc:embedded-database>
>
>
> --
> View this message in context: http://shiro-user.582556.n2.nabble.com/Unable-to-use-spring-embedded-database-tp6652955p6652955.html
> Sent from the Shiro User mailing list archive at Nabble.com.