This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JSF and the fly likes Simple JSF example doesn't render Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Simple JSF example doesn Watch "Simple JSF example doesn New topic
Author

Simple JSF example doesn't render

Russell Bateman
Ranch Hand

Joined: Feb 26, 2008
Posts: 69
I've got a project that uses exactly the following JARs
commons-beanutils-1.8.3.jar
commons-codec-1.4.jar
commons-collections-3.2.1.jar
commons-digester-2.1.jar
commons-discovery-0.4.jar
commons-logging-1.1.1.jar
jstl-1.2.jar
myfaces-api-1.2.8.jar
myfaces-impl-1.2.8.jar

I have a page, src/main/webapp/pages/inputname.jsp:
(and I have a src/main/webapp/pages/inputname.jsf containing:

src/main/java/jsf/example/messages.properties:

My src/main/webapp/WEB-INF/web.xml is:
And src/main/webapp/WEB-INF/faces-config.xml is

The bean is on the path src/main/java/jsf/example/PersonBean.java.

My problem is that the result (http://localhost:8080/one/) appears unrendered thus in the browser:

#{msg.prompt}   #{person.personName}   #{msg.button_text}

where #{person.personName} appears in an edit field and ${msg.button_text} in a button just as you'd expect--so, everything working except no rendering of the JSF. Hitting the button goes to a similarly unrendered greeting.jsp page (which I won't show here).

I got myself into this mess because I'm trying to use Maven to create and build my JSF project instead of doing it by what is for me "the usual way" in Eclipse WTP.

Can anyone see a flaw in what I've done? Somehow JSF just isn't getting called? At the risk of being really annoying, let me give the console output from Tomcat 6.0 just in case it's helpful. Incidentally, Attempting the page in the browser doesn't result in anything getting added to the console output below.

Thanks for any clues you can give me.

Feb 7, 2011 11:38:13 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /home/russ/dev/jdk1.6.0_21/jre/lib/amd64/server:/home/russ/dev/jdk1.6.0_21/jre/lib/amd64:/home/russ/dev/jdk1.6.0_21/jre/../lib/amd64:/usr/lib64/xulrunner-addons:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
Feb 7, 2011 11:38:14 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.serverne' did not find a matching property.
Feb 7, 2011 11:38:14 AM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Feb 7, 2011 11:38:14 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 500 ms
Feb 7, 2011 11:38:14 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Feb 7, 2011 11:38:14 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.29
Feb 7, 2011 11:38:14 AM org.apache.catalina.core.StandardContext addApplicationListener
INFO: The listener "org.apache.myfaces.webapp.StartupServletContextListener" is already configured for this context. The duplicate definition has been ignored.
Feb 7, 2011 11:38:14 AM org.apache.myfaces.webapp.StartupServletContextListener dispatchInitializationEvent
INFO: Checking for pluginsrg.apache.myfaces.FACES_INIT_PLUGINS
Feb 7, 2011 11:38:14 AM org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.PRETTY_HTML' found, using default value true
Feb 7, 2011 11:38:14 AM org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.ALLOW_JAVASCRIPT' found, using default value true
Feb 7, 2011 11:38:14 AM org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON' found, using default value false
Feb 7, 2011 11:38:14 AM org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.SAVE_FORM_SUBMIT_LINK_IE' found, using default value false
Feb 7, 2011 11:38:14 AM org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.READONLY_AS_DISABLED_FOR_SELECTS' found, using default value true
Feb 7, 2011 11:38:14 AM org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.RENDER_VIEWSTATE_ID' found, using default value true
Feb 7, 2011 11:38:14 AM org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.STRICT_XHTML_LINKS' found, using default value true
Feb 7, 2011 11:38:14 AM org.apache.myfaces.shared_impl.config.MyfacesConfig getLongInitParameter
INFO: No context init parameter 'org.apache.myfaces.CONFIG_REFRESH_PERIOD' found, using default value 2
Feb 7, 2011 11:38:14 AM org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.VIEWSTATE_JAVASCRIPT' found, using default value false
Feb 7, 2011 11:38:14 AM org.apache.myfaces.shared_impl.config.MyfacesConfig createAndInitializeMyFacesConfig
INFO: Tomahawk jar not available. Autoscrolling, DetectJavascript, AddResourceClass and CheckExtensionsFilter are disabled now.
Feb 7, 2011 11:38:14 AM org.apache.myfaces.shared_impl.config.MyfacesConfig createAndInitializeMyFacesConfig
INFO: Starting up Tomahawk on the MyFaces-JSF-Implementation
Feb 7, 2011 11:38:14 AM org.apache.myfaces.config.FacesConfigurator feedStandardConfig
INFO: Reading standard config META-INF/standard-faces-config.xml
Feb 7, 2011 11:38:14 AM org.apache.myfaces.config.FacesConfigurator feedWebAppConfig
INFO: Reading config /WEB-INF/faces-config.xml
Feb 7, 2011 11:38:14 AM org.apache.myfaces.config.FacesConfigurator startLib
INFO: Starting up MyFaces-package : myfaces-api in version : 1.2.8 from path : file:/home/russ/dev/workspaces/maven-workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/one/WEB-INF/lib/myfaces-api-1.2.8.jar
Feb 7, 2011 11:38:14 AM org.apache.myfaces.config.FacesConfigurator startLib
INFO: Starting up MyFaces-package : myfaces-impl in version : 1.2.8 from path : file:/home/russ/dev/workspaces/maven-workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/one/WEB-INF/lib/myfaces-impl-1.2.8.jar
Feb 7, 2011 11:38:14 AM org.apache.myfaces.config.FacesConfigurator startLib
INFO: MyFaces-package : tomahawk not found.
Feb 7, 2011 11:38:14 AM org.apache.myfaces.config.FacesConfigurator startLib
INFO: MyFaces-package : tomahawk12 not found.
Feb 7, 2011 11:38:14 AM org.apache.myfaces.config.FacesConfigurator startLib
INFO: MyFaces-package : tomahawk-sandbox not found.
Feb 7, 2011 11:38:14 AM org.apache.myfaces.config.FacesConfigurator startLib
INFO: MyFaces-package : tomahawk-sandbox12 not found.
Feb 7, 2011 11:38:14 AM org.apache.myfaces.config.FacesConfigurator startLib
INFO: MyFaces-package : tomahawk-sandbox15 not found.
Feb 7, 2011 11:38:14 AM org.apache.myfaces.config.FacesConfigurator startLib
INFO: MyFaces-package : myfaces-orchestra-core not found.
Feb 7, 2011 11:38:14 AM org.apache.myfaces.config.FacesConfigurator startLib
INFO: MyFaces-package : myfaces-orchestra-core12 not found.
Feb 7, 2011 11:38:14 AM org.apache.myfaces.config.FacesConfigurator startLib
INFO: MyFaces-package : trinidad-api not found.
Feb 7, 2011 11:38:14 AM org.apache.myfaces.config.FacesConfigurator startLib
INFO: MyFaces-package : trinidad-impl not found.
Feb 7, 2011 11:38:14 AM org.apache.myfaces.config.FacesConfigurator startLib
INFO: MyFaces-package : tobago not found.
Feb 7, 2011 11:38:14 AM org.apache.myfaces.config.FacesConfigurator startLib
INFO: MyFaces-package : commons-el not found.
Feb 7, 2011 11:38:14 AM org.apache.myfaces.config.FacesConfigurator startLib
INFO: MyFaces-package : jsp-api not found.
Feb 7, 2011 11:38:14 AM org.apache.myfaces.shared_impl.util.LocaleUtils toLocale
WARNING: Locale name in faces-config.xml null or empty, setting locale to default locale : en_US
Feb 7, 2011 11:38:15 AM org.apache.myfaces.config.FacesConfigurator handleSerialFactory
INFO: Serialization provider : class org.apache.myfaces.shared_impl.util.serial.DefaultSerialFactory
Feb 7, 2011 11:38:15 AM org.apache.myfaces.webapp.AbstractFacesInitializer initFaces
INFO: ServletContext '/home/russ/dev/workspaces/maven-workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/one/' initialized.
Feb 7, 2011 11:38:15 AM org.apache.myfaces.webapp.StartupServletContextListener dispatchInitializationEvent
INFO: Checking for pluginsrg.apache.myfaces.FACES_INIT_PLUGINS
Feb 7, 2011 11:38:15 AM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Feb 7, 2011 11:38:15 AM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Feb 7, 2011 11:38:15 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/21 config=null
Feb 7, 2011 11:38:15 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1001 ms


Cesar Loachamin
Ranch Hand

Joined: Dec 25, 2010
Posts: 90

Hi Russell

First you need to improve your properties file, It should not have white space after and before the equals sign, it looks like:Second, this properties file must be within a package, in your case the package is jsf.example, and this should not be in the resources folder, it must be in your case in src/main/java/jsf/example/messages.properties.

I hope this help you with your problem, If not let me know, sorry by my english.
Regards
Cesar


When a dream is ending because to come true - OCPJP 6,7. OCE JPA EE6. MCTS
Russell Bateman
Ranch Hand

Joined: Feb 26, 2008
Posts: 69
Thanks for responding, Cesar.

I've edited my original post to reflect the changes you suggested and rerun several times. There is no change in the result, however. Is there more information I can provide?

Russ
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16020
    
  20

Actually, I don't think the properties syntax is all that insistent about avoiding spaces before and after the "=", but I'd have to RTFM.

If a JSF page doesn't render the JSF - which among other things means that a browser "View Page Source" show the original JSF tags, that means that you didn't route the request to the JSF servlet. You're either using an incorrect URL or your servlet URL mapping is incorrect, since only if a match can be found between the two will the request be passed to the FacesServlet.

Also, I don't think JSF can use navigation rules to route to a non-JSF JSP.


Customer surveys are for companies who didn't pay proper attention to begin with.
Russell Bateman
Ranch Hand

Joined: Feb 26, 2008
Posts: 69
White space in properties files up to the first non-white character of the value is immaterial and I've always been anal-retentive about the appearance cum readability of my own, however the important thing to me isn't to debate white space, but to get this working.

I've written working JSF web apps, but I've used Eclipse WTP with ant and not Maven, which I must learn for my job. Maven wants to restore the rather annoyingly deep and tedious Java project directory structure that Eclipse has blessedly conflated over the years. But, the advantages of Maven, especially in a large environment as I'm in, are undeniable. I've been going off a number of Maven/JSF tutorials, all wildly unsuccessful in this very way. The closest I've got so far as been nothing or unrendered output in the result.

Which merely points out that I am not yet master of this whole thing, but have been doing my successful JSF work only off the template of a successful JSF tutorial I used way back and I'm somehow unable to move that success into Maven.

So, I was hoping to coax some understanding out of this experience such that I completely grok what you're pointing out here and which is the real problem.

You're saying that:

PersonBean.java
pages/inputname.jsp (with content)
pages/inputname.jsf (basically zero-length--forestalls a 404)
web.xml (as presently constituted)


—and I've played with an index.jsp forwarding to pages/inputname.jsf or pages/inputname.jsp—isn't going to work no matter what?

That's okay; I'm not partial to what I'm doing here, it's just something I got out of a tutorial that purported to show Maven building a JSF webapp. I just thought, no brainer, I'll use what this guy uses.

Actually, I need to move on to Facelet coverage (built by Maven) after slaying this dragon, something I was reserving as a next step in difficulty.

Sheesh. This seems a little too hard still.

At this point, unless you've got some real concrete suggestions (which I would kill for), I guess it's back to the drawing board to create a new example.

Profuse thanks for this and any other comments (including cat-calls if applicable).

Russ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Simple JSF example doesn't render