@FacesConverter注释不能与tomcat7-maven-plugin一起使用

时间:2015-12-15 10:53:55

标签: maven jsf tomcat tomcat7-maven-plugin

我有一个打包为WAR文件的应用程序,它在独立的tomcat(7.0.67)中运行得非常好,但是使用mvn tomcat7:run的tomcat7-maven-plugin无法正常运行。

问题在于定义了自定义转换器,例如:

import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

@FacesConverter( "custom" )
public class CustomConverter implements Converter, Serializable {
  ...
}

似乎没有注册,因为我收到以下错误,并且应用程序无法正确加载:

Dec 15, 2015 10:27:01 AM com.sun.faces.application.ApplicationImpl createConverter
SEVERE: JSF1006: Cannot instantiate converter of type custom

但是,如果我在 faces-config.xml 中注册相同的转换器,一切正常:

<converter>
    <converter-id>custom</converter-id>
    <converter-class>com.package.CustomConverter</converter-class>
</converter>

所以问题似乎是独立tomcat和tomcat7-maven-plugin中的不同库。但我无法弄清楚到底是什么。如果您有任何建议,请告诉我,谢谢。

来自 pom.xml 和tomcat7-maven-plugin的

依赖关系:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <port>8080</port>
                <path>/</path>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.1.20</version>
    </dependency>
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-impl</artifactId>
        <version>2.1.20</version>
    </dependency>
    <dependency>
        <groupId>javax.el</groupId>
        <artifactId>el-api</artifactId>
        <version>2.2</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.jboss.el</groupId>
        <artifactId>jboss-el</artifactId>
        <version>2.0.1.GA</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.primefaces</groupId>
        <artifactId>primefaces</artifactId>
        <version>3.5</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context-support</artifactId>
    </dependency>
    <dependency>
        <groupId>org.primefaces.extensions</groupId>
        <artifactId>primefaces-extensions</artifactId>
        <version>0.6.3</version>
    </dependency>
</dependencies>
web.xml

子集:

<context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>
</context-param>

<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Production</param-value>       
</context-param>

<context-param>
<param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
    <param-value>true</param-value>
</context-param>

<context-param>
    <param-name>javax.faces.VALIDATE_EMPTY_FIELDS</param-name>
    <param-value>true</param-value>
</context-param>

<context-param>
    <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
    <param-value>true</param-value>
</context-param>

<context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xhtml</param-value>
</context-param>

<context-param>
    <param-name>com.sun.faces.enableMissingResourceLibraryDetection</param-name>
    <param-value>true</param-value>
</context-param>

<context-param>
    <param-name>com.sun.faces.expressionFactory</param-name>
    <param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
</context-param>

0 个答案:

没有答案