0

While developing my webapp everything was working fine until when after creating new .xhtml page something went wrong. New page did not render tag`s. Now after trying a restart when I try to deploy my webapp I get the fallowing error "/odczytyEE2.xhtml Not Found in ExternalContext as a Resource".

my login.xhtml

<h:body>        
    <h:form id="loginForm">          
        <p:growl id="msg" showDetail="true" life="3000" />
        <p:panel header="Login" style="width: 360px; margin-left:35%; margin-right:45%; margin-top:15%">

            <h:panelGrid id="loginPanel" columns="2">

                <h:outputText value="Username" />

                <p:inputText id="username" value="#{login.login}" ></p:inputText>

                <p:spacer></p:spacer>

                <p:message for="username" ></p:message>

                <h:outputText value="Password" />

                <p:password id="password" value="#{login.password}"  feedback="false"></p:password>

                <p:spacer></p:spacer>

                <p:message for="password"></p:message>

                <p:spacer></p:spacer>

                <p:commandButton action="#{login.loginProject}" value="Login" update="loginForm" ajax="true"></p:commandButton>

            </h:panelGrid>

        </p:panel>

    </h:form>

</h:body> 

my web.xml

<web-app version="3.0" 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-app_3_0.xsd">
<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</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>
 <context-param>
    <param-name>primefaces.THEME</param-name>
    <param-value>#{login.theme}</param-value>
</context-param>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<session-config>
    <session-timeout>
        30
    </session-timeout>
</session-config>
<welcome-file-list>
    <welcome-file>login.xhtml</welcome-file>
</welcome-file-list>

and my project structure: ![project structure]: (https://i.stack.imgur.com/e4E8o.jpg)

What can be the reason for this error?

I didnt change anyhting at all, just played with servlet-mapping from *.xhtml to *.jsf etc. Just more errors occured, but when i returned it to be *.xhtml the webapp is deploying welcome-file witch sorce code in firefox is like this:

<html xmlns="http://www.w3.org/1999/xhtml"  
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:p="http://primefaces.org/ui">
<h:head>
    <title>login</title>
</h:head>
<h:body>        
    <h:form id="loginForm">          
        <p:growl id="msg" showDetail="true" life="3000" />
        <p:panel header="Login" style="width: 360px; margin-left:35%; margin-right:45%; margin-top:15%">

            <h:panelGrid id="loginPanel" columns="2">

                <h:outputText value="Username" />

                <p:inputText id="username" value="#{login.login}" ></p:inputText>

                <p:spacer></p:spacer>

                <p:message for="username" ></p:message>

                <h:outputText value="Password" />

                <p:password id="password" value="#{login.password}"  feedback="false"></p:password>

                <p:spacer></p:spacer>

                <p:message for="password"></p:message>

                <p:spacer></p:spacer>

                <p:commandButton action="#{login.loginProject}" value="Login" update="loginForm" ajax="true"></p:commandButton>

            </h:panelGrid>

        </p:panel>

    </h:form>

</h:body> 

and in Chrom its html:

<td>Username</td><td><input id="loginForm:username" name="loginForm:username" type="text" class="ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all" /><script id="loginForm:username_s" type="text/javascript">PrimeFaces.cw("InputText","widget_loginForm_username",{id:"loginForm:username",widgetVar:"widget_loginForm_username"});</script></td></tr>

Any way when I try to log in II get this message: ![unable to find matching navigation case]: (https://i.stack.imgur.com/mh0ob.jpg)

my Login.java:

public class Login implements Serializable {

    private static final long serialVersionUID = 1L;
    private String password;    
    private String message;
    private String login;
    private Object id;
    private Object bg_color;
    private Object theme = "cupertino";

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }
    @ManagedProperty("#{userDAO}")
    private UserDAO session;

    public void setSession(UserDAO session)
    {
        this.session=session;
    }
    public String loginProject() 
    {   
        boolean result = session.login(login, password);
        if (result) {
            // get Http Session and store username
            HttpSession session = Util.getSession();
            session.setAttribute("username", login);
            //UserView.init(id);
            setId(session.getAttribute("id"));
            setBg_color(session.getAttribute("bg_color"));
            setTheme(session.getAttribute("theme"));

            return "home";
        } else {

            FacesContext.getCurrentInstance().addMessage(
                    null,
                    new FacesMessage(FacesMessage.SEVERITY_WARN,
                    "Invalid Login!",
                    "Please Try Again!"));

            // invalidate session, and redirect to other pages

            //message = "Invalid Login. Please Try Again!";
            return "login";
        }
    }

    public String logout() {
      HttpSession session = Util.getSession();
      session.invalidate();
      return "login.xhtml";
   }

    public Object getId() {
        return id;
    }

    public void setId(Object id) {
        this.id = id;
    }

    public Object getBg_color() {
        return bg_color;
    }

    public void setBg_color(Object bg_color) {
        this.bg_color = bg_color;
    }

    public Object getTheme() {
        return theme;
    }

    public void setTheme(Object theme) {
        this.theme = theme;
    }
}
ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Viwritis
  • 17
  • 3
  • Search "odczytyEE2" in your whole project? – Salih Erikci Nov 05 '14 at 13:29
  • Yes. Every .xhtml is directly under WebContent folder, and all files as in example "odczytyEE2.xhtml" are still there and were working before adding one more .xhtml file and managedBean for it. Now even after deleting those 2 files i get this error. Does not matter is it login.xhtml or odczytyEE2.xhtml. One more strange thing was that the new added page didnt render primefaces tag's or even any jsf tag's. – Viwritis Nov 05 '14 at 13:50

1 Answers1

0

What's about the header of your login.xhtml? To be rendered primefaces requires to have an <h:head></h:head> element, even if it's empty:

<?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:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui">
<!-- THIS IS IMPORTANT: --->
<h:head></h:head>
<h:body>
    [...]
</h:body>
</html>
ChristophS
  • 598
  • 4
  • 23
  • Have it ` login ` – Viwritis Nov 05 '14 at 14:36
  • do you have a ConfigureListener in your web.xml? `com.sun.faces.config.ConfigureListener` – ChristophS Nov 05 '14 at 15:36
  • But maybe this is not required: http://stackoverflow.com/questions/8716352/the-listener-com-sun-faces-config-configurelistener-is-already-configured-for – ChristophS Nov 05 '14 at 15:41
  • No i have not. Strange think is it did work just fine before adding new .xhtml page and some beans for it. I did not add or delete any lib,jar's etc. It just didnt render tag's so i tryed restarting server and my pc. After that i get this error. – Viwritis Nov 05 '14 at 16:06