Announcement Announcement Module
Collapse
No announcement yet.
viewResolver prefix being prepended twice Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • viewResolver prefix being prepended twice

    Dear All

    I am new to Spring and JSF and trying to integrate Spring 3.0.5.RELEASE, Spring security and JSF 2.0.6 (implementation Primefaces 3.0.M4-SNAPSHOT). Got guideline from a friend but facing a strange issue Below is my configuration:

    web.xml
    Code:
             <servlet>
            <servlet-name>springMVCServlet</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
            <init-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>springMVCServlet</servlet-name>
            <url-pattern>/app/*</url-pattern>
        </servlet-mapping>
    servlet-context.xml view resolver part
    Code:
        <bean id="myViewController" class="org.springframework.web.servlet.mvc.UrlFilenameViewController" />
         <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="mappings">
                <props>
                    <prop key="*">myViewController</prop>
                </props>
            </property>
         </bean>
        
         <!-- Resolves views selected for rendering by @Controllers to .xhtml resources in the /WEB-INF/views directory -->
        <bean class="org.springframework.web.servlet.view.UrlBasedViewResolver">
            <property name="viewClass" value="org.springframework.faces.mvc.JsfView" />
            <property name="prefix" value="/WEB-INF/views/" />
            <property name="suffix" value=".xhtml" />
        </bean>
    applicationContext-security-http.xml
    Code:
    <http auto-config="true" use-expressions="true">
            <form-login login-page="/app/login" login-processing-url="/app/logincheck" default-target-url="/app/home" authentication-failure-url="/app/login?login_error=1" />
            <logout logout-url="/app/logout" logout-success-url="/app/home" />
    
            <intercept-url pattern="/app/resource/*" filters="none" />
            <intercept-url pattern="/app/javax.*/**" filters="none" />
            <intercept-url pattern="/app/logout*" access="isAuthenticated()" />
    
            <intercept-url pattern="/app/login" access="permitAll()" />
            <intercept-url pattern="/app/home" access="permitAll()" />
            <intercept-url pattern="/app/error" access="permitAll()" />
            <intercept-url pattern="/app/accessdenied" access="permitAll()" />
    
            <intercept-url access="hasRole('ROLE_ADMIN')" pattern="/app/*" />
    
            <access-denied-handler error-page="/app/accessdenied" />
        </http>
    I can successfully login to application and get navigated to home page where I have a link to another page. That page is accessible too but when I click button on that page which calls a controller method, an exception raises. PS: As per replies on some forums, fellas have suggested to remove * from url-pattern in web.xml but in that case link from home page results in 404 error.

    Below is my log


    web.filter.GzipFilter - http://localhost:8080/mmc/app/WEB-IN...ogSelect.xhtml. Writing with gzip compression
    security.web.FilterChainProxy - - Converted URL to lowercase, from: '/app/web-inf/views/messagelogselect.xhtml'; to: '/app/web-inf/views/messagelogselect.xhtml'
    web.FilterChainProxy - - Candidate is: '/app/web-inf/views/messagelogselect.xhtml'; pattern is /app/resource/*; matched=false
    web.FilterChainProxy - - Converted URL to lowercase, from: '/app/web-inf/views/messagelogselect.xhtml'; to: '/app/web-inf/views/messagelogselect.xhtml'
    web.FilterChainProxy - - Candidate is: '/app/web-inf/views/messagelogselect.xhtml'; pattern is /app/javax.*/**; matched=false
    web.FilterChainProxy - - Converted URL to lowercase, from: '/app/web-inf/views/messagelogselect.xhtml'; to: '/app/web-inf/views/messagelogselect.xhtml'
    web.FilterChainProxy - - Candidate is: '/app/web-inf/views/messagelogselect.xhtml'; pattern is /**; matched=true
    web.FilterChainProxy$VirtualFilterChain - - /app/WEB-INF/views/messageLogSelect.xhtml at position 1 of 10 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
    web.context.HttpSessionSecurityContextRepository - 2011-10-13 13:07:37,734 - - Obtained a valid SecurityContext from SPRING_SECURITY_CONTEXT: 'org.springframework.security.core.context.Securit yContextImpl@fb413416: Authentication: org.springframework.security.authentication.Userna mePasswordAuthenticationToken@fb413416: Principal: org.springframework.security.core.userdetails.User @586034f: Username: admin; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_ADMIN,ROLE_USER; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.We bAuthenticationDetails@0: RemoteIpAddress: 127.0.0.1; SessionId: 02CA1060B2B82534430D44FC79B7FA97; Granted Authorities: ROLE_ADMIN, ROLE_USER'
    web.FilterChainProxy$VirtualFilterChain - /app/WEB-INF/views/messageLogSelect.xhtml at position 2 of 10 in additional filter chain; firing Filter: 'LogoutFilter'
    web.FilterChainProxy$VirtualFilterChain - /app/WEB-INF/views/messageLogSelect.xhtml at position 3 of 10 in additional filter chain; firing Filter: 'UsernamePasswordAuthenticationFilter'
    web.FilterChainProxy$VirtualFilterChain - /app/WEB-INF/views/messageLogSelect.xhtml at position 4 of 10 in additional filter chain; firing Filter: 'BasicAuthenticationFilter'
    web.FilterChainProxy$VirtualFilterChain - /app/WEB-INF/views/messageLogSelect.xhtml at position 5 of 10 in additional filter chain; firing Filter: 'RequestCacheAwareFilter'
    web.FilterChainProxy$VirtualFilterChain - /app/WEB-INF/views/messageLogSelect.xhtml at position 6 of 10 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter'
    web.FilterChainProxy$VirtualFilterChain - /app/WEB-INF/views/messageLogSelect.xhtml at position 7 of 10 in additional filter chain; firing Filter: 'AnonymousAuthenticationFilter'
    web.authentication.AnonymousAuthenticationFilter - - SecurityContextHolder not populated with anonymous token, as it already contained: 'org.springframework.security.authentication.Usern amePasswordAuthenticationToken@fb413416: Principal: org.springframework.security.core.userdetails.User @586034f: Username: admin; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_ADMIN,ROLE_USER; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.We bAuthenticationDetails@0: RemoteIpAddress: 127.0.0.1; SessionId: 02CA1060B2B82534430D44FC79B7FA97; Granted Authorities: ROLE_ADMIN, ROLE_USER'
    web.FilterChainProxy$VirtualFilterChain - /app/WEB-INF/views/messageLogSelect.xhtml at position 8 of 10 in additional filter chain; firing Filter: 'SessionManagementFilter'
    web.FilterChainProxy$VirtualFilterChain - /app/WEB-INF/views/messageLogSelect.xhtml at position 9 of 10 in additional filter chain; firing Filter: 'ExceptionTranslationFilter'
    web.FilterChainProxy$VirtualFilterChain - /app/WEB-INF/views/messageLogSelect.xhtml at position 10 of 10 in additional filter chain; firing Filter: 'FilterSecurityInterceptor'
    web.access.intercept.DefaultFilterInvocationSecuri tyMetadataSource - Converted URL to lowercase, from: '/app/web-inf/views/messagelogselect.xhtml'; to: '/app/web-inf/views/messagelogselect.xhtml'
    web.access.intercept.DefaultFilterInvocationSecuri tyMetadataSource - Candidate is: '/app/web-inf/views/messagelogselect.xhtml'; pattern is /app/logout*; matched=false
    web.access.intercept.DefaultFilterInvocationSecuri tyMetadataSource - Candidate is: '/app/web-inf/views/messagelogselect.xhtml'; pattern is /app/login; matched=false
    web.access.intercept.DefaultFilterInvocationSecuri tyMetadataSource - Candidate is: '/app/web-inf/views/messagelogselect.xhtml'; pattern is /app/home; matched=false
    web.access.intercept.DefaultFilterInvocationSecuri tyMetadataSource - Candidate is: '/app/web-inf/views/messagelogselect.xhtml'; pattern is /app/error; matched=false
    web.access.intercept.DefaultFilterInvocationSecuri tyMetadataSource - Candidate is: '/app/web-inf/views/messagelogselect.xhtml'; pattern is /app/accessdenied; matched=false
    web.access.intercept.DefaultFilterInvocationSecuri tyMetadataSource - Candidate is: '/app/web-inf/views/messagelogselect.xhtml'; pattern is /app/*; matched=false
    intercept.AbstractSecurityInterceptor - Public object - authentication not attempted
    web.FilterChainProxy$VirtualFilterChain - /app/WEB-INF/views/messageLogSelect.xhtml reached end of additional filter chain; proceeding with original chain
    javax.faces.FacesException: /WEB-INF/views/WEB-INF/views/messageLogSelect.xhtml Not Found in ExternalContext as a Resource
    at com.sun.faces.lifecycle.RenderResponsePhase.execut e(RenderResponsePhase.java:124)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:1 01)
    at com.sun.faces.lifecycle.LifecycleImpl.render(Lifec ycleImpl.java:139)
    ........
    Caused by: java.io.FileNotFoundException: /WEB-INF/views/WEB-INF/views/messageLogSelect.xhtml Not Found in ExternalContext as a Resource
    at com.sun.faces.facelets.impl.DefaultFaceletFactory. resolveURL(DefaultFaceletFactory.java:224)
    at com.sun.faces.facelets.impl.DefaultFaceletFactory. resolveURL(DefaultFaceletFactory.java:265)
    web.access.ExceptionTranslationFilter - Chain processed normally
    web.context.SecurityContextPersistenceFilter - SecurityContextHolder now cleared, as request processing completed



    Kindly help out, I am short of time
    Last edited by shahzadmunir; Oct 13th, 2011, 05:40 AM.
Working...
X