Saturday, August 18, 2012

Spring Hibernate jQuery Based Basic Web Application

*** For a version hosted on GitHub follow this link  . The version in this post is hosted on subversion and is  a tad older.***

For a Java base web application, you need to have Java locally. For installing Java follow Java Installation. Also you need to have an IDE locally. Any IDE is fine. The following is done on Eclipse. For details on eclipse, follow Eclipse
This base web application is a working Java based web application which can be used as a start point.  The web application is hosted in a svn repository and can be checked out. You need to have a svn client in you pc. You can use either Tortoise svn or subclipse plugin in Eclipse.  For subclipse plugin in svn follow Eclipse IDE Subversion Integration. Please be careful about the versions as the linked article might have versions which may not be relevant currently.
Also you need maven locally installed. Maven is similar to ant but much more than that. Make sure maven bin is in your executable path.
The application follows the following stack:
The versions of the above framework can be seen at pom.xml
To start with, checkout the code from
Once the code is downloaded, go to the project directory and note the pom.xml file. This is the project management file used by maven to manage the project. At the project root run the following:
mvn tomcat7:run
If you are running maven first time, this will take a good amount of time based on your internet connection. (Oh, did I told you that for maven to work properly you need to have internet connection, as Maven downloads all the dependencies from the Maven repositories.)
Run the application by pointing your browser to
If you find issues with not able to connect to 8080, then check that no application is holding the port. If everything works fine, then you will be presented with a login page. For login to work we need to insert a user in the database.
By default the application is integrated with H2 database. When you run the mvn command to launch tomcat, the database is already hosted for you. To access the database, run the H2 Server application. For running the server create an eclipse configuratioon with main class as org.h2.tools.Server. This automatically launches a browser, if not than access the browser using the rl
Select the following settings:
Saved Settings: Generic H2 (Server)
JDBC URL: jdbc:h2:tcp://localhost/~/test
In the SQL, console insert a role and user
INSERT INTO APP_ROLES (NAME) values ('ADMIN');
INSERT INTO APP_USERS (EMAIL, FIRST_NAME, LAST_NAME, STATUS, ROLE, PASSWORD) values ('admin@lalitbhatt.com','Lalit','Bhatt','A',1,'943a62b7f20672e7b16fb6fb321600fbe9a71004');
Restart the application by calling mvn tomcat7:run again. Now in the login page enter admin@lalitbhatt.com/welcome . This should take you to users list page with admin user listed.

1 comment: