You are here: TWiki > Guides Web > Java > AppFuseInstallation r4 - 23 Mar 2006 - 07:57 - JesseSuen


Start of topic | Skip to actions

Setting Up Your First AppFuse Project

AppFuse is a well known and commonly used starter web application to get you started on a J2EE app and is one of the most popular and top ranked/accessed projects on java.net. It was created by Matt Raible, who wrote the book Spring Live. AppFuse? includes many useful libraries/binaries necessary for your app, including ant, javamail, spring, struts, junit, hibernate, mysql/postgresql jdbc drivers, and many more. It creates a directory structure based on best practices, provides a build.xml file which has options to compile, deploy, run tests, start/stop tomcat, and setup your database. The app even includes a sample application which shows the use of struts, spring, hibernate, JSF -- whichever source you decide to download. This tutorial will show you how to set up your environment to start using AppFuse?.

  1. Install Tomcat (5.5.16) http://tomcat.apache.org/. Make sure you choose 5.5.16 because 5.5.15 has a bug where the ant reload command will fail with java.lang.NoClassDefFoundError. See http://raibledesigns.com/page/rd?entry=why_i_like_tomcat_5 for details on the problem.
  2. Install MySQL? (5.0.18) http://www.mysql.com/
  3. Install Ant (1.6.5) http://ant.apache.org/
  4. This tutorial uses cygwin so you may also want to install it as well. You can get it from http://www.cygwin.com.
  5. After installing, add system environment variables for each of root installation directories. Access this by right clicking My Computer and selecting properties. It is under: System Properties -> Advanced -> Environment Variables. The variables should look something like this:
ANT_HOME = C:\Development\ant
CATALINA_HOME = C:\Development\Apache Software Foundation\Tomcat 5.5
JAVA_HOME = C:\Program Files\Java\jdk1.5.0_06
  1. Append the $JAVA_HOME\bin, $ANT_HOME\bin, $CATALINA_HOME\bin, and your MySQL? bin directories to your PATH variable. It should look something like this:
PATH=.......;C:\Development\MySQL\MySQL Server 5.0\bin;%JAVA_HOME%\bin;%ANT_HOME%\bin;%CATALINA_HOME%\bin
  1. Edit Tomcat's tomcat-users.xml file and create a password for your admin user.
$ cd "$CATALINA_HOME/conf/"
$ vi tomcat-users.xml
  <user username="admin" password="admin" roles="admin,manager"/>
  1. Access the mysql console and create a user with the ability to create databases and tables:
$ mysql -u root -p
> GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' IDENTIFIED BY 'admin' WITH GRANT OPTION;
  1. Download AppFuse? 1.9 from https://appfuse.dev.java.net/. The Struts + Spring + Hibernate version is called: appfuse-1.9-src.zip
  2. Unzip to your workspace directory:
$ unzip appfuse-1.9-src.zip
  1. Create a new project using the "ant new" command in the appfuse directory. It will ask you to name your new application, choose a database, and a package name for your classes.
$ cd appfuse
$ ant new
What would you like to name your application [myapp]?
What would you like to name your database [mydb]?
What package name would you like to use [org.appfuse]?
  1. After your app has been created, cd to your app root directory and setup your database username and password in the build.properties file:
$ cd ../myapp/
$ vi build.properties
database.admin.username=admin
database.admin.password=admin
  1. In the same directory, edit the properties.xml file to use the tomcat user you created:
$ vi properties.xml
    <property name="tomcat.username" value="admin"/>
    <property name="tomcat.password" value="admin"/>
  1. The following command will create your database and tables, setup your webabb in Tomcat, and start the application.
$ ant setup-db setup-tomcat deploy
  1. You are done. The webapp should be setup on http://localhost:8080/myapp/. The database should already be setup with the user:
username: mraible
password: tomcat

References

-- JesseSuen - 02 Mar 2006

Edit | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r4 < r3 < r2 < r1 | More topic actions
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback