You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shiro.apache.org by "Milos Kolencik (JIRA)" <ji...@apache.org> on 2010/05/20 18:47:20 UTC

[jira] Created: (SHIRO-167) getServletContext allways return null with conf via spring (native mode)

getServletContext allways return null with conf via spring (native mode)
------------------------------------------------------------------------

                 Key: SHIRO-167
                 URL: https://issues.apache.org/jira/browse/SHIRO-167
             Project: Shiro
          Issue Type: Bug
          Components: Integration: Spring
    Affects Versions: 1.0.0
         Environment: sun java, jetty 8.0.0, servelt 3.0 api, win 7
            Reporter: Milos Kolencik
             Fix For: 1.0.0


Hi,
i am using shiro rev. 945078, with configuration which uses native sessions

filter is configured via springframework - DelegatingFilterProxy

(here is the snippet from web.xml)

 	<filter>
 		<filter-name>shiroFilter</filter-name>
 		<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
 	</filter> 

(and here from spring conf. xml)

	<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
	    <property name="securityManager" ref="securityManager"/>
	</bean>
	<bean id="securityManager" class="org.apache.shiro.web.DefaultWebSecurityManager">
		<property name="realm" ref="trustRealm" />
		<property name="subjectFactory" ref="trustSubjectFactory" />
		<property name="sessionMode" value="native" />
		<property name="sessionManager" ref="trustSessionManager" />
		<property name="cacheManager">
			<bean class="org.apache.shiro.cache.MemoryConstrainedCacheManager" />
		</property>
	</bean>


the problem i have is that the method HttpServletRequest.getSession().getServletContext() always return null,

(I was wondering why and i found that the ServletContext is set to AbstractFilter only in init(filterConfig) method.
But this method is never called in configuration via spring-DelegatingFilterProxy. I know that specifying the "targetFilterLifecycle" filter init-param as "true" will enforce invocation of the Filter.init. But this way my definitions will be overrided.)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (SHIRO-167) getServletContext allways return null with conf via spring (native mode)

Posted by "Les Hazlewood (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SHIRO-167?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Les Hazlewood resolved SHIRO-167.
---------------------------------

      Assignee: Les Hazlewood
    Resolution: Fixed

Fix committed to the 1.0.x branch and trunk.  Note that the new solution requires that you set the DelegatingFilterProxy filter's 'targetFilterLifecycle' init-param to 'true' in web.xml if using Shiro native sessions.  The wiki documentation has been updated to reflect this:

https://cwiki.apache.org/confluence/display/SHIRO/Spring

(it will update to the main incubator web site in an hour or two).

Setting 'targetFilterLifecycle' should no longer interfere with your configuration.

> getServletContext allways return null with conf via spring (native mode)
> ------------------------------------------------------------------------
>
>                 Key: SHIRO-167
>                 URL: https://issues.apache.org/jira/browse/SHIRO-167
>             Project: Shiro
>          Issue Type: Bug
>          Components: Integration: Spring
>    Affects Versions: 1.0.0
>         Environment: sun java, jetty 8.0.0, servelt 3.0 api, win 7
>            Reporter: Milos Kolencik
>            Assignee: Les Hazlewood
>             Fix For: 1.0.0
>
>
> Hi,
> i am using shiro rev. 945078, with configuration which uses native sessions
> filter is configured via springframework - DelegatingFilterProxy
> (here is the snippet from web.xml)
>  	<filter>
>  		<filter-name>shiroFilter</filter-name>
>  		<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
>  	</filter> 
> (and here from spring conf. xml)
> 	<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
> 	    <property name="securityManager" ref="securityManager"/>
> 	</bean>
> 	<bean id="securityManager" class="org.apache.shiro.web.DefaultWebSecurityManager">
> 		<property name="realm" ref="trustRealm" />
> 		<property name="subjectFactory" ref="trustSubjectFactory" />
> 		<property name="sessionMode" value="native" />
> 		<property name="sessionManager" ref="trustSessionManager" />
> 		<property name="cacheManager">
> 			<bean class="org.apache.shiro.cache.MemoryConstrainedCacheManager" />
> 		</property>
> 	</bean>
> the problem i have is that the method HttpServletRequest.getSession().getServletContext() always return null,
> (I was wondering why and i found that the ServletContext is set to AbstractFilter only in init(filterConfig) method.
> But this method is never called in configuration via spring-DelegatingFilterProxy. I know that specifying the "targetFilterLifecycle" filter init-param as "true" will enforce invocation of the Filter.init. But this way my definitions will be overrided.)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHIRO-167) getServletContext allways return null with conf via spring (native mode)

Posted by "Les Hazlewood (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHIRO-167?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12869695#action_12869695 ] 

Les Hazlewood commented on SHIRO-167:
-------------------------------------

Hi Milos,

When you say "But this way my definitions will be overridden" - what definitions are you talking about?  The Shiro beans created at startup?

> getServletContext allways return null with conf via spring (native mode)
> ------------------------------------------------------------------------
>
>                 Key: SHIRO-167
>                 URL: https://issues.apache.org/jira/browse/SHIRO-167
>             Project: Shiro
>          Issue Type: Bug
>          Components: Integration: Spring
>    Affects Versions: 1.0.0
>         Environment: sun java, jetty 8.0.0, servelt 3.0 api, win 7
>            Reporter: Milos Kolencik
>             Fix For: 1.0.0
>
>
> Hi,
> i am using shiro rev. 945078, with configuration which uses native sessions
> filter is configured via springframework - DelegatingFilterProxy
> (here is the snippet from web.xml)
>  	<filter>
>  		<filter-name>shiroFilter</filter-name>
>  		<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
>  	</filter> 
> (and here from spring conf. xml)
> 	<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
> 	    <property name="securityManager" ref="securityManager"/>
> 	</bean>
> 	<bean id="securityManager" class="org.apache.shiro.web.DefaultWebSecurityManager">
> 		<property name="realm" ref="trustRealm" />
> 		<property name="subjectFactory" ref="trustSubjectFactory" />
> 		<property name="sessionMode" value="native" />
> 		<property name="sessionManager" ref="trustSessionManager" />
> 		<property name="cacheManager">
> 			<bean class="org.apache.shiro.cache.MemoryConstrainedCacheManager" />
> 		</property>
> 	</bean>
> the problem i have is that the method HttpServletRequest.getSession().getServletContext() always return null,
> (I was wondering why and i found that the ServletContext is set to AbstractFilter only in init(filterConfig) method.
> But this method is never called in configuration via spring-DelegatingFilterProxy. I know that specifying the "targetFilterLifecycle" filter init-param as "true" will enforce invocation of the Filter.init. But this way my definitions will be overrided.)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.