Friday, October 29, 2010

A dive into Web app frameworks

Started to look for a good Web application framework to do my last piece of dissertation. I am quite a newbie in the world of Web app development and suddenly got swamped by the vast amount of existing frameworks. Most of these use MVC architecture–using MySQL/Postgresql as RDBMS, Hibernate/iBatis as the ORM layer, Spring to implement business logic and a presentation framework such as Spring MVC, Struts/Struts2(merge of Struts and WebWork2), JSF, Tapestry, etc.


I tried to take a look at Matt Raible’s appfuse project, which is a ready-to-use framework that provides customized stacks of existing frameworks at various layers. It’s quite cool, but still I need quite a lot of time to learn.


Then, I read about comparisons of many existing frameworks and found the new trend to favor much simpler and easy-to-use frameworks such as Wicket, Stripes, Click. After reading their documentation, quick start guide and sample applications. I decided to try Wicket.


Wicket is a bit different from those MVC frameworks in that it cleanly separates UI design (in html) and application implementation (in Java code). Also opposite to frameworks that use a lot of XML configuration files, Wicket does not use any XML configuration or Java annotations. From its rich set of live examples, ajax integration is quite good.


So, I set out and started to learn and use Wicket. First, I tried to follow its online example code. However, those code is quite outdated and its maven pom.xml file did not even work properly. I had to use mvn eclipse plugin (mvn eclipse:eclipse) to import code into eclipse. After many attempts to fix the pom file, I finally gave up. It appears to be a Wicket plugin for eclipse (Wicket Bench from Laughing Panda), however this plugin is quite primitive and showed many errors in my eclipse 3.2.2.


Then, luckily I found a wicket module for Netbeans 5.5 (module is the plugin for Netbeans). It has well-documented steps to develop wicket applications and everything is made so simple in Netbeans. I even did not have to worry about libraries and dependency configurations, etc. The bundled Tomcat 5.5.17 is launched automatically when you run the Web application and the browser page is brought out automatically as well. Nice features like HTTP monitor, log messages are also available to help.


I think now I need to explore more about Netbeans 5.5. It’s really a quite sharp and neat tool, in some aspects better than eclipse/MyEclipse 5.1.1 I am using now.


A note to configure Tomcat and use log4j 1.2 and commons-logging:
1. Shutdown Tomcat if it is currently running.
2. Download the Commons Logging package from the Apache web site (unless you already have it).
3. Copy the commons-logging.jar file from the distribution into your Tomcat common/lib directory.
4. Download the Log4j package from the Apache web site (unless you already have it).
5. Copy the log4j.jar file from the distribution into your Tomcat common/lib directory.
6. Create a log4j.properties file in your Tomcat common/classes directory (see next section).
7. Restart Tomcat.


Sample log4j.properties file:
#


Configures Log4j as the Tomcat system logger



#


#


Configure the logger to output info level messages into a rolling log file.



#
log4j.rootLogger=INFO, R


#


To continue using the “catalina.out” file (which grows forever),



comment out the above line and uncomment the next.



#


log4j.rootLogger=ERROR, A1



#


Configuration for standard output (”catalina.out”).



#
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
#


Print the date in ISO 8601 format



#
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n


#


Configuration for a rolling log file (”tomcat.log”).



#
log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.DatePattern=’.'yyyy-MM-dd
#


Edit the next line to point to your logs directory.



The last part of the name is the log file name.



#
log4j.appender.R.File=/usr/local/tomcat/logs/tomcat.log
log4j.appender.R.layout=org.apache.log4j.PatternLayout
#


Print the date in ISO 8601 format



#
log4j.appender.R.layout.ConversionPattern=%d [%t] %-5p %c - %m%n


#


Application logging options



#


log4j.logger.org.apache=DEBUG



log4j.logger.org.apache=INFO



log4j.logger.org.apache.struts=DEBUG



log4j.logger.org.apache.struts=INFO

No comments:

Post a Comment