| Author |
JSF runtime error
|
Edward Chen
Ranch Hand
Joined: Dec 23, 2003
Posts: 758
|
|
I am new to JSF. I am using Eclipse 3.4 + Tomcat 6.
The JSF runtime is mojarra-2.0.1-FCS-binary + JSTL 1.2. ( is it not compatible with Tomcat 6 ?)
I have add JSF lib to JSF library preference. I run a simpe JSF file, it will give me errors, like this.
Then I realize the jars is not in web-inf/lib, then I copy all three jar files into it, it will give me another error , like this
How to work out ? I don't like the JBoss, so please any possible solution be away from JBoss.
Thanks.
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14475
|
|
Core JSF comes in 2 parts: the API jar and the implementation jar. A true JEE (J2EE 1.5) server has the implementation jar built into the server, so only the API jar needs to be in your webapp's WEB-INF/lib directory. However, Tomcat is not a JEE server, only J2EE (1.4), so for Tomcat apps, you also have to include an implementation jar.
JBoss can make this confusing, since it commonly employs Tomcat, so you might think you needed to include the implementation jar in your WAR, but JBoss is a full-stack JEE implementation, so you only need the API jar. Stand-alone Tomcat, however, requires both.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
Edward Chen
Ranch Hand
Joined: Dec 23, 2003
Posts: 758
|
|
Tim Holloway wrote: so for Tomcat apps, you also have to include an implementation jar
Thanks for your detailed explanation. Now I have all these three jars in my eclipse JSF library.
jsf-api.jar
jsf-impl.jar
jstl-1.2.jar
I have missed something else ?
I have followed this tutorial, but it doesn't work for me. http://balusc.blogspot.com/2008/01/jsf-tutorial-with-eclipse-and-tomcat.html
Thanks.
|
 |
Raghavan Muthu
Ranch Hand
Joined: Apr 20, 2006
Posts: 3327
|
|
Well, the title of the post itself says, "runtime error".
As per Tim's guidelines, have you got the jar files included/packed inside your WAR's WEB-INF/lib directory?
|
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14475
|
|
|
I don't think you should be including the JSTL jar.
|
 |
Akaine Harga
Ranch Hand
Joined: Nov 03, 2009
Posts: 68
|
|
Tim Holloway wrote:I don't think you should be including the JSTL jar.
That's true for the case when JSTL isn't used in the project.
|
Wanna install linux on a vacuum cleaner. Could anyone tell me which distro sucks better?
willCodeForFood("Java,PHP,C#,XML,VBS,XHTML,CSS,JavaScript,SQL"); //always looking for job opportunities in AU/NZ/US/CA/Europe :P
|
 |
Edward Chen
Ranch Hand
Joined: Dec 23, 2003
Posts: 758
|
|
Finally I found this weird and interesting problem.
If I request http://localhost:8080/JSFTest2/test.jsf, it will automatically go to http://localhost:8080/JSFTest2/test.jsp.
I don't know why. I am using Eclipse 3.4 , I did some wrong setting in Eclipse ?
My web.xml is
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14475
|
|
You did exactly right and there's nothing wrong with Eclipse there.
But I think you're making the common mistake of assuming that "http://localhost:8080/JSFTest2/test.jsf" is a file path. It is not. It's a Uniform Resource Locator.
The difference is that a URL is something that looks somewhat like a file path, but is actually just an ID string for a resource. That ID string is passed to the FacesServlet, because it matches (one of) the FaceServlet's URL pattern(s). Specifically, you've directed your webapp server to route URLs ending with ".jsf" to FacesServlet.
FacesServlet decodes the URL. The way they decode it is to remove ".jsf" from the end of the URL string - which has already had things like the protocol and query strings removed from it - and replace the ".jsf" with a ".jsp" and use that as a relative path reference within the WAR to locate your view source (test.jsp). It will then perform the JSF magic against that view source in order to render the actual HTML page that gets sent back to the user's browser.
So everything there is just fine. Are you still getting an exception?
|
 |
Edward Chen
Ranch Hand
Joined: Dec 23, 2003
Posts: 758
|
|
Tim Holloway wrote:So everything there is just fine. Are you still getting an exception?
working, no exception now. Thank you very much.
|
 |
 |
|
|
subject: JSF runtime error
|
|
|