Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

To: Gregg Bolinger (Where Does This Snippet Go?)  RSS feed

 
Daniel Gee
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gregg, in the JSFLogin example you gave, there is a code snippet:


It is unclear where the above snippet go.

There are a number of files: login.jsp, greeting.jsp, messages.properties, LoginBean.java, faces-config.xml, web.xml for this JSFLogin application. The best candidate seems to be the LoginBean.java. But, the complete code for LoginBean.java consists of a constructor, and a couple of pairs of get and set methods.

Is it I did not read your example carefully enough?

Thanks in advance.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It goes in the LoginBean.java file. If you look carefully, there is a link that says JavaBean.java complete just above the snippet of code for LoginBean.

I omitted the login() method from the first snippet as to not add too much complexity too early. In hindsight I suppose I could have bee a bit clearer where that method went when I started talking about it.

HTH
 
Daniel Gee
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I have found the complete code for the LoginBean.java.

I ran the example; however, I got the error message shown below:

root cause

java.util.MissingResourceException: Can't find bundle for base name bundle.Messages, locale en_US
java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:804)
java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:773)
java.util.ResourceBundle.getBundle(ResourceBundle.java:661)
com.sun.faces.taglib.jsf_core.LoadBundleTag.doStartTag(LoadBundleTag.java:96)
org.apache.jsp.login_jsp._jspx_meth_f_loadBundle_0(login_jsp.java:113)
org.apache.jsp.login_jsp._jspService(login_jsp.java:78)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.


What should I do to fix the problem?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you put the Message.properties file in WEB-INF/classes/bundle ?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The build script copies the resources folder which contains the properties file into the JSFLogin/classes folder. Then the WAR task packages the JSFLogin/classes folder into the WEB-INF/classes folder.

The script works as is. After the WAR file is created either deploy it exploded or unjar the WAR and look for yourself. The other common mistake is calling the file message.properties or messages.properties instead of Message.properties. Check spelling and punctuation in your JSP's as well.

Everything works as is. I've had a lot of feedback on that very aspect of this tutorial. Let me know if there is anything else I can do.
 
Daniel Gee
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I simply ran the provided ANT build.xml file by right clicking on that file, selecting the "Run" from the menu, and selecting the "Build Ant" (I use the Eclipse 3.0.1). Then, I copied the jsflogin.war file to the $TOMCATHOME/webapps directory, started Tomcat and typed in http://localhost:8080/jsflogin/faces/login.jsp in the browser window address bar.

Thereafter, I got the aforementioned error message. At the same time, a "jsflogin" folder was created under the $TOMCATHOME/webapps directory.

I used the Windows Explorer and saw that the messages.properties file in the $TOMCATHOME/webapps/jsflogin/WEB-INF/classes/bundle directory.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Daniel Gee:
I simply ran the provided ANT build.xml file by right clicking on that file, selecting the "Run" from the menu, and selecting the "Build Ant" (I use the Eclipse 3.0.1). Then, I copied the jsflogin.war file to the $TOMCATHOME/webapps directory, started Tomcat and typed in http://localhost:8080/jsflogin/faces/login.jsp in the browser window address bar.

Thereafter, I got the aforementioned error message. At the same time, a "jsflogin" folder was created under the $TOMCATHOME/webapps directory.

I used the Windows Explorer and saw that the messages.properties file in the $TOMCATHOME/webapps/jsflogin/WEB-INF/classes/bundle directory.


Is is Message.properties or messages.properties? It should be Message.properties. Obviously you could change your JSP to use the other one, but if you used my JSP the properties file must be Message.properties.
 
Daniel Gee
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help.

It ran successfully now. My mistake was that I did not capitalize the "M". But, it is plural "Messages" (I used all your original files.)
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Daniel Gee:
Thanks for your help.

It ran successfully now. My mistake was that I did not capitalize the "M". But, it is plural "Messages" (I used all your original files.)


Glad to hear it.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!