File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes JSF 2.0 Requirements and Specifications Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF 2.0 Requirements and Specifications" Watch "JSF 2.0 Requirements and Specifications" New topic
Author

JSF 2.0 Requirements and Specifications

Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

So, I just ran across this rather disturbing excerpt from the JSF2.0 spec, which I'm sure I'm taking far too literally, but I'd appreciate it if someone told me that I was wrong:

JSF is based on the following Java API specifications:
■ JavaServer Pages™ Specification, version 2.1 (JSP™) http://java.sun.com/products/jsp
■ Java™ Servlet Specification, version 2.5 (Servlet) http://java.sun.com/products/servlet
■ Java™2 Platform, Standard Edition, version 5.0 http://java.sun.com/j2se
■ Java™2 Platform, Enterprise Edition, version 5.0 http://java.sun.com/j2ee
■ JavaBeans™ Specification, version 1.0.1 http://java.sun.com/products/javabeans/docs/spec.html
■ JavaServer Pages™ Standard Tag Library, version 1.2 (JSTL) http://java.sun.com/products/jsp/jstl/
Therefore, a JSF container must support all of the above specifications. This requirement allows faces applications to be
portable across a variety of JSF implementations.


Java™2 Platform, Enterprise Edition, version 5.0...a JSF container must support all of the above specifications

Really? A JSF container must also be a J2EE container? So JSF2.0 won't run on Tomcat, or within a Servlet engine?

I'm reading this far too literally, right?

-Cameron McKenzie



Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

Well, I just downloaded Tomcat6 and deployed the JSF2.0 examples, and they all seemed to work, so it would appear that any suggested requirement of J2EE for JSF 2.0 is a bit of hyperbole.

-Cameron McKenzie
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

I just stumbled on this old thread. Sorry for resurrecting a Zombie thread at CodeRanch.

So, I clearly took the reference to Java EE 5 too literally. When they say 'based on' they're clearly not talking about every part of the API, but really just the web container parts of the specification.

Still, it seems every good book on JSF out there discusses CDI, Contexts and Dependency Injection, and CDI isn't part of the Servlet and JSP specification. I'm guessing that I can't leverage CDI in my JSF applications and deploy to say, Tomcat 7, because Tomcat 7 is simply a web container? Looks like I have more work to do.

-Cameron McKenzie
Ilari Moilanen
Ranch Hand

Joined: Apr 15, 2008
Posts: 198
I agree with everything you say in your last posts. JSF does work in Web containers that do not support J2EE fully. And Tomcat 7 does not support CDI fully (only parts of it) so I would not use CDI with Tomcat (but I do not know what the Tomcat developers plan to do in the future so although not a full J2EE container it may support CDI in future versions.)

EDIT: These are good articles to read about the subject
http://weblogs.java.net/blog/cayhorstmann/archive/2009/12/23/javaxfacesbeanmanagedbean-dead-arrival
http://weblogs.java.net/blog/cayhorstmann/archive/2009/12/29/jsf-20-and-tomcat
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

I do believe there is a project that is working on building a Java EE container on top of Tomcat.

All the books on JSF 2.0 use CDI. This makes it pretty frustrating if you're interested in deploying directly to Tomcat. I wonder if adding in CDI support to Tomcat 7 is as simple as just adding in a JAR or two?

Ooops...I see that your second article by Cay talks about this precisely.

"this may be the time for switching to GlassFish."

That's a pretty sad statement, to suggest to do proper JSF 2.0 develoment that we should abandon Tomcat.
Ilari Moilanen
Ranch Hand

Joined: Apr 15, 2008
Posts: 198
Yeah, I for one will not move to J2EE containers so I just do not use CDI. Cay is obviously a hardcore J2EE container supporter.
But people are free to do as they wish...
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

So, in Cay's article, his complaint is the lack of EL and CDI support in Tomcat 6.

Tomcat 7 supports EL 2.2 out of the box, and to use CDI, you simple get the weld-servlet.jar from seam:

The CDI Reference Implementation from JBoss Seam: weld-servlet.jar



That doesn't seem like an overly restrictive requirement to use Tomcat 7 and JSF 2.0?

Just as a side note, I added the above entry to my faces-config.xml file, and got the following runtime error:

Unable to find BeanManager for org.apache.catalina.core.ApplicationContextFacad


Stupid me. The entry is supposed to go in the web.xml file, not the faces-config.xml file. Silly me.

Also, when I tried to use the weld framework without a beans.xml file, I got this error:

java.lang.NullPointerException
org.jboss.weld.context.ForwardingContextual.toString(ForwardingContextual.java:53)


Similarly, without a beans.xml file, I more often than not saw this error too:


Target Unreachable, identifier resolved to null


So, just by putting a blank beans.xml file into the WEB-INF folder seemed to fix it.

By the way, one other problem I had was constantly getting a 404 error message when I ran the program. A few weird things happened. First off, I didn't make my POJO serializable, so make sure your JavaBean implements java.io.Serializable.

I also had a Named and SessionScope class files compiled, created and placed in my classes directory. I have no idea what happened, but I deleted them. After deleting them and implementing java.io.Serializable, things worked. Strange.
Ilari Moilanen
Ranch Hand

Joined: Apr 15, 2008
Posts: 198
That is what he says yes. Altough it does not necessarily mean that it actually works. Or that it should be done (what is for example the performance impact and so on). And of course the article is old so the situation might have changed.

But if you actually test it with real-life application I would like to hear the results you get
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSF 2.0 Requirements and Specifications