• 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

JSF runtime error

 
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 27491
195
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 27491
195
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think you should be including the JSTL jar.
 
Ranch Hand
Posts: 99
MyEclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 27491
195
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I'm gonna teach you a lesson! Start by looking at this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic