• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSF 2.0 Requirements and Specifications

 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Good night. Drive safely. Here's a tiny ad for the road:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic