Posts Tagged 'AppFuse&'

Nov

16

AppFuse 2.0 M4 Released

Posted by admin under technology - No Comments

The AppFuse Team is pleased to announce the release of AppFuse 2.0 M4!
This release marks a milestone in the usability of AppFuse 2.x. A lot of folks (including myself) have been using AppFuse 2.0 on projects and have fixed quite a few issues. In addition to polishing the tutorials, we’ve fixed a fair amount of i18n bugs and packaging issues with modular archetypes.

We were hoping to get AMP’s code generation and XFire integrated in M4, but were it’s going to have to wait until M5.

AppFuse 2.0 is available as a Maven archetype. For information on creating a new project using this release, please see the QuickStart Guide.

If you’ve used AppFuse 1.x, but not 2.x, you’ll want to read the FAQ and join the user mailing list if you have any questions. The Maven Reference Guide has a map of Ant -> Maven commands.

The 2.0 series of AppFuse has a minumum requirement of the following specification versions:

  • Java Servlet 2.4 and JavaServer Pages (JSP) 2.0
  • Java 5 for Development (Java 1.4 for deployment using the Retrotranslator Plugin)

For more information, please see the 2.0 M4 Release Notes.

We appreciate the time and effort everyone has put toward contributing code and documentation, posting to the mailing lists, and logging issues.

Nov

15

AppFuse 2.0 M3 Released

Posted by admin under resource - No Comments

The AppFuse team is pleased to announce the release of AppFuse 2.0 M3!

This release marks a milestone in our documentation efforts. We’ve completed all of the web framework tutorials and ensured that all the archetypes work properly. Turkish language support was added and native2ascii was integrated so all i18n bundles should work properly.

The major things missing from this release are code generation (AppGen) and web services (XFire) support. We hope to add both of these before the final release.

AppFuse 2.0 is available as a Maven archetype. For information on creating a new project using this release, please see the QuickStart Guide.

The 2.0 series of AppFuse has a minumum requirement of the following specification versions:

  • Java Servlet 2.4 and JavaServer Pages (JSP) 2.0
  • Java 2 Standard Platform Edition (J2SE) 5.0

For more information, please see the 2.0 M3 Release Notes.

We appreciate the time and effort everyone has put toward contributing code and documentation, posting to the mailing lists, and logging issues.

Nov

15

Install and configure AppFuse

Posted by admin under technology - No Comments

To install and configure AppFuse for development, see the QuickStart Guide at:
http://raibledesigns.com/wiki/Wiki.jsp?page=AppFuseQuickStart.

To learn how to develop your J2EE webapps with AppFuse, see
http://raibledesigns.com/wiki/Wiki.jsp?page=Articles (or docs/index.html if you
downloaded the AppFuse source distribution). You can also download all the
latest documentation to the “docs” directory by running “ant wiki”.

To build this application - you must be using Ant 1.6.2+. You will also need
to copy junit.jar into your $ANT_HOME/lib directory.

You are expected to have Tomcat 5.0.x+ installed, as well as an SMTP server on
localhost. If you don’t want to install an SMTP server, change
web/WEB-INF/classes/mail.properties to point to an existing one.

To run this application, you will need to perform the following tasks:

1. The default database setup expects a mysql database installed with
an admin user named “root” and no password. If your system is different,
modify properties.xml or build.properties to override the default values.
2. Run “ant setup-db”. This creates a mysql database named “appfuse” and
grants the user “test” (password: test) full rights to this database.
3 Test that the db access code works with:
ant test-dao -Dtestcase=UserDAO
ant test-service -Dtestcase=UserManager
4. Setup Tomcat by running “ant setup-tomcat deploy”. This deploys an
appfuse.xml file to $CATALINA_HOME/webapps ($CATALINA_HOME/conf/Catalina/
localhost on Tomcat 5). It also deploys the application to
$CATALINA_HOME/webapps.
5. Start Tomcat and test the web login using “ant test-canoo -Dtestcase=Login”.
If you experience issues with Tomcat, check your build/test/cargo.log file.

Nov

15

AppFuse Tutorials

Posted by admin under resource, technology - No Comments

If you’ve just downloaded AppFuse and want to setup it up on your machine, your best bet is the QuickStart Guide. Once you’ve got everything setup, the tutorials below are a great resource for learning how to develop with AppFuse. NOTE: These tutorials are included in AppFuse’s distribution. If you want to update your project’s copy (in the docs directory), run “ant wiki”.As of 1.6.1, you can generate most of the code covered in these tutorials. If you’re using Struts+Hibernate, you can generate all of it. For Spring and WebWork, it was too much trouble to write the installers so you will need to manually configure the Controllers and Actions. This was mainly due to the fact that I’m not using XDoclet for these web frameworks and the limitations of using Ant as an installer. The AppGen tool which generates the code is covered in Part I.

There’s also an AppFuse Generator project that has similar functionality to AppGen.

Part I: Creating new DAOs and Objects in AppFuse - A HowTo for creating Java Objects (that represent tables) and creating Java classes to persist those objects in the database.

Translations: Chinese, Portuguese, Spanish

Part II: Creating new Managers - A HowTo for creating Business Facades that talk between the database tier (DAOs) and the web tier (Actions or Controllers).

Translations: Chinese, Portuguese, Spanish

Part III: (Struts) Creating Struts Actions and JSPs - A HowTo for creating Actions and JSPs in your AppFuse project. Includes generating JSPs and customizing them to look good. Also, you will write a WebTest to test the JSPs functionality. Other web framework options are as follows:

Translations: Chinese, Portuguese
Translations: Portuguese

Part IV: (Struts) Adding Validation and List Screen - Adding validation logic to the personForm so that firstName and lastName are required fields and adding a list screen to display all person records in the database.

Translations: Chinese, Portuguese
Translations: Portuguese

NOTE: You can generate the files created in these tutorials by using AppGen. If you experience problems - you should be able to compare your results to what AppGen does. To do this, cd into extras/appgen, and run “ant test-detailed”. This will create an “appfuse-appgen” project, generate the code in these tutorials, and test everything.

Thomas Gaudin’s Excellent AppFuse Tutorials

Thomas Gaudin has put together a couple of detailed and easy-to-follow tutorials on his site.

Related AppFuse HowTos

Translations: Portuguese
Translations: Portuguese

Server Configuration


Other

Outdated Articles that still get some traffic:

Nov

15

AppFuse: Start Your J2EE Web Apps

Posted by admin under technology - No Comments

by Matt Raible
07/15/2004

One of the hardest parts about J2EE development is getting started. There is an immense amount of open source tools for web app development. Making a decision on which technologies to use can be tough — actually beginning to use them can be even more difficult. Once you’ve decided to use Struts and Hibernate, how do you go about implementing them? If you look on the Hibernate site or the Struts site, you’ll probably have a hard time finding any information on integrating the two. What if you want to throw Spring into the mix? As a developer, the best way for me to learn is by viewing sample apps and tutorials that explain how to extend those applications. In order for me to learn (and remember) how to integrate open source technologies such as Hibernate, Spring, Struts, and Ant/XDoclet, I created AppFuse. The beauty of AppFuse is you can actually get started with Hibernate, Spring, and Struts without even knowing much about them. Using test-driven development, AppFuse and its tutorials will show you how to develop a J2EE web application quickly and efficiently.

The Birth of AppFuse

In early 2002, I managed to land a contract where I was the lone developer. I was responsible for everything, from gathering requirements to database creation to DHTML on the web front end. While I’d done a lot of front-end work (Struts, HTML, etc.) over the years, the business layer and persistence layer were mostly new to me. So I searched and searched for J2EE patterns to do things the “right way” for my new client. I ended up implementing Business Delegates, DAOs, and ServiceLocators — many of them modeled after J2EE Blueprints. Towards the end of that contract, I was contracted to help write a book on JSP 2.0. The publisher was Wrox Press and the book was Professional JSP 2.0. I volunteered to write two chapters — one on Struts and one on web security. Note: in March 2003, Wrox went out of business and this book eventually became Pro JSP, Third Edition, published by Apress.

When you write a technical book, it’s helpful to use a sample app to demonstrate concepts. I was tired of reading books that had a throwaway sample app, so I wanted to develop something meaningful; something I could use after I was done writing. My initial thoughts were to write an application that would help you get started with Struts, and would use XDoclet to do a lot of the heavy lifting. It also had to have a lot of security features so I could use it for my chapter on web application security. I came up with the name struts-xdoclet and began developing my application.

After a couple of weeks, I decided that “struts-xdoclet” was too hard to say and renamed the project AppFuse. I developed the sample app for my Struts chapter using AppFuse and released it as Struts Resume. After publishing Struts Resume, I needed to extract the resume-specific stuff out of it to revert back to the generic “jumpstart” application I wanted AppFuse to be. It took me almost three months, but I finally released the first official version of AppFuse in April 2003.

Since its initial release, AppFuse has gone through many changes and improvements. Most of the technology decisions were made from experience. It was a pain to keep my ValueObjects (VOs) and ActionForms in sync, so ActionsForms are generated using XDoclet. I found it tedious to write JDBC and more tedious to update SQL and VOs when adding new table columns. To solve this, I chose to use Hibernate for persistence and use Ant/XDoclet to dynamically create my database tables. Rather than lose my tables’ data each time, I integrated DBUnit, which also came in handy when running unit tests. I decided to use Tomcat/MySQL as the default server/database setup because I was most familiar with them. I integrated a plethora of unit/integration tests so I could make sweeping changes and verify that everything still worked (including the JSPs) by running ant test-all.

In March of 2004, I moved the AppFuse project from the Struts project on SourceForge to java.net. I had a couple of reasons for doing this. First of all, it was a sub-project on SourceForge, and its user base was growing quickly. It needed dedicated mailing lists and forums. Secondly, java.net seemed to do a better job of marketing projects and I’d heard their CVS system was much more stable. My experience at java.net has been quite nice: it’s a very stable system, and the administrators are very supportive of the project and have even helped with marketing it.

What is AppFuse?

So after all that history, what is AppFuse? At its very core, AppFuse is a web application that you can package into a .war and deploy to a J2EE 1.3-compliant app server. It’s designed to help you create new web applications using a new target in its build.xml file. The new target allows you to specify a name for your project and a name for the database it will talk to. Once you’ve created a project, you can instantly create a MySQL database and deploy it to Tomcat using ant setup. Furthermore, you can verify that the basic functionality of your new application works by running ant test-all. At this point, you might sneer and say, “What’s the big deal? Anyone can create a .war file and deploy it to Tomcat.” I agree, but do you have a setup-tomcat target that will configure Tomcat with JNDI resources for connections pooling and mail services? Most of what AppFuse does is not rocket science. In reality, it’s nothing more than a directory structure, a build file, and a bunch of base classes — with a few features thrown in. However, it has vastly accelerated my ability to start projects and develop high-quality, well-tested web applications.

AppFuse tries to make it as simple as possible to build, test, and deploy your application. It virtually eliminates setup and configuration, which are often the hard parts. Tools like Ant, JUnit, XDoclet, Hibernate, and Spring can be difficult to get started with. Furthermore, features like authentication, password hints, “remember me,” user registration, and user management are things that most web apps need. AppFuse ships with tutorials for developing DAOs, business delegates, Struts actions (or Spring controllers), integrating tiles and validation, and uses an Ant-based XDoclet task (written by Erik Hatcher) to generate master/detail JSPs from model objects. It uses slick open source tag libraries like Struts Menu (for navigation) and the Display Tag (for paging and sorting lists).

One of the best parts, in my opinion, is that it embraces the Java community’s ideas and suggestions. The directory structure and build file are largely based on Erik Hatcher and Steve Loughran’s excellent Java Development with Ant book. In this book, Erik built a sample application that inspired me to learn more about Ant and XDoclet — and use it in my Struts development.

When I first started learning and using Hibernate in AppFuse, I made many mistakes — and the community let me know. At first, I opened and closed its Session object for each DAO method. When Gavin told me this was a bad idea, I made modifications to use an OpenSessionInView pattern, with my own ServletFilter to do the work. I passed the session object into each method signature, for which the community repeatedly questioned my logic. My answer was, “I wanted to get it working more than anything — do you have a better idea?” The better idea turned out to be using the Session as a constructor argument, which worked pretty well.

