开发者社区> 问答> 正文

由以下原因导致:java.lang.IllegalArgumentException:过滤器映射中无

经理个人资质证书,经理个人资质:

Caused by: java.lang.IllegalArgumentException: Invalid [Faces Servlet] in filter mapping at org.apache.catalina.core.StandardContext.validateFilterMap(StandardContext.java:3025) at org.apache.catalina.core.StandardContext.addFilterMap(StandardContext.java:2971) at org.apache.catalina.startup.ContextConfig.configureContext(ContextConfig.java:1289) at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1169) at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:775) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:301) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5051) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ... 27 more

Quantdo defino @WebFilter("Faces Servlet")na Minha class JPAFilter.Troquei por @WebFilter(“。xhtml”),或entityManager cria muitas表示同意。Minha类JPAFilter:

`package br.faraway.nicholas.filters;

import java.io.IOException;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;

/**
 * Servlet Filter implementation class JPAFilter
 */
@WebFilter("Faces Servlet")
public class JPAFilter implements Filter {

    private EntityManagerFactory entityManagerFactory;

    private String persistence_unit_name = "comex-pu";

    public JPAFilter() {

    }

    public void destroy() {

        this.entityManagerFactory.close();
    }

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException {

        EntityManager entityManager = this.entityManagerFactory.createEntityManager();


        request.setAttribute("entityManager", entityManager);


        entityManager.getTransaction().begin();


        chain.doFilter(request, response);

        try {


            entityManager.getTransaction().commit();

        } catch (Exception e) {


            entityManager.getTransaction().rollback();
        } finally {
            System.out.println("Finalyu");

            entityManager.close();
        }
    }

    public void init(FilterConfig fConfig) throws ServletException {

        this.entityManagerFactory = Persistence.createEntityManagerFactory(this.persistence_unit_name);
    }

MEU web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0">
    <welcome-file-list>
        <welcome-file>pages/secured/redireciona.html</welcome-file>
    </welcome-file-list>
    <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>Development</param-value>
    </context-param>
    <context-param>
        <param-name>primefaces.THEME</param-name>
        <param-value>california-#{guestPreferences.theme}</param-value>
    </context-param>
    <context-param>
        <param-name>primefaces.FONT_AWESOME</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
        <param-value>/WEB-INF/primefaces-california.taglib.xml</param-value>
    </context-param>
    <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>*.xhtml</url-pattern>
    </servlet-mapping>
    <mime-mapping>
        <extension>ttf</extension>
        <mime-type>application/font-sfnt</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>woff</extension>
        <mime-type>application/font-woff</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>woff2</extension>
        <mime-type>application/font-woff2</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>eot</extension>
        <mime-type>application/vnd.ms-fontobject</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>eot?#iefix</extension>
        <mime-type>application/vnd.ms-fontobject</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>svg</extension>
        <mime-type>image/svg+xml</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>svg#exosemibold</extension>
        <mime-type>image/svg+xml</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>svg#exobolditalic</extension>
        <mime-type>image/svg+xml</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>svg#exomedium</extension>
        <mime-type>image/svg+xml</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>svg#exoregular</extension>
        <mime-type>image/svg+xml</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>svg#fontawesomeregular</extension>
        <mime-type>image/svg+xml</mime-type>
    </mime-mapping>
    <filter>
        <filter-name>PageFilter</filter-name>
        <filter-class>br.faraway.nicholas.filters.PageFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>PageFilter</filter-name>
        <url-pattern>/pages/secured/restricted/*</url-pattern>
    </filter-mapping>
    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>
    <listener>
        <listener-class>br.faraway.nicholas.filters.SessionListner</listener-class>
    </listener>
    <context-param>
        <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
        <param-value>true</param-value>
    </context-param>

</web-app>

展开
收起
垚tutu 2019-12-19 16:50:41 1044 0
1 条回答
写回答
取消 提交回答
  • 技术架构师 阿里云开发者社区技术专家博主 CSDN签约专栏技术博主 掘金签约技术博主 云安全联盟专家 众多开源代码库Commiter

    仔细检查下格式,Caused by: java.lang.IllegalArgumentException: Invalid [Faces Servlet] in filter mapping at

    2019-12-28 14:27:59
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
Spring Cloud Alibaba - 重新定义 Java Cloud-Native 立即下载
The Reactive Cloud Native Arch 立即下载
JAVA开发手册1.5.0 立即下载