Tuesday, February 12, 2008

Begin Again

So, I'm starting a new project. 

It never ceases to amaze me how difficult java web applications are to setup.  A lot of it is because of all the different frameworks we get to choose from.  This project appears to be going to use Ice Faces (a JSF implementation/extension), Facelets some level of Spring Integration, possibly JPA or Hibernate.

I played around with RichFaces and facelets a few months ago and was able to lean on the JBoss IDE for some of the configuration, but since I'm using Ice Faces this time I don't want all of the extra stuff that comes with the JBoss IDE.

So we get to start from scratch.  The documentation is pretty decent on what needs to be added to the web.xml and faces-config.xml to get facelets working correctly.  But after that where do you start?  I guess the best place is always the beginning so let's code up the index.html page (always a good place to start).

As you know for faces to work you need to be working w/in a faces context so this is a really good places to initialize the faces context let's make a silly little index.jsp page that simply forwards us inside the context:


<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<title>My Title</title>
<jsp:forward page="pages/login.jsf" />


So, that's easy enough.  But, with Facelets we don't want to really be writing jsf or jsp pages.  Clearly we are forwarding to a jsf page though what gives?  We create a url-pattern mapped to a Faces Servlet so any request to our url pattern (*.jsf) get's routed through the faces context.  One last thing we need to make sure our faces.DefaultSuffix is linked to *.xhtml pages.  So our pages/login.jsf page will land on the pages/login.xhtml page.   Remember with JSF it is all about the faces context stay in the context and you will be ok. This is why (IMHO) if you're doing AJAX you really need to use a framework like RichFaces or IceFaces.  You're just asking for death by a million cuts to go any other route.

So I got all my xhtml files created the web.xml and faces-config.xml are all tweaked out and guess what the dang thing didn't work.  I kept getting this error:


at com.sun.faces.config.ConfigureListener$InitFacesContext.getViewRoot(ConfigureListener.java:1690)
at com.sun.faces.util.MessageFactory.getMessage(MessageFactory.java:113)
at com.sun.faces.util.MessageUtils.getExceptionMessageString(MessageUtils.java:277)
at com.sun.faces.util.Util.createInstance(Util.java:477)
at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:671)
at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:503)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:402)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4493)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5150)
at com.sun.enterprise.web.WebModule.start(WebModule.java:308)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:960)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:944)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:671)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1575)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1216)
at com.sun.enterprise.server.WebModuleDeployEventListener.moduleDeployed(WebModuleDeployEventListener.java:169)
at com.sun.enterprise.server.WebModuleDeployEventListener.moduleDeployed(WebModuleDeployEventListener.java:265)
at com.sun.enterprise.admin.event.AdminEventMulticaster.invokeModuleDeployEventListener(AdminEventMulticaster.java:951)
at com.sun.enterprise.admin.event.AdminEventMulticaster.handleModuleDeployEvent(AdminEventMulticaster.java:938)
at com.sun.enterprise.admin.event.AdminEventMulticaster.processEvent(AdminEventMulticaster.java:448)
at com.sun.enterprise.admin.event.AdminEventMulticaster.multicastEvent(AdminEventMulticaster.java:160)

This seems to be a pretty nasty error, all it is really saying is "Hey I somebody is referencing a class I don't know anything about".  This is probably java's biggest criticism happening right here on my laptop.  I think there are a total of 16 jars I needed to get my very simple page to work here.  Don't get me wrong I'm most thankful to the people who wrote them.  But man it is sure a pain to be trying to figure out what you need and what you don't.

I actually opted for the shotgun approach.  I ended up taking a demo app that comes with Ice Faces and pull out all of the jars from the demo and add them to my project.  Not very accurate but it did fix the problem.

That's enough for tonight.  I'll let you know how it goes.

By the way I got the ice faces demo apps running here:




Deryk said...

Hey, Aaron.

Thanks for trying out ICEfaces and thanks for posting. Hopefully the demo apps you put up will take some of the load off of our servers ;-)

I'll keep an eye on future posts and chime in if I can be of use.

Scott said...

Hey Aaron just saw your post. Funny, I actually built out a PC a few weeks back. Turned out pretty nice and cheap, here is what I used:

Antec Sonata III Case - $100
Got a good deal on this at Micro Center. There are cheaper cases out there, but I liked this one a lot.

Gigabyte S-Series Motherboard - $69

AMD Athlon 64 X2 4400+ - $70

($35 with rebate)

I had the other parts, CD, hard drive laying around.

Now what is with Mr. IT guy not doing backups on his own server? :>



(Started a blog, but have not done much with it so far: http://scootnblog.blogspot.com/)