-- Author: bibiye -- Release Date: 20:03:44 -- Appfuse practice (1) -- configure and install I use webwork + spring + hibernate. For more information, see tutorial. I. Prepare the system environment Download from http://java.sun.com, I use 1.4.2 _ 05. Download Tomcat from latest Tomcat release. The current version is 5.0.28. It is best not to use the Le version. Otherwise, you need to add the jar packages of DBCP and javamail. Download the latest appfuse version. I use appfuse 1.6. Download MySQL. Ant, XDoclet, spring, Hibernate (or ibatis), JUnit, cactus, strutstestcase, canoo/'s webtest, Struts menu, display tag library, Oscache, jstl and Struts (or spring MVC) components. 2. install and configure appfuse Download appfuse and decompress MySQL server needs to be started Utf8 is the default character set used to create your own application database, which is critical because appfuse supports multiple languages or the program cannot run normally. Therefore, the default Character Set of the MySQL server should also be utf8. I don't know how to change MySQL to the utf8 character set. I started it by using the name line parameter: Mysqld -- default-character-set = utf8 Now you can use ant to create your own application: Ant New-dapp. Name = MyApp-DDB. Name = mydb If you need to change the database, you can modify the parameters in the build. properties file: # Database. Jar =$ {PostgreSQL. Jar} # Database. type = PostgreSQL # Database. Name = MyApp # Database. Host = localhost # Database URL for creating other databases (doesn/'t work with pgsql) # Database. admin. url = JDBC :$ {database. Type}: // $ {database. Host}/template1 # Database. admin. Username = s # Database. admin. Password = s # Hibernate. dialect = net. SF. hibernate. dialect. postgresqldialect # Database. driver_class = org. PostgreSQL. Driver # Database. url = JDBC :$ {database. Type}: // $ {database. Host}/$ {database. name} Create a database and publish applications on Tomcat Run Ant setup If an error occurs, the database mydb cannot be created automatically. The error message is as follows: Build failed: D: // myfile // MyApp // build. xml: 830: org. dbunit. dataset. nosuchtableexception: app_user Check the execution process and put the automatically executed SQL statement for creating app_user in MySQL control center for execution. Create Table app_user ( Username varchar (20) not null, Version integer not null, Password varchar (1, 255 ), First_name varchar (50 ), Last_name varchar (50 ), Address varchar (150 ), City varchar (50 ), Province varchar (100 ), Country varchar (100 ), Postal_code varchar (15 ), Email varchar (255) not null unique, Phone_number varchar (255 ), Webwebsite varchar (255 ), Password_hint varchar (255 ), Primary Key (username) ); Execution failed. error message: [Root @ localhost: 3306] Error 1071: specified key was too long. Max key length is 500 Modified as follows, Change email varchar (255) not null unique Email varchar (100) not null unique, After testing, an error occurs when the length exceeds 166 (inclusive! I don't know why it is caused by the utf8 character set. Is a utf8 character considered to occupy three bytes (500/3 <167 )?? That is to say, the length of the field declared as not null unique cannot exceed 166. Because the SQL statement is automatically created based on the pojo Tag: Find the source program of org. appfuse. model. User. Modify @ Hibernate. Column name = "email" not-null = "true" unique = "true" Changed: @ Hibernate. Column name = "email" not-null = "true" length = "166" unique = "true" Run Ant setup-DB Successful! OK! Start Tomcat 5.0.25 Run Ant setup Error Build failed: D: // edu // build. xml: 33: Please copy JUnit. jar into C: // ANT/lib Complete copying Successful! Excellent! Open the Firefox browser and run it: Input: http: // 127.0.0.1: 8080/MyApp No response ?? What's going on ?? Start Tomcat under the command line to see if there are any error messages: Unregistering logger Catalina: TYPE = logger, Path =/MyApp, host = localhost Open C: // Tomcat // conf // Catalina // localhost // myaqpp. xml Modify: comment out the logger Information <! -- Logger classname = "org. Apache. Catalina. Logger. filelogger" prefix = "myapp_log." suffix = ". txt" timestamp = "true"/--> Restart Tomcat Still incorrect Tomcat 5.0.5.28 The error message has changed. Application not started ?? Run the task Ant install Failed! The error message is as follows: Build failed: D: // myfile // MyApp // build. XML: 1221: Java. io. ioexception: server returned HTTP response code: 401 for URL: http: // localhost: 8080/manager/deploy? Path = % 2 fmyapp Enter http: // localhost: 8080/manager/deploy in the browser? Path = % 2 fmyapp ?? In the displayed window, enter the user name and password. View MyApp // tomcat. properties. The administrator password is admin and Admin. Modify Tomcat // conf // tomcat-users.xml add administrator Admin Add two roles <Role rolename = "admin"/> <Role rolename = "manager"/> Add Admin user <User Username = "admin" Password = "admin" roles = "role1, tomcat, admin, Manager"/> Delete the MyApp directory under Tomcat and the MyApp. xml file under conf // Catalina // localhost, and restart tomcat. Run Ant install Success !! However, Tomcat reports the following error: 2004-11-14 19:59:49 org. Apache. Catalina. Core. standardhostdeployer install Information: Processing context Configuration File URL File:/C:/tomcat/CONF/Catalina/localhost/MyApp. xml 2004-11-14 19:59:49 org. Apache. Catalina. Core. standardhostdeployer install Information: Installing web application from URL jar: file:/C:/tomcat/webapps/MyApp. War! / 2004-11-14 20:00:04 org. Apache. Catalina. Core. standardcontext listenerstart Severe: skipped installing application listeners due to previous error (s) 2004-11-14 20:00:04 org. Apache. Catalina. Core. standardcontext start Severe: Error listenerstart 2004-11-14 20:00:04 org. Apache. Catalina. Core. standardcontext start Severe: context startup failed due to previous errors 2004-11-14 20:00:04 org. Apache. Catalina. Logger. loggerbase stop Information: unregistering logger Catalina: TYPE = logger, Path =/MyApp, host = localhost Why ?? Incorrect tomcat version ?? Run the struts installer. Run ant install-webwork again Build failed: D: // myfile // MyApp // build. xml: 1391: basedir D: // myfile // MyApp // extras // webwork does not exist Hmm ~~ Change the extras // viewgen directory name to webwork Run ant install-webwork again Run ant install again Open Firefox and enter http: // 127.0.0.1: 8080/MyApp. Successful! Enter the user name mraible Password Tomcat OK !! Enter the main interface (the interface is not uploaded, sorry ^_^) |