facebook

JSF Login Sample

  1. MyEclipse Archived
  2.  > 
  3. Web Development (HTML, CSS, etc.)
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #235515 Reply

    j.bin
    Member

    Hello,

    While running your sample ( http://www.myeclipseide.com/images/tutorials/JSF/SFLoginDemoTutorial.html)
    on 4M3 (3.9.310) run into a problem:

    Aug 23, 2005 9:44:23 AM org.apache.catalina.core.StandardWrapperValve invoke
    SEVERE: Servlet.service() for servlet jsp threw exception
    java.lang.NullPointerException
    at com.sun.faces.taglib.jsf_core.LoadBundleTag.doStartTag(LoadBundleTag.java:96)
    at org.apache.jsp.userLogin_jsp._jspx_meth_f_loadBundle_0(org.apache.jsp.userLogin_jsp:121)
    at org.apache.jsp.userLogin_jsp._jspService(org.apache.jsp.userLogin_jsp:86)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Unknown Source)

    which can’t explain. Need a pointer. Please, help.

    Many thanks!

    #235525 Reply

    Riyad Kalla
    Member

    Can you please post all the information we request in the [URL=http://www.myeclipseide.com/PNphpBB2+file-viewtopic-t-393.html]Posting Guidelines[/URL] thread at the top of this forum? That will give us some context so that we can determine if this is an installation issue, a configuration problem, or a bug. Thanks.

    Also post the contents of your userLogin.jsp file, your faces-config.xml file and your web.xml file.

    #235539 Reply

    j.bin
    Member

    Here’re details you requested.

    What operating system and version are you running?
    W2K sp 4

    What Eclipse version and build id are you using? (Help > About Eclipse Platform)
    Eclipse Version: 3.1.0
    Build id: I20050627-1435

    – Was Eclipse freshly installed for MyEclipse?
    Yes.

    – Are any other external plugins installed?
    Subversion

    – How many plugins in the <eclipse>/plugins directory are like org.eclipse.pde.*
    4.
    org.eclipse.pde.build_3.1.0
    org.eclipse.pde.doc.user_3.1.0
    org.eclipse.pde.junit.runtime_3.1.0
    org.eclipse.pde.source_3.1.0

    What MyEclipse version are you using? (Help > About Eclipse Platform > Features)
    Version 4.0 Milestone 3 (3.9.310)
    Build ID: 20050808

    What JDK version are you using to run Eclipse? (java -version)
    1.5.0_04

    What JDK version are you using to launch your application server?
    1.5.0_04

    What steps did you take that resulted in the issue?
    localhost:8080/meld/userLogin.jsp

    What application server are you using?
    Tomcat 5.5

    Are there any exceptions in the Eclipse log file? (<workspace>/.metadata/.log)
    !SESSION 2005-08-23 11:55:35.00 ————————————————
    eclipse.buildId=I20050627-1435
    java.version=1.5.0_04
    java.vendor=Sun Microsystems Inc.
    BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
    Command-line arguments: -os win32 -ws win32 -arch x86 -clean

    !ENTRY org.eclipse.update.configurator 2005-08-23 11:55:53.46
    !MESSAGE Could not install bundle ../../Utils/MyEclipse/eclipse/plugins/org.eclipse.xsd_2.1.0/ Bundle “org.eclipse.xsd” version “2.1.0” has already been installed from: update@plugins/org.eclipse.xsd_2.1.0.jar

    Hope that helps.

    Thank you,

    #235547 Reply

    Riyad Kalla
    Member

    You forgot the most important part:

    Also post the contents of your userLogin.jsp file, your faces-config.xml file and your web.xml file.

    please use the code button below to wrap your code

    #235550 Reply

    j.bin
    Member

    They, except for web.xml, are the SAME as on your site. But, if you wish, here they come.

    userLogin.jsp

    
     <%@ page language="java" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
        <title>My JSF 'userLogin.jsp' starting page</title>
    </head>
    <body>
        <f:view>
            <f:loadBundle basename="com.jsfdemo.MessageBundle" var="bundle"/>
           
            <h:form id="loginForm">
                <table>
                    <tbody>
                        <tr>
                            <td><h:outputText value="#{bundle.user_name_label}" /></td>
                            <td>
                                <h:inputText id="userName" value="#{UserBean.userName}" required="true">
                                    <f:validateLength minimum="1" />
                                </h:inputText>
                            </td>
                        </tr>
                        <tr>
                            <td><h:outputText value="#{bundle.user_password_label}" /></td>
                            <td>
                                <h:inputSecret id="password" value="#{UserBean.password}" required="true">
                                    <f:validateLength minimum="3" />
                                </h:inputSecret>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <h:messages style="font-weight: bold; color: #FF0000;" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" colspan="2">
                                <h:commandButton id="submit" action="#{UserBean.loginUser}" value="#{bundle.login_button_label}" />
                            </td>
                        </tr>
                    </tbody>
                </table>
            </h:form>
        </f:view>
    </body>
    </html>
    
    

    faces-config.xml

    
     <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
    <faces-config>
        <navigation-rule>
            <from-view-id>/userLogin.jsp</from-view-id>
            <navigation-case>
                <from-outcome>success</from-outcome>
                <to-view-id>/userLoginSuccess.jsp</to-view-id>
            </navigation-case>
            <navigation-case>
                <from-outcome>failure</from-outcome>
                <to-view-id>/userLogin.jsp</to-view-id>
            </navigation-case>
        </navigation-rule>
        <managed-bean>
            <description>Bean used to handle all User-based operations.</description>
            <managed-bean-name>UserBean</managed-bean-name>
            <managed-bean-class>com.jsfdemo.bean.UserBean</managed-bean-class>
            <managed-bean-scope>session</managed-bean-scope>
        </managed-bean>
    </faces-config>
    

    web.xml

    
     <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
      <context-param>
        <param-name>javax.faces.CONFIG_FILES</param-name>
        <param-value>/WEB-INF/faces-config.xml</param-value>
      </context-param>
      <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>
    
    

    Thank you!

    #235551 Reply

    Riyad Kalla
    Member

    First, comment out this line in your JSP file:

    
    <f:loadBundle basename="com.jsfdemo.MessageBundle" var="bundle"/> 
    

    does the page work without an exception? If so, go to your com.jsfdemo package, do you have any properties file named MessageBundle.properties or MessageBundle_<your language code>.properties? If not, you need to add one.

    #235553 Reply

    j.bin
    Member

    Per your advice commented out loadBundle.
    Received:

    
    SEVERE: Servlet.service() for servlet jsp threw exception
    javax.servlet.jsp.JspException: Cannot find FacesContext
        at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:399)
        at com.sun.faces.taglib.jsf_core.ViewTag.doStartTag(ViewTag.java:105)
        at org.apache.jsp.userLogin_jsp._jspx_meth_f_view_0(org.apache.jsp.userLogin_jsp:113)
        at org.apache.jsp.userLogin_jsp._jspService(org.apache.jsp.userLogin_jsp:88)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
        at java.lang.Thread.run(Unknown Source)
     
    

    Yes, MessageBundle.properties is under \src\com\jsfdemo, as instructed in your tutorial.

    #235554 Reply

    Riyad Kalla
    Member

    You can uncomment the bundle line, the error with FacesContext is more a configuration issue.

    Are you sure this project has JSF capabilities added to it? Please list all the JARs you have in your WEB-INF/lib directory. Something flaky is going on here.

    Also, what version of Tomcat are you deploying this to?

    #235561 Reply

    j.bin
    Member

    Sure. Here’s what I have under lib:

    
     
     Directory of C:\Devel\vector\JSF\meld\WEB-INF\lib
    
    08/22/2005  15:48       <DIR>          .
    08/22/2005  15:48       <DIR>          ..
    08/22/2005  15:48              118,757 commons-beanutils.jar
    08/22/2005  15:48              170,902 commons-collections.jar
    08/22/2005  15:48              109,131 commons-digester.jar
    08/22/2005  15:48               31,638 commons-logging.jar
    08/22/2005  15:48              364,344 jsf-api.jar
    08/22/2005  15:48              695,507 jsf-impl.jar
    08/22/2005  15:48               20,682 jstl.jar
    08/22/2005  15:48              393,259 standard.jar
                   8 File(s)      1,904,220 bytes
    

    It’s deployed on:
    Starting Servlet Engine: Apache Tomcat/5.5.9

    #235562 Reply

    Riyad Kalla
    Member

    Please use File > Export > ZIP and email it to support@genuitec.com ATTN Riyad with a link to this thread so I know why I’m receiving the file.

    #235576 Reply

    Riyad Kalla
    Member

    j.bin, the problem is that you are trying to access your JSP page using the name of the file:
    /userLogin.jsp

    You don’t want to do that, you want to access it using:
    /userLogin.faces

    per your web.xml file you have mapped all .faces URLs to your JSFServlet, so you need to do that in order for JSF to process the request before you get to the JSP. I imported your project and did that and it worked fine.

Viewing 11 posts - 1 through 11 (of 11 total)
Reply To: JSF Login Sample

You must be logged in to post in the forum log in