You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Peter Cheung <ps...@gmail.com> on 2005/10/07 20:16:54 UTC

myfaces + Spring + Acegi Problem

I was having problem to get Acegi 0.8.3 to work with myfaces 1.1 and Spring
1.2.5 in Tomcat 5.5.9 running 1.5.0_2. I modified myfaces_tiles_examples
from myfaces 1.0.9, so that I created a new directory called mine, and
inside there was a jsp called my_page.jsp. In the Spring configuration file,
I specified anyone who accesses page with "my_*" have to be prompted for
userid/password, see below:

<bean id="filterInvocationInterceptor" class="
net.sf.acegisecurity.intercept.web.FilterSecurityInterceptor">
<property name="authenticationManager">
<ref local="authenticationManager"/>
</property>
<property name="accessDecisionManager">
<ref local="accessDecisionManager"/>
</property>
<property name="runAsManager">
<ref bean="runAsManager"/>
</property>
<property name="objectDefinitionSource">
<value>
CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
PATTERN_TYPE_APACHE_ANT
/**/my_*=ROLE_ADMIN
</value>
</property>
</bean>

When I clicked the "My Page" link on the following navigation jsp, the
my_page.jsp was displayed without prompting for the userid/password, but the
second time, the login page was displayed. I think it had to do with
"tiles", because I tried a "non-tiles" example, and the result was the same.
It might be due to the fact that the URL was on the browser was still
showing the URL of the navigation jsp after the first click.

<%@ taglib uri="http://myfaces.apache.org/extensions" prefix="x"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>

<h:panelGrid columns="1" >
<h:commandLink action="nav_page1">
<h:outputText value="Page1" />
</h:commandLink>
<h:commandLink action="nav_page2">
<h:outputText value="Page2" />
</h:commandLink>
<h:commandLink action="my_page">
<h:outputText value="My Page" />
</h:commandLink>
<h:commandLink action="nav_page3">
<h:outputText value="non-tiles page" />
</h:commandLink>
<f:verbatim>
<a href="mine/my_page.jsp">My non-tiles page</a>
</f:verbatim>
</h:panelGrid>

I have the following 2 questions:
1. Is there any way to get the login page to display the first time when "My
Page" link is clicked, not the second time?
2. I tried to use "My non-tiles page" HTML link to access the my_page.jsp,
this way, the login page was displayed after the first click, but after I
logged in, I got the following exception:

java.lang.NullPointerException
javax.faces.webapp.UIComponentTag.setupResponseWriter(UIComponentTag.java
:615)
javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:217)
org.apache.jsp.mine.my_005fpage_jsp._jspx_meth_h_outputText_0(
org.apache.jsp.mine.my_005fpage_jsp:77)
org.apache.jsp.mine.my_005fpage_jsp._jspService(
org.apache.jsp.mine.my_005fpage_jsp:54)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java
:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
FilterChainProxy.java:292)
net.sf.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(
FilterSecurityInterceptor.java:74)
net.sf.acegisecurity.intercept.web.SecurityEnforcementFilter.doFilter(
SecurityEnforcementFilter.java:182)
net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
FilterChainProxy.java:303)
net.sf.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(
BasicProcessingFilter.java:206)
net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
FilterChainProxy.java:303)
net.sf.acegisecurity.ui.AbstractProcessingFilter.doFilter(
AbstractProcessingFilter.java:305)
net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
FilterChainProxy.java:303)
net.sf.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(
HttpSessionContextIntegrationFilter.java:152)
net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
FilterChainProxy.java:303)
net.sf.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java
:173)
net.sf.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java
:125)
net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
FilterChainProxy.java:292)
net.sf.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(
FilterSecurityInterceptor.java:84)
net.sf.acegisecurity.intercept.web.SecurityEnforcementFilter.doFilter(
SecurityEnforcementFilter.java:182)
net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
FilterChainProxy.java:303)
net.sf.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(
BasicProcessingFilter.java:206)
net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
FilterChainProxy.java:303)
net.sf.acegisecurity.ui.AbstractProcessingFilter.doFilter(
AbstractProcessingFilter.java:305)
net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
FilterChainProxy.java:303)
net.sf.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(
HttpSessionContextIntegrationFilter.java:226)
net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
FilterChainProxy.java:303)
net.sf.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java
:173)
net.sf.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java
:125)


The following is the configuration for the FacesServlet:
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<!-- Faces Servlet Mapping -->

<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>

Thanks in advance.

Re: myfaces + Spring + Acegi Problem

Posted by Julián García <jg...@unionsoluciones.com.co>.
I have used myfaces and acegi with no problems so far. However, I try 
not to use a JSF page as my login page, I use a plain jsp.  If using a 
jsf page is a requirement, check this blog entry: 
http://www.jroller.com/page/vtatai/20050505

In regard to the code below: what for do you use runAsManager? I'd 
suggest to start the project with plain jsp pages, then introduce 
myfaces when it works. I have found somehow difficult to make acegi work 
from scratch.