Then, late last year, I discovered the Spring framework and found the beautiful solution I’d been looking for. Using its ORM support, I was able to eliminate any Session handling in AppFuse; now Spring elegantly handles it all. AppFuse now uses Spring’s OpenSessionInViewFilter. All I needed to do was configure it in web.xml and it manages opening and closing the session for me. When I integrated Spring in AppFuse’s persistence layer, I deleted two or three classes and reduced my LOC count by around 75 percent. All of the Hibernate issues I’d had before disappeared! In addition, I was quickly able to add a DAO implementation using iBATIS, which I worked with on a project last year. On that project, I discovered that iBATIS was easy to use and worked very well for interacting with complex database schemas.

AppFuse is not only a jumpstart kit for your web apps; it’s also a showcase for integrating technologies like Hibernate, Spring, and Struts. Tutorials exist for integrating these different open source components, but rarely do they give you an application you can walk away with and use to develop your next application. In a sense, AppFuse is a glue that binds open source projects together. When I found Spring, it was a perfect fit, since it was the glue to configure components and loosely couple the different layers of an application. Erik’s book might have been the match that lit AppFuse, but Spring is the gasoline that really got it roaring. Spring has vastly simplified how I develop with AppFuse and forced me to follow best practices in J2EE. In short, it’s the best tool I’ve ever used with J2EE. I realize Spring is not the be-all-end-all for J2EE applications — AppFuse worked fine before I integrated it. However, it helped answer all of my “How should I do …” questions — which was a nice relief.

What Does the Future Hold?

AppFuse 1.5 was released at the end of May. Its major feature is the option to use Spring MVC instead of Struts. All of the tutorials have been updated to educate users how to use Spring (or Struts) for their web layers. For AppFuse 1.6, I plan to add support for using WebWork and SiteMesh, as well as make it easier to run unit tests from Eclipse and IDEA. By the end of the year, I hope to add Tapestry and JSF as MVC options. The middle tier and back end (Spring plus Hibernate) probably won’t change much. It’s a well-oiled machine at this point. This isn’t to say that I think AppFuse is perfect. I hope I continue to receive valuable feedback and suggestions. After all, this is the driving force behind improving its quality.

When I find innovative and easier ways to develop web apps, it ends up in AppFuse. People ask me why AppFuse doesn’t support Middlegen. The reason is simple: I’ve never used or needed Middlegen on a project, so I don’t see any reason to add it. If I end up on a project where I use Middlegen, you can bet I’ll end up adding support for it. Recently, I started using Spring’s MVC framework instead of Struts. At first, I found it a bit difficult to understand, so I implemented the web layer with Spring MVC. Since the web layer contains many features that I use in web apps (i.e., templating, validation, file upload, and exception handling), I learned the ins and outs of Spring MVC by integrating it.

Using and learning AppFuse is a good way to keep up to date with the latest releases of its dependent projects. I try to keep as up to date as possible with new releases — and due to AppFuse’s unit test coverage, I can easily test new releases by dropping them in and running ant test-all. This even works for dependent resources such as Tomcat and MySQL, in which I’ve found bugs via AppFuse. For me, it acts as a testing tool to verify the functionality of new open source releases.

AppFuse Light

Equinox is a lightweight version of AppFuse; hence its pseudonym “AppFuse Light.” I was inspired to create it when looking at the struts-blank and webapp-minimal applications that ship with Struts and Spring, respectively. These “starter” apps were not robust enough for me, and I wanted something like AppFuse, only simpler — with no build-time dependencies.

It’s designed to show web app developers how to start a bare-bones Struts/Spring/Hibernate app using the QuickStart Chapter in Spring Live. More functionality may be added in the future, but the main goal is to provide a better implementation of a bare-bones web app.

Equinox should mostly be used for writing tutorials and rapid prototyping. I don’t recommend using it for starting a full-fledged production application. That’s what AppFuse is for.

How Do I Start Using It?

The best way to get started using AppFuse is to download it and read the QuickStart Guide. AppFuse is a part of the Java Enterprise Community on java.net. Its project homepage is at appfuse.dev.java.net.

If you’re interested in Equinox, you can read the QuickStart Chapter from Spring Live to build a quick and easy application using Struts, Spring, and Hibernate. If you like, you can view a demo of the MyUsers application that this chapter helps you build. Equinox is a sub-project of AppFuse on java.net. Its project homepage is at equinox.dev.java.net.

Resources

Matt Raible is currently authoring Spring Live and is a member of the J2EE 1.5 Expert Group. He blogs about J2EE and his experiences on both jroller.com and raibledesigns.com.