Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Primefaces在使用Maven Tomcat7插件时出错_Maven_Jsf 2_Primefaces_Tomcat7 - Fatal编程技术网

Primefaces在使用Maven Tomcat7插件时出错

Primefaces在使用Maven Tomcat7插件时出错,maven,jsf-2,primefaces,tomcat7,Maven,Jsf 2,Primefaces,Tomcat7,我正在使用maven tomcat7:run部署一个简单的Primefaces 4 Web应用程序。webapp包含1个表单。可以显示该表单,而不会出现任何错误。当我提交表格时,我收到以下错误: Feb 19, 2014 11:52:01 PM com.sun.faces.lifecycle.ProcessValidationsPhase execute WARNING: /registrationWithVal.xhtml @23,117 value="#{userController.reg

我正在使用
maven tomcat7:run
部署一个简单的Primefaces 4 Web应用程序。webapp包含1个表单。可以显示该表单,而不会出现任何错误。当我提交表格时,我收到以下错误:

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)
但是代码在独立的Tomcat7服务器上运行得很好<代码>我想,maven tomcat7插件有一个问题。从maven tomcat7收到这个错误的原因应该是什么。以下是守则摘要:

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>
<?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>
<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>

不久前我遇到了这个问题:


对我来说,使用
mvntomat7:runwar
而不是
mvntomcat7:run
是有效的。但我仍然不知道这是一个bug还是插件的一个特性…

这对我来说很有效。当运行tomcat7:runwar时,所有托管bean的信息都会列在tomcat日志中,而仅使用tomcat7:run时不会发生这种情况
@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";   
    }
}