javax.faces.el.PropertyNotFoundException
hoetschmann Sep 23, 2005 7:46 AMHi,
I'm trying to rebuild the registration app with Seam. Unfortunately it does not work. The deployment works, also it is displayed, but invoking the registration throws an exception (see below).
Can somebody tell me why that is?
My code is as follows:
The action:
@Stateless
@Scope(EVENT)
@Name("register2")
@Interceptor(SeamInterceptor.class)
public class RegisterAction implements Registrierung {
@In @Valid
private Student student;
@PersistenceContext
private EntityManager em;
@In
private FacesContext facesContext;
@IfInvalid(outcome=Outcome.REDISPLAY)
public String register()
{
List existing = em.createQuery("select username from Student where username=:username")
.setParameter("username", student.getUserName())
.getResultList();
if (existing.size()==0)
{
em.persist(student);
return "success";
}
else
{
facesContext.addMessage(null, new FacesMessage("username already exists"));
return null;
}
}
}
LocalInterface:
import javax.ejb.Local;
@Local
public interface Registrierung {
public String register();
}
@Entity
@Name("student")
@Scope(SESSION)
@Table(name="students")
public class Student implements Serializable{
/**
*
*/
private static final long serialVersionUID =-2866059835575212534L;
public Student(){}
public Student(String name, String username,String passwort){
this.name=name;
this.username=username;
this.passwort=passwort;
}
//private String titel;
@Basic
private String username;
@Basic
private String name;
@Basic
private String passwort;
public String getPasswort() {
return passwort;
}
public void setPasswort(String passwort) {
this.passwort = passwort;
}
public String getName() {
// TODO Auto-generated method stub
return name;
}
public void setName(String name) {
// TODO Auto-generated method stub
this.name=name;
}
@Id @NotNull @Length(min=5, max=15)
public String getUserName() {
return username;
}
public void setUserName(String user) {
this.username = user;
}
}
The jsf:
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<html>
<head>
<title>Studentenregistrierung</title>
</head>
<body>
<f:view>
<h:form>
<table border="0">
<tr>
<td>Username</td>
<td><h:inputText value="#{student.username}"/></td>
</tr>
<tr>
<td>Nachname</td>
<td><h:inputText value="#{student.name}"/></td>
</tr>
<tr>
<td>Passwort</td>
<td><h:inputSecret value="#{student.passwort}"/></td>
</tr>
</table>
<h:messages/>
<h:commandButton type="submit" value="Register" action="#{register2.register}"/>
</h:form>
</f:view>
</body>
</html>
Thrown Exception is:
12:14:37,900 ERROR [ValueBindingImpl] Cannot set value for expression '#{student.passwort}' to a new value of type java.lang.String
javax.faces.el.PropertyNotFoundException: Base is null: student
at org.apache.myfaces.el.ValueBindingImpl.resolveToBaseAndProperty(ValueBindingImpl.java:444)
at org.apache.myfaces.el.ValueBindingImpl.setValue(ValueBindingImpl.java:230)
at javax.faces.component.UIInput.updateModel(UIInput.java:226)
at javax.faces.component.UIInput.processUpdates(UIInput.java:165)
at javax.faces.component.UIForm.processUpdates(UIForm.java:81)
at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:416)
at javax.faces.component.UIViewRoot.processUpdates(UIViewRoot.java:150)
at org.apache.myfaces.lifecycle.LifecycleImpl.updateModelValues(LifecycleImpl.java:238)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:81)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:94)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
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.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:157)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
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.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:595)
...
Thanks for any help!
Dhoetschmann