Julian

Peter Cheung wrote:

>I was having problem to get Acegi 0.8.3 to work with myfaces 1.1 and Spring
>1.2.5 in Tomcat 5.5.9 running 1.5.0_2. I modified myfaces_tiles_examples
>from myfaces 1.0.9, so that I created a new directory called mine, and
>inside there was a jsp called my_page.jsp. In the Spring configuration file,
>I specified anyone who accesses page with "my_*" have to be prompted for
>userid/password, see below:
>
><bean id="filterInvocationInterceptor" class="
>net.sf.acegisecurity.intercept.web.FilterSecurityInterceptor">
><property name="authenticationManager">
><ref local="authenticationManager"/>
></property>
><property name="accessDecisionManager">
><ref local="accessDecisionManager"/>
></property>
><property name="runAsManager">
><ref bean="runAsManager"/>
></property>
><property name="objectDefinitionSource">
><value>
>CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
>PATTERN_TYPE_APACHE_ANT
>/**/my_*=ROLE_ADMIN
></value>
></property>
></bean>
>
>When I clicked the "My Page" link on the following navigation jsp, the
>my_page.jsp was displayed without prompting for the userid/password, but the
>second time, the login page was displayed. I think it had to do with
>"tiles", because I tried a "non-tiles" example, and the result was the same.
>It might be due to the fact that the URL was on the browser was still
>showing the URL of the navigation jsp after the first click.
>
><%@ taglib uri="http://myfaces.apache.org/extensions" prefix="x"%>
><%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
><%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
>
><h:panelGrid columns="1" >
><h:commandLink action="nav_page1">
><h:outputText value="Page1" />
></h:commandLink>
><h:commandLink action="nav_page2">
><h:outputText value="Page2" />
></h:commandLink>
><h:commandLink action="my_page">
><h:outputText value="My Page" />
></h:commandLink>
><h:commandLink action="nav_page3">
><h:outputText value="non-tiles page" />
></h:commandLink>
><f:verbatim>
><a href="mine/my_page.jsp">My non-tiles page</a>
></f:verbatim>
></h:panelGrid>
>
>I have the following 2 questions:
>1. Is there any way to get the login page to display the first time when "My
>Page" link is clicked, not the second time?
>2. I tried to use "My non-tiles page" HTML link to access the my_page.jsp,
>this way, the login page was displayed after the first click, but after I
>logged in, I got the following exception:
>
>java.lang.NullPointerException
>javax.faces.webapp.UIComponentTag.setupResponseWriter(UIComponentTag.java
>:615)
>javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:217)
>org.apache.jsp.mine.my_005fpage_jsp._jspx_meth_h_outputText_0(
>org.apache.jsp.mine.my_005fpage_jsp:77)
>org.apache.jsp.mine.my_005fpage_jsp._jspService(
>org.apache.jsp.mine.my_005fpage_jsp:54)
>org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
>javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java
>:322)
>org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
>org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
>javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
>FilterChainProxy.java:292)
>net.sf.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(
>FilterSecurityInterceptor.java:74)
>net.sf.acegisecurity.intercept.web.SecurityEnforcementFilter.doFilter(
>SecurityEnforcementFilter.java:182)
>net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
>FilterChainProxy.java:303)
>net.sf.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(
>BasicProcessingFilter.java:206)
>net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
>FilterChainProxy.java:303)
>net.sf.acegisecurity.ui.AbstractProcessingFilter.doFilter(
>AbstractProcessingFilter.java:305)
>net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
>FilterChainProxy.java:303)
>net.sf.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(
>HttpSessionContextIntegrationFilter.java:152)
>net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
>FilterChainProxy.java:303)
>net.sf.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java
>:173)
>net.sf.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java
>:125)
>net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
>FilterChainProxy.java:292)
>net.sf.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(
>FilterSecurityInterceptor.java:84)
>net.sf.acegisecurity.intercept.web.SecurityEnforcementFilter.doFilter(
>SecurityEnforcementFilter.java:182)
>net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
>FilterChainProxy.java:303)
>net.sf.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(
>BasicProcessingFilter.java:206)
>net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
>FilterChainProxy.java:303)
>net.sf.acegisecurity.ui.AbstractProcessingFilter.doFilter(
>AbstractProcessingFilter.java:305)
>net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
>FilterChainProxy.java:303)
>net.sf.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(
>HttpSessionContextIntegrationFilter.java:226)
>net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
>FilterChainProxy.java:303)
>net.sf.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java
>:173)
>net.sf.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java
>:125)
>
>
>The following is the configuration for the FacesServlet:
><servlet>
><servlet-name>Faces Servlet</servlet-name>
><servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
><load-on-startup>1</load-on-startup>
></servlet>
>
><!-- Faces Servlet Mapping -->
>
><servlet-mapping>
><servlet-name>Faces Servlet</servlet-name>
><url-pattern>*.jsf</url-pattern>
></servlet-mapping>
>
>Thanks in advance.
>
>  
>