Beispiel wirft Fehler. JSF 2.0 / Tomcat / Eclipse

akchill

Mitglied
Hallo zusammen,

ich habe mir das Buch JAVAServer Faces 2.0 gekauft. Dort wurde eine Seite erwähnt wo ich die Beispiele mir anschauen kann, dies habe ich getan. Jetzt wenn ich das erste Beispiel laufen lassen will, zeigt er mir folgenden Fehler an.

Java:
14.09.2010 08:19:39 com.sun.faces.lifecycle.ProcessValidationsPhase execute
WARNUNG: /editCustomer.xhtml @16,72 value="#{customer.firstName}": Target Unreachable, identifier 'customer' resolved to null
javax.el.PropertyNotFoundException: /editCustomer.xhtml @16,72 value="#{customer.firstName}": Target Unreachable, identifier 'customer' resolved to null
	at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:93)
	at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:95)
	at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1008)
	at javax.faces.component.UIInput.validate(UIInput.java:934)
	at javax.faces.component.UIInput.executeValidate(UIInput.java:1189)
	at javax.faces.component.UIInput.processValidators(UIInput.java:691)
	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
	at javax.faces.component.UIForm.processValidators(UIForm.java:243)
	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
	at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1180)
	at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
	at java.lang.Thread.run(Thread.java:619)
14.09.2010 08:19:39 org.apache.catalina.core.StandardWrapperValve invoke
SCHWERWIEGEND: Servlet.service() for servlet Faces Servlet threw exception
javax.el.PropertyNotFoundException: /editCustomer.xhtml @16,72 value="#{customer.firstName}": Target Unreachable, identifier 'customer' resolved to null
	at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:93)
	at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:95)
	at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1008)
	at javax.faces.component.UIInput.validate(UIInput.java:934)
	at javax.faces.component.UIInput.executeValidate(UIInput.java:1189)
	at javax.faces.component.UIInput.processValidators(UIInput.java:691)
	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
	at javax.faces.component.UIForm.processValidators(UIForm.java:243)
	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
	at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1180)
	at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
	at java.lang.Thread.run(Thread.java:619)


Nach langem suchen finde ich den Fehler einfach nicht.

Der Fehler kann eig. nicht ein größerer sein, da dass beispiel ein kleines ist.


Fehler bei dem Klick ausgelöst wird:
Java:
<?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">
<head>
	<title>MyGourmet - Edit Customer</title>
</head>
<body>
    <h1><h:outputText value="MyGourmet"/></h1>
    <h2><h:outputText value="Edit Customer"/></h2>
    <h:form id="form">
        <h:panelGrid id="grid" columns="2">
            <h:outputLabel value="First Name:" for="firstName"/>
            <h:inputText id="firstName" value="#{customer.firstName}"/>
            <h:outputLabel value="Last Name:" for="lastName"/>
            <h:inputText id="lastName" value="#{customer.lastName}"/>
            <h:commandButton id="save" action="#{customer.save}" value="Save"/>
        </h:panelGrid>
    </h:form>
</body>
</html>

Bean Klasse:
Java:
package webtest.WebContent.java.

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/*
 * customer profile
 */
@ManagedBean
@SessionScoped
public class customer {
	private String firstName;
	private String lastName;

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String save() {
		return "/showCustomer.xhtml";
	}

}

web.xml
Java:
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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_2_5.xsd"
		version="2.5">

	<description>JavaServer Faces 2.0 - MyGourmet 1</description>

	<!-- Faces Servlet -->
	<servlet>
		<servlet-name>Faces Servlet</servlet-name>
		<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>

	<!-- Faces Servlet Mapping -->
	<servlet-mapping>
		<servlet-name>Faces Servlet</servlet-name>
		<url-pattern>*.jsf</url-pattern>
	</servlet-mapping>

	<!-- Welcome files -->
	<welcome-file-list>
		<welcome-file>index.html</welcome-file>
	</welcome-file-list>

</web-app>

Java-Config.xml
Java:
<?xml version="1.0"?>
<faces-config 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-facesconfig_2_0.xsd"
		version="2.0">

    <!-- No special configuration needed for MyGourmet 1 -->

</faces-config>

Eventuell liegt es am Package wo die Customer.java datei ist?


packageaufbau.jpg



Danke mit freundlichen Grüßen

AKCHILL!
 
J

JohannisderKaeufer

Gast
Und wie?

Die Klasse customer.java

1. schreibt man aus konvention Groß also Customer.java und public class Customer.
2. gehört diese Klasse nicht in Webcontent - JS (JavaScript) sondern unter Java Resources:src

Ausserdem gehören auch die log4j.properties in den Ordner Java Resources : src
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
A JSF Suche Beispiel für Primefaces Tree als Navigation Web Tier 3
D JSF RichFaces Tree-Beispiel Problem Web Tier 2
L Erstes JSF Beispiel [http-apr-8080-exec-8] Web Tier 10
L JSF Beispiel wird nicht ausgeführt Web Tier 2
A Sicherheitswort programmieren Beispiel Web Tier 2
Spin JSF erstes Beispiel Web Tier 4
H Applet wirft AccessControlException bei File von Servlet Web Tier 3
C Tomcat wirft keine ViewExpiredException Web Tier 8
W RichFaces converter in orderingList wirft exception Web Tier 5
A Fehler in der Deployment-Description Web Tier 1
G Ersetzen von @ManagedBean Annotation durch @named erzeugt Fehler Web Tier 3
M Ajax Fehler zur Laufzeit Web Tier 5
B JSF Internationalisierungs-Fehler auf Remoteserver Web Tier 12
H JSF Fehler bei Zugriff auf f:attribute Web Tier 2
D Fehler: Cookies nicht gesetzt Web Tier 5
B Tomcat 6 ergibt Fehler - java.net.SocketException Web Tier 2
T Fehler - Unable to restore sessions Web Tier 3
A JSF Fehler bei Sonderzeichen? Web Tier 2
Spin JSP Fehler beim casten , why? Web Tier 6
R Exception? Was für ein Fehler? Web Tier 3
R Fehler 1053 beim Beenden von Tomcat Web Tier 25
J Fehler Tomcat/JSP findet Methode nich Web Tier 3
F Fehler beim erstellen des EJB - Moduls! Web Tier 4

Ähnliche Java Themen

Neue Themen


Oben