Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

App doesn't work

 
Sunny Greenhorn
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure why this doesn't work, a basic simple setup thought, trying to have it run on Tomcat6 with JSF 2.0 jars. Any clues please ???

web.xml (under WEB-INF folder)
-------
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
</web-app>

faces-config.xml (under WEB-INF folder)
-----------------
<?xml version="1.0" encoding="UTF-8"?>

<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
version="1.2">

<application>
<locale-config>
<default-locale>en</default-locale>
</locale-config>
<resource-bundle>
<base-name>my.messages</base-name>
<var>msgs</var>
</resource-bundle>
</application>
</faces-config>

index.xhtml (under WebContent folder)
------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>#{msgs.title}</title>
</h:head>
<h:body></h:body>
</html>

messages.properties (under src, my package)
--------------------
title=Hello There!

No deployment errors and no issues with folder structures...
just URL doesn't respond:http://localhost:8080/T2/faces/index.xyz
http://localhost:8080/T2/faces/index.xhtml - gives the XHTML as is dump.

THanks.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Sanath!

There's a "Code" button on the Ranch message editor. You can also use it with XML. It keeps the message formatter from taking liberties with your formatted text.

You need to establish a mapping between "*.xhtml" and JSF in your web.xml file. Something like:


You also probably need to configure Facelets in web.xml as well.

Without that mapping information, the webapp container won't route your URL to the FacesServlet and the FacesServlet won't decode it properly.
 
Sunny Greenhorn
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, still the same issue, when I run it, I just see #{msgs.title} in the source (as-is xhtml) and empty in browser window.
another issue it seems that if we give same .xhtml extension for URL mapping is eating away stack, not sure how, but I have other app (quiz program demo)
that works fine....so scary ! where am I doing wrong (I hope so :-) )
 
Sunny Greenhorn
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Directory structure is here
DIR_STRU.PNG
[Thumbnail for DIR_STRU.PNG]
Directory Structure
 
Sunny Greenhorn
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
response status is as shown...
outputs_scr.PNG
[Thumbnail for outputs_scr.PNG]
 
Sunny Greenhorn
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is quite similar to the QuizProgram demo that comes with mojarra-2.0.4-FCS, not able to figure out where is the issue.
any thoughts anyone!
 
Sunny Greenhorn
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found the thorn atlast ! Issue with faces-config.xml file and the error is in here

where as this is supposed to be


This ofcourse makes huge difference...
if 1.2 is used, resource bundles and beans wont come up and when servlet url mapping and DEFAULT_SUFIX matches, it runs out of stack, like infinite loop.
with 2.0, these are resolved.

Thanks for all, Again, thanks for warm welcome Tim.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic