aspose file tools*
The moose likes Spring and the fly likes Integrating Spring 2.5 and a legacy Servlet Application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Integrating Spring 2.5 and a legacy Servlet Application" Watch "Integrating Spring 2.5 and a legacy Servlet Application" New topic
Author

Integrating Spring 2.5 and a legacy Servlet Application

George Impagliazo
Ranch Hand

Joined: Sep 25, 2010
Posts: 41
I'm new to Spring.

I worked through the sections of this tutorial that cover web flow. My ultimate goal is to use Spring to implement new features in a legacy servlet webapp and then gradually replace the existing code making the servlet webapp into a Spring webabb.

So, to that end, I decided to go through the web flow part of the tutorial again, changing names to make my own first "hello world" screen with Spring within the development copy of the legacy servlet application.

My problem is that when I put the servlet mappings for Spring into my web.xml, I get 404s trying to get to my landing page.


  • [*]I'm using WebLogic 9.2
    [*]I converted the directory tree of my webapp to mimic the layout that Spring webapps use
    [*]I copied spring.jar and spring-mvc.jar into my WEB-INF/lib
    [*]My application is "abc", it is depllyed abc.war, weblogic.xml has this tag: <wls:context-root>nsd</wls:context-root>


  • I made a simplified version of my web.xml, with just one legacy servlet in it ( for the landing page ) and Spring. It works with the Spring stuff commented out, but not otherwise. Here it is, my WEB-INF/web.xml for the "abc" webapp




    This is my WEB-INF/abc-servlet.xml





    Here is the code for my elementary controller:




    Again, my problem isn't with the controller or the view (jsp)...yet. Right now, when I include the Spring servlet mappings in my web.xml, I can't get to my landing page, I get a 404. When I yank the Spring servlet mappings, that problem goes away.

    I'm a raw beginner with Spring, so I am not sure where to look.

    Thanks in advance for any clues

    Mark Spritzler
    ranger
    Sheriff

    Joined: Feb 05, 2001
    Posts: 17250
        
        6

    If you are learning Spring, it is best to use the latest version of Spring and latest approaches. By looking at your Controller you are using really old style of Spring MVC. I recommend looking at materials that are up to date, like the Spring documentation at www.springframework.org

    Good Luck

    Mark


    Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
    How to Ask Questions the Smart Way FAQ
    George Impagliazo
    Ranch Hand

    Joined: Sep 25, 2010
    Posts: 41
    Mark Spritzler wrote:If you are learning Spring, it is best to use the latest version of Spring and latest approaches. By looking at your Controller you are using really old style of Spring MVC. I recommend looking at materials that are up to date, like the Spring documentation at www.springframework.org

    Good Luck

    Mark


    I agree with you Mark. However, the most advanced tutorial I found is for 2.5. I even bought an otherwise excellent book ( from "* In Action" series yet ) that doesn't even have a complete working example. There are just too many new things going on for me to use docs with out a step by step tutorial.

    Let me know if you have any ideas what the issue is with my original post.......thanks.
    Mark Spritzler
    ranger
    Sheriff

    Joined: Feb 05, 2001
    Posts: 17250
        
        6

    I posted a couple of links to better tutorials in this thread

    http://www.coderanch.com/t/567496/Spring/HandleRequestInternal-not-called-spring

    Mark
    George Impagliazo
    Ranch Hand

    Joined: Sep 25, 2010
    Posts: 41
    Mark Spritzler wrote:I posted a couple of links to better tutorials in this thread

    http://www.coderanch.com/t/567496/Spring/HandleRequestInternal-not-called-spring

    Mark


    I'm reposting them here as I didn't find them searching:


    http://www.mkyong.com/spring3/spring-3-mvc-hello-world-example/

    http://www.giantflyingsaucer.com/blog/?p=2395

    Thanks much, I am going to try again tomorrow, following these tutorials.

    George Impagliazo
    Ranch Hand

    Joined: Sep 25, 2010
    Posts: 41
    In my legacy servlet application, the URLs the servlets are mapped to do not have file names.

    For example, there is a servlet, Address.java that would map to the URL:

    https://blah.blah.blah/abc/address/

    Is it possible that Spring, WebLogic, the web.xml are considering URLs like that to *.htm files and getting things confused, with Spring trying to map those URLs to itself while the web.xml is trying to map those URLs to another servlet?
    Mark Spritzler
    ranger
    Sheriff

    Joined: Feb 05, 2001
    Posts: 17250
        
        6

    George Impagliazo wrote:In my legacy servlet application, the URLs the servlets are mapped to do not have file names.

    For example, there is a servlet, Address.java that would map to the URL:

    https://blah.blah.blah/abc/address/

    Is it possible that Spring, WebLogic, the web.xml are considering URLs like that to *.htm files and getting things confused, with Spring trying to map those URLs to itself while the web.xml is trying to map those URLs to another servlet?


    It depends on your Servlet mapping in your web.xml. If you put in <servlet-mapping> tags that overlap each other, then yes you would have issues. But that is all based on what you put into the web.xml for all your servlet mapping, nothing that Spring is doing.

    Good Luck

    Mark
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Integrating Spring 2.5 and a legacy Servlet Application