Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

Struts+Acegi not working

Gerardo Corro

2007-07-31

Replies:


Hi,

I'm building a web application build with Struts+Spring+Acegi, I'm building the login page but I'm getting the next error:



javax.servlet.ServletException: Cannot retrieve mapping for action /j_acegi_security_check
 org.apache.jasper.runtime.PageContextImpl.doHandle PageException(PageContextImpl.java:825)
 org.apache.jasper.runtime.PageContextImpl.handlePa geException(PageContextImpl.java:758)
 org.apache.jsp.userLogin_jsp._jspService(userLogin _jsp.java:148)
 org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:94)
 javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
 org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:324)
 org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:292)
 org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:236)
 javax.servlet.http.HttpServlet.service(HttpServlet .java:802)



javax.servlet.jsp.JspException: Cannot retrieve mapping for action /j_acegi_security_check
 org.apache.struts.taglib.html.FormTag.lookup(FormT ag.java:810)
 org.apache.struts.taglib.html.FormTag.doStartTag(F ormTag.java:506)
 org.apache.jsp.userLogin_jsp._jspx_meth_html_form_ 0(userLogin_jsp.java:213)
 org.apache.jsp.userLogin_jsp._jspService(userLogin _jsp.java:136)
 org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:94)
 javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
 org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:324)
 org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:292)
 org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:236)
 javax.servlet.http.HttpServlet.service(HttpServlet .java:802)


My Acegi context file looks like:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
 <bean id="filterChainProxy" class="org.acegisecurity.util.FilterChainProxy">
   <property name="filterInvocationDefinitionSource">
     <value>
       CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
       PATTERN_TYPE_APACHE_ANT
/*.do*=httpSessionContextIntegrationFilter,authenti
cationProcessingFilter,exceptionTranslationFilter,
filterInvocationInterceptor</value>
   </property>
 </bean>
 
 <bean id="passwordEncoder" class="org.acegisecurity.providers.encoding.Md5Pas swordEncoder"/>  

 <bean id="httpSessionContextIntegrationFilter" class="org.acegisecurity.context.HttpSessionContex tIntegrationFilter" />

  <bean id="authenticationProcessingFilter" class="org.acegisecurity.ui.webapp.AuthenticationP rocessingFilter">
   <property name="authenticationManager">
     <ref local="authenticationManager" />
   </property>
   <property name="authenticationFailureUrl">
     <value>/userLogin.jsp?login_error=errors.credenciales.nova lidos</value>
   </property>
   <property name="defaultTargetUrl">
     <value>/</value>
   </property>
   <property name="filterProcessesUrl">
     <value>/j_acegi_security_check.do</value>
   </property>
 </bean>

 <bean id="authenticationManager" class="org.acegisecurity.providers.ProviderManager ">
   <property name="providers">
     <list>
       <ref local="daoAuthenticationProvider" />
     </list>
   </property>
 </bean>

 <bean id="filterInvocationInterceptor" class="org.acegisecurity.intercept.web.FilterSecur ityInterceptor">
   <property name="authenticationManager">
     <ref local="authenticationManager" />
   </property>
   <property name="accessDecisionManager">
     <ref local="accessDecisionManager" />
   </property>
   <property name="objectDefinitionSource">
     <value>
       CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
       PATTERN_TYPE_APACHE_ANT
       /buscadorperfiles.do*=ROLE_ADMIN,ROLE_TODO
       /*.do*=ROLE_ADMIN,ROLE_TODO
      </value>
   </property>
 </bean>
 <bean id="authenticationEntryPoint" class="org.acegisecurity.ui.webapp.AuthenticationP rocessingFilterEntryPoint">
   <property name="loginFormUrl">
     <value>/userLogin.jsp?login_error=errors.credenciales.nova lidos</value>
   </property>
   <property name="forceHttps">
     <value>false</value>
   </property>
 </bean>
  <bean id="daoAuthenticationProvider" class="org.acegisecurity.providers.dao.DaoAuthenti cationProvider">
   <!-- En memoria
     <property name="authenticationDao"><ref bean="administradoresDAO"/></property> -->
   <!-- En bbdd -->
   <property name="userDetailsService">
     <ref bean="administradoresJDBCDAO" />
   </property>
   <!-- Cache -->
   <property name="userCache">
     <ref bean="userCache" />
   </property>
    <property name="passwordEncoder"><ref local="passwordEncoder"/></property>    
 </bean>
 <bean id="administradoresJDBCDAO" class="org.acegisecurity.userdetails.jdbc.JdbcDaoI mpl">
   <property name="dataSource">
     <ref bean="basicDataSource" />
   </property>
   <property name="usersByUsernameQuery">
     <value>select idusuario as username, password as password,'1' as enabled FROM usuarios WHERE idusuario=?</value>
   </property>
   <property name="authoritiesByUsernameQuery">
     <value>select idusuario as username, CONCAT('ROLE_',idperfil) from usuarios where idusuario=?</value>
   </property>
 </bean>
 
 <bean id="userCache" class="org.acegisecurity.providers.dao.cache.EhCac heBasedUserCache">
   <property name="cache">
     <ref local="userCacheBackend" />
   </property>
 </bean>

 <bean id="userCacheBackend" class="org.springframework.cache.ehcache.EhCacheFa ctoryBean">
   <property name="cacheManager">
     <ref local="cacheManager" />
   </property>
   <property name="cacheName">
     <value>userCache</value>
   </property>
 </bean>

 <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheMa nagerFactoryBean">
   <property name="configLocation">
     <value>classpath:/ehcache-failsafe.xml</value>
   </property>
 </bean>
 
<bean id="authenticationProcessingFilterEntryPoint"
class="org.acegisecurity.ui.webapp.AuthenticationP
rocessingFilterEntryPoint">
   <property name="loginFormUrl">
     <value>/userLogin.jsp</value>
   </property>
   <property name="forceHttps">
     <value>false</value>
   </property>
 </bean>
 
 <bean id="exceptionTranslationFilter" class="org.acegisecurity.ui.ExceptionTranslationFi lter">
   <property name="authenticationEntryPoint">
     <ref bean="authenticationProcessingFilterEntryPoint" />
   </property>
   <property name="accessDeniedHandler">
     <bean class="org.acegisecurity.ui.AccessDeniedHandlerImp l">
       <property name="errorPage" value="/login.jsp" />
     </bean>
   </property>
 </bean>

 <bean id="roleVoter" class="org.acegisecurity.vote.RoleVoter" />

 <bean id="accessDecisionManager" class="org.acegisecurity.vote.AffirmativeBased">
   <property name="allowIfAllAbstainDecisions">
     <value>false</value>
   </property>
   <property name="decisionVoters">
     <list>
       <ref local="roleVoter" />
     </list>
   </property>
 </bean>    

</beans>


The input login form like this:



   <html:form action="j_acegi_security_check.do" name="userLoginForm">
     username : <html:text property="j_username" />
     <html:errors property="j_username" />
     <br />    
     password : <html:password property="j_password" />
     <html:errors property="j_password" />
     <br />
     <html:submit />
   </html:form>



The struts config file is this one:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD
Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

<struts-config>
<data-sources />
<form-beans >
  <form-bean name="userLoginForm" type="com.xxx.yyy.struts.form.UserLoginForm" />
</form-beans>

 
<action-mappings >
  <action
   attribute="userLoginForm"
   input="/userLogin.jsp"
   name="userLoginForm"
   path="/userLogin"
   scope="request"
   type="com.xxx.yyy.struts.action.UserLoginAction">
   <forward name="success" path="/WEB-INF/page/userLoginSuccess.jsp" />
   <forward name="failure" path="/userLogin.jsp" />
  </action>

</action-mappings>

<message-resources parameter="com.xxx.yyy.struts.ApplicationResources " />
</struts-config>


And my web.xml file is:



 <filter>
    <filter-name>FiltroFilterChainProxy</filter-name>
    <filter-class>org.acegisecurity.util.FilterToBeanProxy</filter-class>
    <init-param>
       <param-name>targetClass</param-name>
       <param-value>org.acegisecurity.util.FilterChainProxy</param-value>
    </init-param>
  </filter>

 <filter-mapping>
   <filter-name>FiltroFilterChainProxy</filter-name>
   <url-pattern>*.do</url-pattern>
 </filter-mapping>



Please assist, thank you!
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
©2008 junlu.com - Jax Systems, LLC, U.S.A.