- Requirements: JDK 1.4.2 (or above), Tomcat 5.0+, Ant 1.6.1+
- Also, you can use cygwin in windows to emulate linux like commands
- set JAVA_HOME, ANT_HOME, CATALINA_HOME environment variables – paths to the installed software
- Add to PATH: JAVA_HOME/bin, ANT_HOME/bin, CATALINA_HOME/bin
- You can start with the minimal application like struts-blanke.war or webapp-minimal that contains the basic files for struts and spring frameworks respectively. Or start with a equinox download from https://equinox.dev.java.net/files/documents/1901/5728/equinox-1.0.zip that will simplify strut-spring integration/switching. Download and unzip
- Make sure that the environment variables are set properly. Take a look at build.xml file. Check different sections like compile, distribution, ant-tomcat, help, database
- run ant new -Dapp.name=users from windows/linux/cygwin command prompt. It will create a new application with name users.
- Check the directory structure. It should look like as follows:
- under newly created users directory run commands like ant and check output. In build.xml, change default=”help” to default=”compile”, run ant again, run ant deploy, play with different ant commands
- if ant command shows error messages then you may need to change build.xml file as indicated. With equinox, you may face path error like {…}/common/lib or {…} lib
- If things don’t work right, check build.properties and modify the options if required. Play again
- Also, check tomcatTasks.properties file to see what classes are used for different ant commands (used in the build.xml file)
- Run ant list to check the services running. if the command fails, check that build.properties file contains right information. Make sure tomcat-users.xml file under the Tomcat installation directory has an entry for users as provided in the build.properties file
- Make sure, you are under the users directory
- run: ant deploy : the users application will be deployed under Tomcat. Check target name=deploy section in your build.xml file. You will see what actually happens in deployment (mostly copy)
- Using your browser, go to: http://localhost:8080/users/, you will see the interface of the users application
- Unit Test Persistence Layer
- Hibernate for persistence
- Hibernate relates Java Objects to database tables, makes CRUD (Create, Read, Update, Delete) very easy
- Spring + Hibernate: 75% code reduction than Hibernate alone: [ref:Internet, sourcebeat.com]
- Spring + Hibernate: removal of a ServiceLocator, removal of several DAOFactory classes, replace Hibernate’s checked exceptions with Spring’s runtime exceptions
- Before proceeding further, you may want to open the application using Eclipse. You can also use any editor to create Java files.
- Eclipse 3.3.2: How to open the project: File->new->project->java->java project->create project from existing source->identify the location and provide project name as users->you may want to switch to java perspectives.
- Click on build.xml file. Right click -> run as -> 2 Ant Build. If compilation fails: change basedir to the application directory. If it fails again check, tomcat directories and the directories mentioned in the build.xml files are the same. [you may not need /server in build.xml for tomcat 6.o]
- Check: build.xml -> right click -> Run As -> 3. Ant Build -> check that you selected the operation you want. If you want to deploy your application after compilation you need to select compile, deploy. Check what else apply. Or you can use the ant command [with options] from the command prompt
- Now Hibernate and Persistence again:
From: http://sitestree.com/?p=4924
Categories:Java Short Notes
Tags:
Post Data:2006-12-25 08:52:32
Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada