Reputation: 2287
I am deploying a simple Primefaces 4 webapp using maven tomcat7:run
. The webapp contains 1 form. The form can be displayed without any error. When I submit the form, I am receiving following error:
Feb 19, 2014 11:52:01 PM com.sun.faces.lifecycle.ProcessValidationsPhase execute
WARNING: /registrationWithVal.xhtml @23,117 value="#{userController.registrationUser.userName}": Target Unreachable, identifier 'userController' resolved to null
javax.el.PropertyNotFoundException: /registrationWithVal.xhtml @23,117 value="#{userController.registrationUser.userName}": Target Unreachable, identifier 'userController' resolved to null
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100)
at org.primefaces.util.ComponentUtils.getConverter(ComponentUtils.java:124)
But the code runs just fine on a standalone Tomcat 7 server! I guess, there is an issue about maven tomcat7 plugin.
What should be the reason of this error received from maven tomcat7. Following is a summary of the code:
pom.xml
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>${jsf.version}</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>${jsf.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>${primefaces.version}</version>
</dependency>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<plugin>
</plugins>
</build>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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">
<description>PrimeFaces Beginners Guide : Chapter 01 </description>
<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>*.jsf</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
registrationWithVal.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
template="/templates/masterTemplate.xhtml">
<ui:define name="bodyContent">
<h:form id="registrationForm">
<p:panel header="Registration Form" >
<p:messages />
<h:panelGrid columns="3">
<p:outputLabel value="UserName:*"/>
<p:inputText id="userName" value="#{userController.registrationUser.userName}" required="true" label="UserName" >
<p:ajax event="keyup" update="userNameMsg"/>
</p:inputText>
<p:message id="userNameMsg" for="userName"/>
<p:outputLabel value=""/>
<p:commandButton action="#{userController.doRegister}" value="Register" update="registrationForm"/>
<p:outputLabel value=""/>
</h:panelGrid>
</p:panel>
</h:form>
</ui:define>
</ui:composition>
UserController.java
@ManagedBean
@RequestScoped
public class UserController {
private User registrationUser = new User();
public UserController() {
}
public User getRegistrationUser() {return registrationUser;}
public void setRegistrationUser(User registrationUser) {this.registrationUser = registrationUser;}
public String doRegister() {
String msg = "User Registered Successfully";
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg));
FacesContext.getCurrentInstance().getExternalContext().getFlash().setKeepMessages(true);
return "registrationWithVal.jsf?faces-redirect=true";
}
}
Upvotes: 1
Views: 688
Reputation: 1003
I had this problem some time ago: Target unreachable, Identifier resolved to null with correct names, dependencys, imports .
For me, it worked to use mvn tomat7:run-war
instead of mvn tomcat7:run
. But I still don't know weather this is a bug or a feature of the plugin...
Upvotes: 3