October 02, 2005 15:18
Programming, Java
(Logs from the last couple of days.)

Read through the Hibernate manual and get some simple container working. It doesn't have the functionality of ATG repositories, but it does all the basic stuff, like item descriptor inheritance and an abstract query language. The advanced stuff (derivations, cache groups, distributed locked caching, cascade updates, etc) is outside its purview, but it's sensible, well-behaved, and it doesn't suck. (I realize I sound like a zealot regarding ATG. So be it.)

Installed Spring. Got it working with Hibernate. The IoC framework is roughly Nucleus without layers or scoping. The page flow component (aka Spring MVC) is not so hot, judging from the tutorial. The controller will provide a model that you can access through JSP, with the ModelAndView class calling the actual JSP page and providing a model. So a class has to be written for every page, providing a model to it, and registered with the framework? It's MVC, but I don't see the added value here. Decide to look at something else.

It's very hard to get an overview of all the different frameworks... either they're one line "Oh yeah, this is a framework like this other framework" or they go for the full-on Prevayler slobber.

Look at WebWork, a page flow framework. Just from initial reading, it doesn't seem crazy and it has good reviews. But hang on. For a framework designed for the JSP template engine, it's a bit strange to be using Velocity behind the scenes. How many template languages should you need to know to put a website together? And what's with xWork?

Look at SiteMesh. It's a page flow framework for decorating output. After the response is sent to the OutputStream, SiteMesh then manipulates that output using a series of postprocessors. I don't see how it can do this without some unpleasant implications: either it caches the response for every request (big memory overhead there) or it writes to a commited OutputStream (which, IIRC, causes IllegalStateException in J2EE apps). Thanks, I'll pass.

Look at JSF. Rave reviews, if your last name is Hightower. Everyone else seems to hate it. According to Matt Raible it does a POST for every request. He can't be serious. Who would release a framework like that?

Struts may be the least of all evils. From reading the blogs, it seems like no-one really likes it. But everyone agrees that it's servicable. But I think I'll be ambitious and try WebWork.

Ah. AppFuse. Presumably because it fuses all these applications together. Except that it's set up to use MySQL and Tomcat by default. I'd actually prefer it to be broken by default and have modules that I can just plug into it. It never makes me feel comfortable when I have to strip out application servers in the code base. They should be factored out into a different file (deploy-tomcat.xml, deploy-orion.xml, etc.) and then have the tasks imported into build.xml. At least PostgreSQL settings exist (although commented out).

ant install-webwork
ant package-web

Huh. Where's the EAR file? Oh. No application.xml file. It just makes the WAR. That's wierd. Time to copy over some code.

ant deploy
java -jar orion.jar

Well, Spring doesn't like that very much. Lots of complaining about missing beans. Time to hunt for the web.xml file... which is split into several different pieces and merged together with xDoclet. Isn't that cute. I suppose this is because having a single file is too complicated.

Edit web-settings.xml

What is classpath*? Okay. Whatever it is, Orion doesn't support it. Time to pull all the XML files together. Nope, still doesn't work. Okay, AppFuse generates Spring and Hibernate XML files dynamically using xDoclet. How very... clever. Grrr.

Okay, now it's complaining about missing tables. That's a good sign. Create database, create tables... Oh. Okay. We need some user data to put in the tables... which is in an XML format and run through Ant.

ant setup-db

Read through some more documentation. Equinox is a "simpler AppFuse." The documentation couldn't have mentioned this straight out?

Still populating drop-downs and then nothing. Look at the source code. Ah. The StartupListener in AppFuse doesn't catch exceptions, so it's just headed off into the void (Why doesn't Orion have a logging method for exceptions that bubble all the way up to the top of the stack?). Putting a try / catch / log block around it shows that I'm missing the "lookupManager" bean.

Now it says "No class def: ListenerDescriptor." Google shows this as an Orion problem. Fixed by Orion 2.0.6, the experimental version. Great.

Okay, now I get a recursive error page. Somewhere in FilterToBeanProxy. What's up here? Ah. This is actually an Orion problem again. When I installed Orion 2.0.6, I didn't install the tools.jar file from the JDK. You'd think it would have a better way of telling me it can't do page compilation.

Now I get a "Yikes!" page with no info. There's nothing in the logs. I turn everything in log4j.properties up to DEBUG, and run through it. Nothing. It could be another code piece without a try / catch block, but I have no way of knowing where.

yikes

Time to use a debugger and step through it. Set up Eclipse with libraries. Ah, here's something in the logs. Except that it just tells me I need more dependent libraries for runtime. My environment is swimming in small libraries that do almost exactly the same thing. (Side rant: I have yet to see anyone give a valid reason for using dom4j. Oh, you don't like the API? Write utility methods in your own code and suck it up. Don't pass it off to me, I have enough problems with the classpath as it is.)

Orion libraries are obfuscated and without debug information. And I can't get Eclipse to breakpoint on a thrown Java exception. This just isn't working.

I wish I could take Tomcat seriously. I'd go back to Jetty, but it doesn't even support JNDI. But... I know enough about how AppFuse works now to migrate small pieces in my own project. It won't be nearly as fancy, but I understand how it should work now, and I'll know why something doesn't work, because it will have worked before. So that's what I'll do.

« AppFuse Log 2 | Home | Fried BIOS »

I agree with most of your gripes about AppFuse - especially web.xml and Tomcat hard-coded. I'm working on them and will hopefully simplify and make things better in the next release. Thanks for the detailed post with all your issues - I'll definitely keep it around as a good reference of problems to solve.

>So a class has to be written for every page, providing a model to it, and registered with the framework?

No, a class does not have to be written for every page.

Spring MVC ships a number of out of the box controller implementations that handle predefined workflows that span pages: these include simple forms, and wizards. See the class hierarchy for the "Controller " interface for details.

In these cases, one class handles all the workflow, and that workflow typically spans multiple pages.

In addition, you may use the MultiActionController to centralize your own controller logic within one class (via individual handler methods).

Finally, Spring MVC integrates well with Spring Web Flow (SWF), which is an extremely powerful controller framework that allows full declarative control over the definition and modeling of a page flow.

You'll find SWF a true, full-blown page flow framework that goes beyond the simple controller dispatch & predefined workflows Spring MVC and WebWork address.

I hope this helps.

I'm using WebWork and SiteMesh for datafaber.com (and I used them also for a number of projects at my former company). I haven't looked at the code for SiteMesh, but as far as I know it wraps the HttpServletResponse in PageFilter: the overhead it may introduce is minimal, and well worth the benefits. Only thing I found difficult is debugging, when something goes wrong in a decorator or in one of the filters it can be hard sometimes to understand what is doing.

I like WebWork too, even if the 2.x versions are still a bit of a moving target to me... I use the ww:action tag as a sort of dsp:droplet replacement with great success (behind the actions I handle data retrieval with Ibatis). One thing I don't like much in WebWork is the attention given to some "en vogue" things like AJAX support and the lack of something fairly basic (but please correct if I'm wrong) as post-redirect-get support. WebWork handles double-posts with a token tag in the HTML form, but I had to write a sizeable amount of code to get something akin to ATG's form handling capabilities (redirecting to successURL or errorURL after a post, keeping error messages between action invocations, etc.).

Still, I don't regret my choice: I think Ibatis+WebWork+SiteMesh is a very good combination of open source libraries for Java webapp development.

Great post! I'm just surprised you kept on going, I would have given up and looked for a carrer in the church.

hey,

how can u configure appfuse to enable hot deploy in eclipse? i mean just editing a jsp and seeing the change instantly when refreshing as apposed to using ant for a quick jsp redployment????

thanks

name
url