0

I'm looking to determine which jars I should be looking for and where I should include them to solve this issue - I currently have none in my WEB-INF/lib folder and have been told that WebSphere comes with the functionality for JSF already, however, I return no errors and get just a blank page on rendering (no other resolutions of this nature have been found in my multi-day search - if this is marked as duplicate again, I will delete and just add in jars all over in an attempt to fix :) )

ENVIRONMENT AND EXPERIENCE:

I've just recently come off my first real Development project, and we worked with Websphere 8.5, Oracle DB, and MyEclipse Blue (IBM) - in an attempt to mirror this environment at home, I've added the free dev/trial versions of all 3 tools.

SUCCESSES AND GOAL:

I'm working with a pluralsite tutorial for JEE - I was very overwhelmed throughout the project in regards to configuration, but have made some progress on understanding the basics of JAR/EAR/WAR/Library/.xml config files/etc so I think I can speak accurately about what I'm attempting and should hopefully have a clear disconnect between what I know and what I don't - and hopefully where my issue resides.

In this tutorial, we construct a Data-Access Objects (DAOs), Data-Access Implementations, and a front-end developed with Apache's MyFaces 2.0.

ISSUE:

I am struggling to get the JSFs to work for me, and I think it may be a JAR issue, as that has been my main issue in the past.

WEB.XML

<?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"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    id="WebApp_ID" version="3.0">
    <display-name>ListManagerWeb</display-name>

    <welcome-file-list>
        <welcome-file>faces/login.xhtml</welcome-file>
    </welcome-file-list>

    <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>
        <enabled>true</enabled>
    </servlet>

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>

    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>

    <context-param>
        <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</param-value>
    </context-param>
    <context-param>
        <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
        <param-value>resources.application</param-value>
    </context-param>
    <listener>
        <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
    </listener>

    <context-param>
        <param-name>com.ibm.ws.jsf.LOAD_FACES_CONFIG_AT_STARTUP</param-name>
        <param-value>true</param-value>
    </context-param>

    <resource-ref>
        <res-ref-name>jdbc/OracleDS</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>

</web-app>

Login.xhtml

<!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:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">
    <h:head>

    <title>Login - List Manager</title>

    <meta name="keywords" content="enter,your,keywords,here" />
    <meta name="description" content="A short description of this page." />
    <meta name="content-type" content="text/html; charset=UTF-8" />

    <h:outputStylesheet library="css" name="login.css" />
</h:head>
<h:body>
    <div>
        <h:form styleClass="login-form">
            <div>
                <h:outputText value="Username" />
            </div>
            <div>
                <h:inputText value="#{userBean.username}" />
            </div>
            <div>
                <h:commandButton styleClass="button" value="Login"
                    action="#{loginController.login}" />
            </div>
        </h:form>
    </div>
</h:body>

login.css (all commented out)

/* .login-container {
    position: absolute;
    top: 50%;
    margin-top: -4.5rem;
    left: 0;
    width: 100%;
    padding: 2rem 0 2rem 0;
    background-color: #f5f5f5;
}

.login-container .login-form {
    width: 20rem;
    margin: 0 auto;
    height: 5.5rem;
}

.login-container .login-form div {
    height: 1.5rem;
    width: 20rem;
} */

LoginController (@managed bean)

package com.pluralsight.listmanager.web.controller;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;

import org.pluralsite.listmanager.model.User;
import org.pluralsite.listmanager.service.UserService;
import org.pluralsite.listmanager.service.impl.UserServiceImpl;

import com.pluralsight.listmanager.web.model.UserBean;

@ManagedBean
@RequestScoped
public class LoginController {

        private final UserService userService;

        @ManagedProperty("#{userBean}")
        private UserBean userBean;

        public LoginController() {
            userService = new UserServiceImpl();
        }

        public String login() {
            String outcome = null; //next page

            User user = userService.authenticateUser(userBean.getUsername());
            if (user != null) {
                outcome = "list?faces-redirect=true";
            }

            return outcome;
        }

        public void setUserbean(UserBean userBean) {
            this.userBean = userBean;
        }
    }

Output when I hit the site, after successful deploy and server start, in chrome OR IE

    <!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:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core" data-genuitec="wc2-2-18">
    <h:head>
        <title data-genuitec="wc2-2-20">Login - List Manager</title>

        <meta name="keywords" content="enter,your,keywords,here" data-genuitec="wc2-2-21"/>
        <meta name="description" content="A short description of this page." data-genuitec="wc2-2-22"/>
        <meta name="content-type" content="text/html; charset=UTF-8" data-genuitec="wc2-2-23"/>


        <h:outputStylesheet library="css" name="login.css" />
    </h:head>
    <h:body>

        <div data-genuitec="wc2-2-25">
            <h:form styleClass="login-form">
                <div data-genuitec="wc2-2-27">
                    <h:outputText value="Username" />
                </div>
                <div data-genuitec="wc2-2-28">
                    <h:inputText value="#{userBean.username}" />
                </div>
                <div data-genuitec="wc2-2-29">
                    <h:commandButton styleClass="button" value="Login"
                        action="#{loginController.login}" />
                </div>
            </h:form>
        </div>
    </h:body>
