Announcement Announcement Module
Collapse
No announcement yet.
Strange STS behavior in the creation of Spring MVC project using STS template help :( Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Strange STS behavior in the creation of Spring MVC project using STS template help :(

    I am quite new in the Spring MVC world and I have a doubt about the corretct creation of a Spring MVC project.

    When I run an imported project (for example the Spring MVC Showcase example downlodable form the STS dashboard), inside the browser URL bar this project have an URL like: http://localhost:8080/project-name/

    For example the Web MVC Showcase example have project name: "spring-mvc-showcase" and have the following URL: for example the Web MVC Showcase example have project name: "spring-mvc-showcase" and have the following URL: http://localhost:8080/spring-mvc-showcase/

    Now, my doubt is related to the creation of a new Spring MVC project using Spring Template in STS\Eclipse.

    I do the following operation inside STS:

    File --> New --> Project and appears to me a wizard where I can chose the type of project.

    So I chose Spring Template Project, now appears to me ano other wizard windows where I can chose the specific typology of Spring Project and I chose "Spring MVC Project"

    Ok, now appears to me an other wizard windows in which I have to set up:
    Project name and I insert: my-spring-project
    Top level package and I have insert: org.mycompany.foo

    Ok, now I run my project on server, this don't run and inside the URL bar of the browser I have not http://localhost:8080/my-spring-project/ (as I would expect) but I have: http://localhost:8080/foo/

    In the stacktrace I have the following error message:

    Code:
    WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/foo/] in DispatcherServlet with name 'appServlet'
    Then if I do a project clean of my project, STS rebuild the project and if I try to run it again the project run well and the URL address still remain: http://localhost:8080/foo/

    I think that this is a strange behavior and I have not ideas what is the reason about it...

    So:

    1) Why the URL is not http://localhost:8080/my-spring-project/ but is http://localhost:8080/foo/ ?

    2) Why I have to clean and rebuild my project to run it?

    3) I am doing some error in the creation of a standard Spring MVC project?

    I am going crazy...

    Thank you very much

    Andrea

  • #2
    Hey Andrea!

    Regarding the clean build of the template project:
    sometimes the automatic build right after the wizard project creation doesn't do the full job because some libs are being added lazily. We will try to figure out how to fix this, but a clean build of the project helps as well.

    Regarding the URL of the different projects:
    This is something you can configure your each project (Properties -> Web Project Settings). This configuration is used when deploying the application to tc Server. Then, you can customize that using the tc Server editor, if you want to.

    The Spring MVC template project is configured out-of-the-box to use the third level of your package structure as the URL extension for your application. The MVC showcase app works differently and is imported as a standard Maven project. Therefore, I guess, it takes default values for the URL.

    Hope this helps!
    -Martin

    Comment


    • #3
      Originally posted by Martin Lippert View Post
      Hey Andrea!

      Regarding the clean build of the template project:
      sometimes the automatic build right after the wizard project creation doesn't do the full job because some libs are being added lazily. We will try to figure out how to fix this, but a clean build of the project helps as well.

      Regarding the URL of the different projects:
      This is something you can configure your each project (Properties -> Web Project Settings). This configuration is used when deploying the application to tc Server. Then, you can customize that using the tc Server editor, if you want to.

      The Spring MVC template project is configured out-of-the-box to use the third level of your package structure as the URL extension for your application. The MVC showcase app works differently and is imported as a standard Maven project. Therefore, I guess, it takes default values for the URL.

      Hope this helps!
      -Martin
      Ok,
      thank you very much for your complete answer.

      Let's see if I understand correctly (I still have some question for you)

      1) Then having to do a clean of the project may depend by the way in which Maven added dependencies? (who will try to figure out how to fix this "problem"?)

      2) Ok, I have understand how to change the context root of my project inside the Web Project Settings. The thing that I have not understand is if this thing is needed only in vFabric or also in TomCat Server.

      3) Exactly what do you mean when you say: "Then, you can customize that using the tc Server editor". What is the tc Server editor?
      Looking in STS I think that you mean: right click on my server (inside the server view), click on Open ---> Modules tab and here I can change the path of a deployed project as I can change it in my package explorer changing the context root...

      But I don't know if you mean this thing or something else...

      4) Ok, I have understand what do you mean about the two types of project configuration:

      So I think that if I would use the third level of package configuration I can give to this level the name of application, so in the URL I have a name that makes sense. The MVC Showcase Showcase instead have the context root set on the external project folder...ok

      Forgive the silly question, but in your opinion, which of the two configurations is the "best"? The third package level or the one that uses the standard Maven project (as the Spring MVC Showcase)?

      (In your book these topics are covered?)

      thank you very much
      Andrea

      Comment


      • #4
        Hey Andrea!

        Originally posted by AndreaNobili View Post
        1) Then having to do a clean of the project may depend by the way in which Maven added dependencies? (who will try to figure out how to fix this "problem"?)
        I think we have to fix this within the IDE tooling, but we haven't found a way to reliably reproduce this behavior. Still struggling a bit with this, but we will try to cover this for the next version.

        Originally posted by AndreaNobili View Post
        2) Ok, I have understand how to change the context root of my project inside the Web Project Settings. The thing that I have not understand is if this thing is needed only in vFabric or also in TomCat Server.
        I think this is also needed for Tomcat, not only for tc Server.

        Originally posted by AndreaNobili View Post
        3) Exactly what do you mean when you say: "Then, you can customize that using the tc Server editor". What is the tc Server editor?
        Looking in STS I think that you mean: right click on my server (inside the server view), click on Open ---> Modules tab and here I can change the path of a deployed project as I can change it in my package explorer changing the context root...

        But I don't know if you mean this thing or something else...
        Yes, that is what I meant. When you double click on the server in the servers view, there is an editor being opened up for you (not a textual editor, but this graphical UI that you can use to customize the tc Server settings). But that is called an "editor" in Eclipse as well... ;-)

        Originally posted by AndreaNobili View Post
        4) Ok, I have understand what do you mean about the two types of project configuration:

        So I think that if I would use the third level of package configuration I can give to this level the name of application, so in the URL I have a name that makes sense. The MVC Showcase Showcase instead have the context root set on the external project folder...ok

        Forgive the silly question, but in your opinion, which of the two configurations is the "best"? The third package level or the one that uses the standard Maven project (as the Spring MVC Showcase)?
        I don't prefer a specific way and I think it depends on the structure of your application and the modules that you deploy to your server. For starting with this I usually use the same name for the project and for the application (the third package level), therefore it is usually all the same for me... :-)

        Originally posted by AndreaNobili View Post
        (In your book these topics are covered?)
        Which book do you mean?

        HTH,
        Martin

        Comment

        Working...
        X