Services | Updates | Contact
Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML
Search All Tutorials
Top Search: Loan Struts Open Source
Weblogic Training
BEA WebLogic is a Server that allows you to quickly develop and deploy reliable, secure, scalable and manageable applica
 
Open Source PVR
Linux users have been proud of the fact that their favorite operating system is at the heart of the most popular persona
 
More Tutorials...

Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML

 
 
Struts
Comments
 
 

 

Downloading Struts & Hibernate

                         

In this we will download Struts & Hibernate and setup the development environment.

Downloading Hibernate

Hibernate is free open source software it can be download from http://www.hibernate.org/. Visit http://www.hibernate.org/ and then click on the Download link to go to the download page. From the download page download the current latest release of Hibernate Core. For this tutorial I have downloaded Hibernate hibernate-3.1.1.zip.

Download Struts

The latest release of Struts can be downloaded from http://struts.apache.org/download.cgi. For this tutorial I have download struts-1.2.9-bin.zip. Save downloaded file into your hard disk.

Downloading Ant

Ant is a free tool under GNU Licence and is freely available at http://jakarta.apache.org/ant/ , current version of ant is 1.6.5. Ant allows the developer to automate the repeated process involved in the development of J2EE application. Developers can easily write the script to automate the build process like compilation, archiving and deployment. For this tutorial I am using apache-ant-1.6.5.

Download MySQL JDBC Driver
Download mysql-connector-java-3.0.16-ga-bin.jar from here mysql-connector-java-3.0.16-ga-bin.jar or you can download and use the latest version of mysql jdbc driver. Copy the JDBC driver file (mysql-connector-java-3.0.16-ga-bin.jar or latest version) to the jakarta-tomcat-5.5.9\common\lib directory of your tomcat installation. This will add the MySQL JDBC driver to the tomcat server.

Setting Up Development Environment

First we will create necessary directories and moved the required files to the appropriate directory. Follow the following steps to accomplish this:

  1. Create a directory in you c: drive called Struts-Hibernate-Integration.
      
  2. Unzip Downloaded file in the directory you have downloaded Struts.
      
  3. Go to the "struts-1.2.9-bin\webapps" directory and you will find struts-blank.war, struts-documentation.war, struts-examples.war, struts-mailreader.war and tiles-documentation.war files in the directory. Open struts-blank.war with WinZip and then click on the "Extract" button. WinZip asks for the directory for extracting the file, enter "C:\Struts-Hibernate-Integration" and click on Extract button.

      
  4. A new directory will created "C:\Struts-Hibernate-Integration\code" and the content of struts-blank.war is extracted in the code directory.
      
  5. Now we will add the hibernate code to our development environment. Extract hibernate-3.1.1.zip in the directory where you have downloaded. 
       
  6. Copy "hibernate3.jar" from <your downoaded direvory>\hibernate-3.1  into C:\Struts-Hibernate-Integration\code\WEB-INF\lib directory.
       
  7. Copy all the library files from "hibernate-3.1\lib" to "C:\Struts-Hibernate-Integration\code\WEB-INF\lib" directory.
      
  8. Create an directory libext under "C:\Struts-Hibernate-Integration\code\WEB-INF\" . We will used this directory to put extra jar files. Copy servlet-api.jar file your tomcat directory to "C:\Struts-Hibernate-Integration\code\WEB-INF\libext" directory. 
      
  9. Change in the build.xml file: Open "C:\Struts-Hibernate-Integration\code\WEB-INF\src\build.xml" file in your favourite editor and change as instructed below:
    a) Find "<property name="servlet.jar" value="/javasoft/lib/servlet.jar"/>" in the build.xml file and change it to "<property name="servlet.jar" value="./libext/servlet-api.jar"/>"
    b) Find "<property name="distpath.project" value="/projects/lib"/>" and change it to "<property name="distpath.project" value="../../dist"/>"
    c) Change "<property name="jdbc20ext.jar" value="/javasoft/lib/jdbc2_0-stdext.jar"/>" to "<property name="jdbc20ext.jar" value="./libext/jdbc2_0-stdext.jar"/>".
    d) Change "<property name="project.title" value="Jakarta Struts Blank "/>" to "<property name="project.title" value="RoseIndia.net Struts Hibernate Integration Tutorial "/>"
    e) Change "<property name="project.distname" value="blank"/>" to "<property name="project.distname" value="strutshibernate"/>"
    e) Change "<target name="project" depends="clean,prepare,compile,javadoc"/>" to "<!--<target name="project" depends="clean,prepare,compile"/>-->"
    You can download my build.xml fom here.
      
  10. Open console and go to the "C:\Struts-Hibernate-Integration\code\WEB-INF\src" directory  and type ant to compile the project. This show the following out put:

    C:\Struts-Hibernate-Integration\code\WEB-INF\src>ant
    Buildfile: build.xml

    clean:
    [delete] Deleting directory C:\Struts-Hibernate-Integration\code\WEB-INF\clas
    ses
    [mkdir] Created dir: C:\Struts-Hibernate-Integration\code\WEB-INF\classes

    prepare:

    resources:
    [copy] Copying 1 file to C:\Struts-Hibernate-Integration\code\WEB-INF\class
    es

    compile:

    project:

    dist:
    [jar] Building jar: C:\Struts-Hibernate-Integration\dist\strutshibernate.j
    ar
    [war] Building war: C:\Struts-Hibernate-Integration\dist\strutshibernate.w
    ar
    [war] Warning: selected war files include a WEB-INF/web.xml which will be
    ignored (please use webxml attribute to war task)

    all:

    BUILD SUCCESSFUL
    Total time: 3 seconds
    C:\Struts-Hibernate-Integration\code\WEB-INF\src>


    and it will create C:\Struts-Hibernate-Integration\dist\strutshibernate.war file which you can deploy on application server to test. You can ignore the warning generated while running the ant build tool.
       
  11. To test the application copy the strutshibernate.war to your tomcat webapps dirctory and start tomcat.
      
  12. Open browser and type http://localhost:8080/strutshibernate/. You browser page should look like: 
      

      
    This means you have successfully configured your development environment.

                         

Facing Programming Problem?
Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

4 comments so far (post your own) View All Comments Latest 10 Comments:

which is the best place for checking for invalidate session in only one place.
i am using struts framework

Posted by Anuj Patil on Wednesday, 09.26.07 @ 19:34pm | #29726

i have followed the steps provided in this but i m getting the error while startup the Tomcat..
**** Initilizing HibernatePlugIn **********
Error while initializing hibernate: JDBC Driver class not found: com.mysql.jdbc.
Driver
*************************************
Tomcat 5.5 && mysql-connector-java-3.0.17-ga.jar & jdk1.4.2 & struts-1.2.9-bin were used.....

it would be great for me if anybody Helps on this,, Thanks in advance.

Karthik.

Posted by Karthik on Wednesday, 09.12.07 @ 01:48am | #26799

I think U forgot to add ant feature to project. Please add that it will be easy.

Posted by Preeti on Thursday, 04.19.07 @ 01:29am | #14525

hi i think u did not mention how to add the ant features to the project before building the war file with ant build

Posted by sreenu on Tuesday, 04.17.07 @ 14:53pm | #14425

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2007. All rights reserved.