Prettyfaces + Spring security only works on Tomcat 7 – not on Tomcat 6

Splash Forums Rewrite Users Prettyfaces + Spring security only works on Tomcat 7 – not on Tomcat 6

This topic contains 12 replies, has 3 voices, and was last updated by  Lincoln Baxter III 2 years, 8 months ago.

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #25054

    jdev81
    Participant

    Hello,

    I have a application that works fine on Tomcat 7, but I need to get it work on Tomcat 6 in order to deploy it to appfog (they don’t support Tomcat 7 yet). I suppose that pretty faces in combination with Spring security causes the problem. When I run the application it starts up and I can see the index page. Whenever I try an page that is mapped by pretty faces (Restful URL) I get a 404. There are no errors on startup in the log file. Here are some snippets from my configuration:

    pom.xml

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <version>3.1.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>3.1.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>3.1.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-crypto</artifactId>
            <version>3.1.4.RELEASE</version>
        </dependency>
    
        <dependency>
            <groupId>org.ocpsoft.rewrite</groupId>
            <artifactId>rewrite-servlet</artifactId>
            <version>2.0.7.Final</version>
        </dependency>
        <dependency>
            <groupId>org.ocpsoft.rewrite</groupId>
            <artifactId>rewrite-config-prettyfaces</artifactId>
            <version>2.0.7.Final</version>
        </dependency>
    

    web.xml:

    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>
    
    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>REQUEST</dispatcher>
    </filter-mapping>
    
    <filter>
        <filter-name>OCPsoft Rewrite Filter</filter-name>
        <filter-class>org.ocpsoft.rewrite.servlet.RewriteFilter</filter-class>
        <async-supported>true</async-supported>
    </filter>
    <filter-mapping>
        <filter-name>OCPsoft Rewrite Filter</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
        <dispatcher>ASYNC</dispatcher>
        <dispatcher>ERROR</dispatcher>
    </filter-mapping>
    

    I would appriate any help! Thank you in advance…

    • This topic was modified 2 years, 10 months ago by  jdev81.
    #25071

    Hi There,

    We’ve just released Rewrite 2.0.8.Final, which fixes several critical bugs released with the ConfigurationBuilder API in 2.0.7.

    Could you try upgrading and let me know if that resolves your problem? If not, could you please post your full Rewrite / PrettyFaces configurations (or a sample app that reproduces the issue)?

    Thanks,
    Lincoln

    #25079

    jdev81
    Participant

    Hi Lincoln,

    I upgraded to 2.0.8.Final and it still does only work on Tomcat 7. My pretty config only contains one line

    ...
    <rewrite match=".*/" trailingSlash="remove" />
    ...

    I only use annotations to define further URL mappings. If you need more information/snippets just let me know. If you don’t know a solution I will try to write a small app to reproduce the error.
    Thank you in advance!

    Regards,
    Murat

    • This reply was modified 2 years, 10 months ago by  jdev81.
    #25117

    I think a small app to reproduce this issue would be very helpful. There is nothing Tomcat6/7 specific in our code, so this just may be some kind of incompatibility or something like this.

    BTW: Which version of Tomcat 6 did you try?

    #25118

    jdev81
    Participant

    The tomcat versions I am using are 6.0.32 and 7.0.39. The zip attachment contains an example app that can reproduce the error
    (http://localhost:8080/prettyfaces/myurl works only on Tomcat 7)

    BTW: I noticed that the filter creation/execution/destroy order seems to be different when I added the debugging Servlet (OrderFilter) which is also included the zip (I added the order filter before spring, after spring and after pretty faces to see what happens)

    • This reply was modified 2 years, 10 months ago by  jdev81.
    • This reply was modified 2 years, 10 months ago by  jdev81.
    #25124

    Thanks for providing the sample app. I’ll try to find some time to have a look at it…

    What do you mean with different order? As you are in a Servlet 2.5 environment, all the filters have to be defined in your web.xml and they have to be executed in exactly this order.

    #25125

    jdev81
    Participant

    When I added the OrderFilter I provided in my example I could see that on Tomcat 7 the filter creation, execution, and destruction was always in the same order (servlet 1: creation, execution, destruction, servlet 2: creation,… and so on). When I executed the same configuration on Tomcat 6 I could see that there was some overlap in filter creation/destruction. This is probably just a a logging issue but nevertheless I wanted to mention it. I added the OrderFilter to see if my filters are executed in the defined order and to check if all filters were executed.

    #25394

    jdev81
    Participant

    I still could’t get it work. Is there a sample project that uses both spring security and prettyfaces and/or rewrite (and which works on Tomcat 6) that I could have a look at? Maybe someone on the forum has already got it to work?

    I would appreciate any hints and/or example projects. Thank you in advance!

    #25395

    Try adding all of this to your web.xml (including the listeners.) It just occurred to me that they might be required:

    
    
       <listener>
          <listener-class>org.ocpsoft.rewrite.servlet.impl.RewriteServletRequestListener</listener-class>
       </listener>
    
       <listener>
          <listener-class>org.ocpsoft.rewrite.servlet.impl.RewriteServletContextListener</listener-class>
       </listener>
    
       <filter>
          <filter-name>OCPsoft Rewrite Filter</filter-name>
          <filter-class>org.ocpsoft.rewrite.servlet.RewriteFilter</filter-class>
          <async-supported>true</async-supported>
       </filter>
       <filter-mapping>
          <filter-name>OCPsoft Rewrite Filter</filter-name>
          <url-pattern>/*</url-pattern>
          <dispatcher>FORWARD</dispatcher>
          <dispatcher>REQUEST</dispatcher>
          <dispatcher>INCLUDE</dispatcher>
          <dispatcher>ASYNC</dispatcher>
          <dispatcher>ERROR</dispatcher>
       </filter-mapping>
    #25463

    jdev81
    Participant

    Thank you for your response. It improved the situation and the URL mappings work now. Though, it seems that I have a new problem now. EL expressions like #{userController.createUser(userBean)} don’t work anymore after the changes in the web.xml. My EL-resolver is defined in may faces-config.xml as follows:

    <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>

    Is there anything I am missing or do I have to change something else in my configuration? Thank you very much in advance…

    #25464

    I don’t think that this is caused by PrettyFaces. PrettyFaces and Rewrite don’t do anything with the ELResolver, beside using it of cause. 🙂

    Could you double check that this problem disappears if you remove the RewriteFilter?

    #25483

    jdev81
    Participant

    You just made my day. Of course you are right! After including the listeners that Lincoln wrote about just another underlying problem appeared and it had nothing to do with Prettyfaces/Rewrite 😉 I just had to replace the EL implementation (I use jboss-el now and it works fine on Tomcat 6). Thank you guys again for your help!

    #25508

    Welcome! I’m glad you got it working 🙂

Viewing 13 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.

Comments are closed.