</html>

(EDIT 1) I access my site via the following URL: "http://localhost:9080/ListManagerWeb/"

Results after using the servlet-mapping value of "*.xhtml":

1) if I use http://localhost:9080/ListManagerWeb/ i get "JSPG0036E: Failed to find resource /faces/login.jsp"

2) if I use http://localhost:9080/ListManagerWeb/faces/login.xhtml I get "JSPG0036E: Failed to find resource /faces/login.jsp"

3) if I use http://localhost:9080/ListManagerWeb/login.xhtml I get "JSPG0036E: Failed to find resource /faces/login.jsp"

Results after using the servlet-mapping value of "/faces/*":

1) if I use http://localhost:9080/ListManagerWeb/ I get blank rendering

2) if I use http://localhost:9080/ListManagerWeb/faces/login.xhtml I get blank rendering

3) if I use http://localhost:9080/ListManagerWeb/login.xhtml I get blank rendering

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
user1211530
  • 116
  • 8
  • In reply to duplication: I have seen that post numerous times in the last few days - I believe I'm using the correct namespace, I have the web.xml doing /faces/* which should suffice for this initial attempt, and I am using JSF 2.0 - thanks for trying to help out, but I need more information on what I may be doing wrong or have correct in my code so I don't keep looking at the same posts that haven't really helped me solve this issue, yet – user1211530 Jun 07 '16 at 18:27
  • The answer tells to use URL pattern of `*.xhtml` instead. And, if you have read that post, then you should also have explicitly included the request URL in the question to prove that you're indeed triggering `/faces/*`. But all information about how you're opening the page is missing from the question. – BalusC Jun 08 '16 at 07:10
  • I've added in the information about opening the page (I had done the .xhtml edit before to web.xml, I suppose I should have included that attempt previously, but the results are just "JSPG0036E: Failed to find resource /faces/login.jsp" – user1211530 Jun 08 '16 at 12:31
  • Why didn't you open by http://localhost:9080/ListManagerWeb/login.xhtml as instructed in the answer? – BalusC Jun 08 '16 at 12:33
  • I didn't because I was trying to stick on the tutorial's URL access, however, I've updated my question again: When I use localhost:9080/ListManagerWeb/login.xhtml using the servlet-mapping of ".xhtml" the output is the same JSPG0036E: Failed to find resource /faces/login.jsp When I use localhost:9080/ListManagerWeb/login.xhtml using the servlet-mapping of "/faces/*" the output is the blank rendering – user1211530 Jun 08 '16 at 12:37
  • 1
    Then webapp's runtime classpath is polluted with multiple different versioned JSF libraries. If you're unable to understand how to configure and cleanup JARs/libraries and all, I suggest to throw away that tutorial and instead read the one linked in the bottom of the duplicate's answer. – BalusC Jun 08 '16 at 12:42
  • That's what I'm thinking (insofar as I have understood the versioning), just keep slamming my head against a wall when I read that my appserver should handle this when I created the dynamic web project initially - I had assumed it would include 1 version and the right one at that, thanks for the direction in any case. – user1211530 Jun 08 '16 at 12:46
  • It depends on the target runtime. If it provides JSF, webapp shouldn't do. See thus also our JSF wiki page. – BalusC Jun 08 '16 at 12:46
  • Unfortunately, I'm still kinda fresh to the Java world (literally mainly Javascript/HTML), so handling JARs, dependencies, and muddying up classpaths makes it hard for me to ask the right questions, I have been hitting up everything but 45 minute tutorials on JSF up until this point, but I am trying to track down some actual installation procedures to see which JARs, and where, people are getting/placing them within their WebApp. When you say target runtime, I assume you mean my server (which is WebSphere 8.5), right? – user1211530 Jun 08 '16 at 12:56
  • From myFaces.Apache.org: myfaces-api.jar and myfaces-impl.jar seem to be the JARs I'll leverage (self-note) – user1211530 Jun 08 '16 at 12:56
  • Yes. That's a Java EE server already. You do not need to supply any Java EE libraries along with webapp. Again, see our JSF wiki page for installation instructions. – BalusC Jun 08 '16 at 12:57
  • Final stupid question before hitting the rabbit-hole: StackOverFlow wiki? or..? Not sure what you mean by 'our wiki' – user1211530 Jun 08 '16 at 13:01
  • It's linked in bottom of the answer of the duplicate (sure you did read it from top to bottom?). You can also get there by hovering the tag below the question until a black popbox shows up and then clicking therein *info* link. – BalusC Jun 08 '16 at 13:03
  • Cheers (and I did read it, my brain RAM just isn't that large) – user1211530 Jun 08 '16 at 13:07

0 Answers0