Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

Erro de inicialização do TomCat

Olá,

Segui os passos da aula e editei o web.xml. Tento inicializar o Tomcat, pelo Eclipse, e recebo a mensagem de que falhou ao iniciar. Mensagem do console : Caused by: java.lang.IllegalArgumentException: The servlets named [br.com.alura.gerenciador.servlet.ControladorFilter] and [br.com.alura.gerenciador.servlet.MonitoramentoFilter] are both mapped to the url-pattern [/entrada] which is not permitted

Conteudo web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
  <display-name>gerenciador</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>

  <filter>
      <filter-name>AF</filter-name>
      <filter-class>br.com.alura.gerenciador.servlet.AutorizacaoFilter</filter-class>
  </filter>
  <filter-mapping>
      <filter-name>AF</filter-name>
      <url-pattern>/entrada</url-pattern>
  </filter-mapping>

  <filter>
      <filter-name>MF</filter-name>
      <filter-class>br.com.alura.gerenciador.servlet.MonitoramentoFilter</filter-class>
  </filter>
  <filter-mapping>
      <filter-name>MF</filter-name>
      <url-pattern>/entrada</url-pattern>
  </filter-mapping>

  <filter>
      <filter-name>CF</filter-name>
      <filter-class>br.com.alura.gerenciador.servlet.ControladorFilter</filter-class>
  </filter>
  <filter-mapping>
      <filter-name>CF</filter-name>
      <url-pattern>/entrada</url-pattern>
  </filter-mapping>

</web-app>

Tomcat -> 9.0.39 Eclipse: 2020-09 (4.17.0)

Como posso corrigir o problema e o servidor inicializar normalmente ?

2 respostas
solução!

Olá Carla, tudo bem com você?

Dando uma olhada no seu web.xml, tudo parece estar em ordem. Verifica se ambas as servlets ControladorFilter e MonitoramentoFilter estão com as anotações @WebFilter comentadas. Caso essa anotação ainda esteja presente nas classes, isso significa que o mapeamento está ocorrendo uma vez no web.xml e outra através da anotação @WebFilter e isso faz com que o TomCat apresente esse erro.

Testa aí e depois me avisa se funcionou!

Abraços e bons estudos!!

Era isso.... comentei @WebFilter conforme você indicou e funcionou !