Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF runtime error

 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think you should be including the JSTL jar.
 
Akaine Harga
Ranch Hand
Posts: 99
Java MyEclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:So everything there is just fine. Are you still getting an exception?

working, no exception now. Thank you very much.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic