Integrate Struts, Hibernate and Spring

In this section you will learn how to download required software for our
Login and Registration Application. In this tutorial we are using one of the
best technologies (Struts, Hibernate and Spring). This tutorial is very good if
you want to learn the process of integrating these technologies in your
application and developed highly scalable and robust web application.
Download Struts:
The latest version of Struts can be downloaded from http://struts.apache.org/download.cgi.
We are using Struts version
Download Hibernate:
The latest version of Hibernate can be downloaded from http://www.hibernate.org/6.html.
We are using hibernate-3.1.3 for this tutorial.
Download Spring:
The latest version of Spring Framework can be downloaded from http://www.springframework.org/download.
We are using spring-framework-1.2.8-with-dependencies for this tutorial.
Setting up Development Directory:
Development directory is very important for any project. It helps you
organize all the software components to make the development process easy. In
the web development process you make changes to the program and then compile,
package and deploy on the application on the application server. Once the
application is deployed you test the effect of your changes. This is repetitive
task in the programming, so its is very important to have good directory structure
that helps you reduce the time taken in compilation and deployment process. In
our application we are using tomcat server. Here are the process to integrate
all the components and then compile and test your development directory structure.
If you don't want to waste the time in setting up the directory structure you
can download the full application from our website. To
download the code click here.
- Extract "struts-blank.war" into copy the directory "struts-blank"
to "integrated\src" and rename the directory struts-blank
to project.
- Copy all the files from "spring-framework-1.2.8-with-dependencies\spring-framework-1.2.8\dist"
into "\integrated\src\project\WEB-INF\lib".
- Copy hibernate3.jar from hibernate-3.1.3\hibernate-3.1 into \integrated\src\project\WEB-INF\lib.
- Copy all the files from "hibernate-3.1.3\hibernate-3.1\lib"
into "integrated\src\project\WEB-INF\lib".
- Download "applicationContext-hibernate.xml" and "jdbc.properties"
files and then place in the "integrated\src\project\WEB-INF\"
folder.
- Modify the "jdbc.properties" and change the following
parameters for your database:
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://192.168.10.3:3306/strutshibernatespring
jdbc.username=deepak
jdbc.password=deepak
- Create an directory "libext" under "project\WEB-INF\".
This directory will be used in our project to place the library files that
which will used to compile the java classes. For compiling Servlets we need
the Servlet, so you find "servlet-api.jar" from you tomcat
server and copy in "libext" directory.
- Download "build.xml" file and replace the "build.xml"
file present in "project\WEB-INF\src" directory.
- In the build.xml file you can change the jar file name for your
application by changing the following
value:
<property name="project.jar.file" value="project.jar"/>
When you run ant compile from command prompt, all the java files will be
compiled and a jar file is created and placed in the lib directory.
- Now copy the project directory to webapps directory of your tomcat
server.
- Start the tomcat and type http://localhost:8080/project in browser.
Your browser should show the default welcome page that comes with
struts-blank application.
In this section you have setup the directory structure for your web
application and tested on the tomcat server.

|
Current Comments
11 comments so far (post your own) View All Comments Latest 10 Comments:Hi
Thanks for this interesting tutorial !!
I can't uncompress the project.zip, the file is corrupt.
please check href links...
Thanks in advance !!
Doxumd
Posted by doxumd on Wednesday, 02.6.08 @ 15:28pm | #47408
It is really helpful for quick learning.
Posted by Raghu on Thursday, 11.29.07 @ 16:14pm | #40886
Hi ,
Can you tell me how to run this application on MyEclipse .
CAn you provide me a Login application only of Struts and database combination.
Posted by Pankaj on Sunday, 11.18.07 @ 10:05am | #37686
Deepak,
I have the app working on Weblogic, but I get the error below when trying to login with an invalid username. Any thoughts?
java.lang.NoSuchMethodError: com.mycompany.work.web.struts.action.UserLoginAction.saveErrors(Ljavax/servlet/http/HttpServletRequest;Lorg/apache/struts/action/ActionMessages;)V
at com.mycompany.work.web.struts.action.UserLoginAction.execute(Unknown Source)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:223)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3245)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2003)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1909)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1359)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
Posted by Gary on Friday, 09.28.07 @ 00:42am | #30099
How different are the deploy steps to get this running on weblogic server?
Posted by Gary on Wednesday, 09.19.07 @ 19:48pm | #27862
sir i have not downloaded this code
Posted by surya on Saturday, 08.4.07 @ 17:22pm | #22652
notes is good fr learnimg see thi
Posted by naresh on Tuesday, 07.17.07 @ 12:10pm | #21424
There are several broken links. Please check the accordingly.
Thanks,
Akash
Posted by Akash Borkar on Friday, 12.1.06 @ 14:49pm | #321
Hi,
The correct file is http://www.roseindia.net/struts/hibernate-spring/project.zip
I have updated the page. Thanks for pointing out the boken link issue.
Deepak
Posted by Deepak Kumar on Wednesday, 11.29.06 @ 21:03pm | #207
Hi Deepak,
The struts-spring-hibernate.zip is not accessible. I hope it can be fixed as soon as possible.
Thank you.
Posted by newbie on Wednesday, 11.29.06 @ 20:06pm | #206