Results 1 to 10 of 12

Thread: Creating Spring MVC Template Project

Hybrid View

  1. #1

    Default Creating Spring MVC Template Project

    I am trying to create a Spring MVC template project according to the Spring Pro 3 book, chpt 16. It indicates to create a Spring Template Project, then select Spring MVC project then enter the name and base package. This is supposed to create a basic project with a hello world jsp page. I don't even get the webapp directory.

    As per the book, I added the following dependencies to the POM for the JPA backend:

    HTML Code:
    	<!-- JPA backend -->
     	<dependency> 
     		<groupId>org.springframework</groupId> 
     		<artifactId>spring-jdbc</artifactId> 
     		<version>${org.springframework-version}</version> 
     	</dependency> 
     	<dependency> 
     		<groupId>org.springframework</groupId> 
     		<artifactId>spring-orm</artifactId> 
     		<version>${org.springframework-version}</version> 
     	</dependency> 
     	<dependency> 
     		<groupId>org.springframework</groupId> 
     		<artifactId>spring-tx</artifactId> 
     		<version>${org.springframework-version}</version> 
     	</dependency> 
     	<dependency> 
     		<groupId>org.springframework.data</groupId> 
     		<artifactId>spring-data-jpa</artifactId> 
     		<version>1.0.1.RELEASE</version> 
     	</dependency> 
     	<dependency> 
     		<groupId>org.hibernate</groupId> 
     		<artifactId>hibernate-entitymanager</artifactId> 
     		<version>3.6.8.Final</version> 
     	</dependency> 
     	<dependency> 
     		<groupId>javax.validation</groupId> 
     		<artifactId>validation-api</artifactId> 
     		<version>1.0.0.GA</version> 
     	</dependency> 
     	<dependency> 
     		<groupId>org.hibernate</groupId> 
     		<artifactId>hibernate-validator</artifactId> 
     		<version>4.2.0.Final</version> 
     	</dependency> 
     	<dependency> 
     		<groupId>com.h2database</groupId> 
     		<artifactId>h2</artifactId> 
     		<version>1.3.160</version> 
     	</dependency> 
     	<dependency> 
     		<groupId>com.google.guava</groupId> 
     		<artifactId>guava</artifactId> 
     		<version>10.0.1</version> 
     	</dependency> 
     	<dependency> 
     		<groupId>joda-time</groupId> 
     		<artifactId>joda-time</artifactId> 
     		<version>2.0</version> 
     	</dependency> 
     	<dependency> 
     		<groupId>joda-time</groupId> 
     		<artifactId>joda-time-hibernate</artifactId> 
     		<version>1.3</version> 
     	</dependency> 
     	
     	<!-- JMS 
     	<dependency> 
     		<groupId>org.apache.activemq</groupId> 
     		<artifactId>activemq-core</artifactId> 
     		<version>5.5.1</version> 
     	</dependency> 
     	<dependency> 
     		<groupId>org.springframework</groupId> 
     		<artifactId>spring-jms</artifactId> 
     		<version>${org.springframework-version}</version> 
     	</dependency> 
     	<dependency> 
     		<groupId>javax.jms</groupId> 
     		<artifactId>jms-api</artifactId> 
     		<version>1.1-rev-1</version> 
     	</dependency> 
     	-->
    I set the server to VMware vFabric tc Server Developer Edition v2.7

    I am using STS 3.1.RELEASE. As I said, there is no webapp directory created and no automatically created home.jsp file which print a Hello World message with the date and time.

    Thanks
    Mike

  2. #2
    Join Date
    Jan 2013
    Location
    us
    Posts
    2

    Default

    Hi,

    Give me some tips for template creation.

  3. #3

    Default Creating MVC Template

    Quote Originally Posted by johny brawn View Post
    Hi,

    Give me some tips for template creation.
    Thanks Johny, it's pretty straight forward. Create a new Spring Templete Project, then from the pop-up dialog select "Spring MVC Project", give it a name and a base package. That's pretty much it. The only other thing I did was add the following dependencies to the Pom: spring-jdbc, spring-orm, spring-tx, spring-data-jpa, hibernate-entitymanager, validation-api, hibernate-validator, h2, joda-time, jodat-time-hibernate, guava. These additions were for the back-end for the project.

    Supposedly after creating the project and adding the extra dependencies, you can click on the project, selec run, then run on server and it brings up VMware VFabric tc Server v2.7. You then see a Hello World jsp page at http://localhost:8080/ch17 (ch17 was the name of the project). But I don't even get a webapp directory created let alone a home.jsp file which contains the Hello World greeting.

  4. #4

    Default

    I solved the problem, actually there never was a problem. Spring was creating the files correctly, just not where I expected. The problem I am having now is error 404. When one creates a Spring MVC template project, you get a home.jsp file that displays Hello World and the time. You should not have to configure anything. When I do this and run it on the server it gives me a 404 file not found.

    When you create a Spring MVC project, just after creating it you have a home.jsp file. According to the book I'm using when you run the project on the server it will try to access http://localhost:8080/xx to display the home.jsp file. XX is the name of the project you created. In my case it's ch17, but when I run it on the server it tries to go to http://localhost:8080/prospring.
    Where is it getting this "prospring" from?

    Note: I downloaded Eclipse, got the STS and maven plug-ins and got this to work almost right away. The POM and *.xml files are all the same, but under STS 3.1 it still won't work. It still tries to go to http://localhost:8080/prospring3 instead of http://localhost:8080/test where test is the name of the project. I don't know where it is getting the prospring3
    Last edited by MikeT; Jan 5th, 2013 at 08:48 PM. Reason: update

  5. #5
    Join Date
    Jan 2013
    Posts
    5

    Default

    Hi,

    I am also facing the same issue. In my case, instead of getting the project name it is adding the base package name.

    That is , my project name is LoginProject and base package is com.sample.login.

    if I give the URL like "http://localhost:8080/login, then it is able to display home.jsp content on browser.
    if I give URL like "http://localhost:8080/LoginProject, I am getting 404 error.

    I am not able to find, how it is happening. Could anybody help me on this?

  6. #6

    Default Spring MVC tempate project

    Quote Originally Posted by srujana View Post
    Hi,

    I am also facing the same issue. In my case, instead of getting the project name it is adding the base package name.

    That is , my project name is LoginProject and base package is com.sample.login.

    if I give the URL like "http://localhost:8080/login, then it is able to display home.jsp content on browser.
    if I give URL like "http://localhost:8080/LoginProject, I am getting 404 error.

    I am not able to find, how it is happening. Could anybody help me on this?
    I can't even get the home page if I put in the correct URL.

Posting Permissions

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