Results 1 to 4 of 4

Thread: mvc:annotation-driven and Tuckey

  1. #1
    Join Date
    Jun 2009
    Posts
    106

    Exclamation mvc:annotation-driven and Tuckey

    hi All,

    I was using Tuckey url for url re-writing. This is how it looks:
    Code:
    <rule>
    	<from>/</from>
    	<to>/pf/welcome</to>
    </rule>
    and this is how I have my entitymanager set up in web.xml:
    Code:
    	<filter-mapping>
    	    <filter-name>OpenEntityManagerInViewFilter</filter-name>
    	     <!-- <url-pattern>/*</url-pattern>-->
    	    	    <url-pattern>/pf/*</url-pattern>
       		<dispatcher>FORWARD</dispatcher>
    	    
    	</filter-mapping>
    I would like to take advantage of Spring 3 validations.
    In my presentation-context file I added this:
    <mvc:annotation-driven />

    As soon as I do that I get 404 errors. The mapping is off.
    Code:
    12/Sep/10 21:57:46 DEBUG [http-8080-1] DEBUG (org.springframework.web.servlet.Di
    spatcherServlet.getLastModified(DispatcherServlet.java:842)) - DispatcherServlet
     with name 'dispatcher' determining Last-Modified value for [/PublicFountainWAR-
    0.0.1-SNAPSHOT/pf/welcome]
    12/Sep/10 21:57:46 DEBUG [http-8080-1] DEBUG (org.springframework.web.servlet.Di
    spatcherServlet.getLastModified(DispatcherServlet.java:850)) - No handler found
    in getLastModified
    12/Sep/10 21:57:46 DEBUG [http-8080-1] DEBUG (org.springframework.web.servlet.Di
    spatcherServlet.doService(DispatcherServlet.java:690)) - DispatcherServlet with
    name 'dispatcher' processing GET request for [/PublicFountainWAR-0.0.1-SNAPSHOT/
    pf/welcome]
    12/Sep/10 21:57:46 WARN  [http-8080-1] WARN (org.springframework.web.servlet.Dis
    patcherServlet.noHandlerFound(DispatcherServlet.java:962)) - No mapping found fo
    r HTTP request with URI [/PublicFountainWAR-0.0.1-SNAPSHOT/pf/welcome] in Dispat
    cherServlet with name 'dispatcher'
    12/Sep/10 21:57:46 DEBUG [http-8080-1] DEBUG (org.springframework.web.servlet.Fr
    ameworkServlet.processRequest(FrameworkServlet.java:677)) - Successfully complet
    ed request
    12/Sep/10 21:57:46 DEBUG [http-8080-1] DEBUG (org.springframework.orm.jpa.suppor
    t.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.j
    ava:120)) - Closing JPA EntityManager in OpenEntityManagerInViewFilter
    12/Sep/10 21:57:46 DEBUG [http-8080-1] DEBUG (org.springframework.orm.jpa.Entity
    ManagerFactoryUtils.closeEntityManager(EntityManagerFactoryUtils.java:328)) - Cl
    osing JPA EntityManager
    my controllers are mapped to key words without the "pf".
    e.g. /welcome NOT /pf/welcome

    the "pf" was just there to forward it to a sort of virtual path only known to the dispatchservlet for processing...the url's are all independant.

    IS there a way to use Tuckey and <mvc:annotation-driven />???

  2. #2
    Join Date
    Jun 2009
    Posts
    106

    Exclamation still stuck!!

    guys any clues would help...just wanna add
    <mvc:annotation-driven />

    to my pre-existing spring mvc 3.0 web app using Tuckey URL filter......


    any help would be greatly appreciated!

  3. #3
    Join Date
    Jun 2009
    Posts
    106

    Lightbulb Solved!! but need more input

    Hi ,

    first of all I'm kinda disapointed of the lack of support for this thread...I think since Spring MVC 3 has some new constructs, that its good to disucss this as much as possible seeing that the documentation isn't the best.

    Here is what I did to solve this problem.
    The conflict started with <mvc:annotation-driven />

    The point of this exercise was to use JSR 303 validation which is why I included <mvc:annotation-driven /> to begin with.
    I am not sure if this is the best approach or not...personally I would like to stick to conventions and would rather use <mvc:annotation-driven />.
    Here is what I did:
    1)I commented out <mvc:annotation-driven />
    2) I did the following:

    Code:
    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
        <property name="webBindingInitializer">
            <bean class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
                <property name="validator" ref="validator" />
            </bean>
        </property>
    <!--    <property name="messageConverters">-->
    <!--        <list>-->
    <!--           <bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter" />-->
    <!--           <bean class="org.springframework.http.converter.StringHttpMessageConverter" />-->
    <!--           <bean class="org.springframework.http.converter.FormHttpMessageConverter" />-->
    <!--           <bean class="org.springframework.http.converter.xml.SourceHttpMessageConverter" />-->
    <!--        </list>-->
    <!--    </property>-->
    <property name="order" value="1" />
     </bean>
     
    <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />
    In this way, I was still able to use Tuckey, along with AnnotationMethodHandlerAdapter which I marked as "order 1"...which means that it will run after Tuckey.

    The problem was this was defaulting to oder 0 which was over-riding tuckey so my request mappings were not being resolved..

    personally I do not understand what I did , I do not know what AnnotationMethodHandlerAdapter really does...I just pieced together different things online...

    All of this to use the @Validate method on my domain objects which I think is pretty cool as you get instant validations of the entity object.

    If any of you know how to make <mvc:annotation-driven /> work with Tuckey, please let me know...I suspect there is some switch you tell <mvc:annotation-driven /> to recognize some other mvc mechanism and to fire with a higher order....

  4. #4
    Join Date
    Jul 2010
    Location
    Venice, Italy
    Posts
    709

    Default

    Solution is...don't use Tuckey...Spring web mvc has its own methods to do url rewriting, read the documentation and experiment with the mvc namespace...

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •