title: error: package javax.servlet does not exist
body: <p>I was trying to implement a login filter in my web app with jsf 2, following this guide:</p>
  
  <p><a href="https://stackoverflow.com/tags/servlet-filters/info">https://stackoverflow.com/tags/servlet-filters/info</a></p>
  
  <p>after I compiled my filter and added the .class in "web-inf/classes" (as the guide says) the filter worked, but i put the  wrong url to redirect to the login page so i deleted the filter.class from the folder (web-inf/classes) and tried to compile the project again , but it failed, and since then im getting "package javax.servlet does not exist"</p>
  
  <p>it is weird because before it was working and i have javax.servlet in my pom.xml.. i tried cleaning the project, but nothing.</p>
  
  <p>this is my filter class:</p>
  
  <pre><code>package Bean;
  
  import java.io.IOException;
  
  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;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import javax.servlet.http.HttpSession;
  
  /**
   * Created with IntelliJ IDEA.
   * User: rodrigo
   * Date: 28-04-13
   * Time: 06:54 AM
   * To change this template use File | Settings | File Templates.
   */
  @WebFilter("/Contenido/*")
  public class filtro implements Filter {
  
      @Override
      public void init(FilterConfig config) throws ServletException {
          // If you have any &lt;init-param&gt; in web.xml, then you could get them
          // here by config.getInitParameter("name") and assign it as field.
      }
  
      @Override
      public void doFilter(ServletRequest request, ServletResponse response,
              FilterChain chain) throws ServletException, IOException {
          HttpServletRequest req = (HttpServletRequest) request;
          LoginBean user = (LoginBean) req.getSession().getAttribute("user");
  
          if (user != null &amp;&amp; user.isLoggedIn()) {
              // User is logged in, so just continue request.
              chain.doFilter(request, response);
          } else {
              // User is not logged in, so redirect to index.
              HttpServletResponse res = (HttpServletResponse) response;
              res.sendRedirect(req.getContextPath() + "/Contenido/Login.xhtml");
          }
      }
  
      @Override
      public void destroy() {
          // If you have assigned any expensive resources as field of
          // this Filter class, then you could clean/close them here.
      }
  }
  </code></pre>
  
  <p>this is the error:</p>
  
  <pre><code>\Users\rodrigo\IdeaProjects\Frutemu\src\main\java\Bean\filtro.java:[5,20] error: package javax.servlet does not exist
  [ERROR] \Users\rodrigo\IdeaProjects\Frutemu\src\main\java\Bean\filtro.java:[6,20] error: package javax.servlet does not exist
  [ERROR] \Users\rodrigo\IdeaProjects\Frutemu\src\main\java\Bean\filtro.java:[7,20] error: package javax.servlet does not exist
  [ERROR] \Users\rodrigo\IdeaProjects\Frutemu\src\main\java\Bean\filtro.java:[8,20] error: package javax.servlet does not exist
  [ERROR] \Users\rodrigo\IdeaProjects\Frutemu\src\main\java\Bean\filtro.java:[9,20] error: package javax.servlet does not exist
  [ERROR] \Users\rodrigo\IdeaProjects\Frutemu\src\main\java\Bean\filtro.java:[10,20] error: package javax.servlet does not exist
  [ERROR] \Users\rodrigo\IdeaProjects\Frutemu\src\main\java\Bean\filtro.java:[11,31] error: package javax.servlet.annotation does not exist
  </code></pre>
  
  <p>my pom.xml:</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;Frutemu&lt;/groupId&gt;
      &lt;artifactId&gt;Frutemu&lt;/artifactId&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;Frutemu Maven Webapp&lt;/name&gt;
      &lt;url&gt;http://maven.apache.org&lt;/url&gt;
      &lt;repositories&gt;
          &lt;repository&gt;
              &lt;id&gt;prime-repo&lt;/id&gt;
              &lt;name&gt;Prime Repo&lt;/name&gt;
              &lt;url&gt;http://repository.primefaces.org&lt;/url&gt;
          &lt;/repository&gt;
      &lt;/repositories&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;3.8.1&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.ejb&lt;/groupId&gt;
              &lt;artifactId&gt;ejb-api&lt;/artifactId&gt;
              &lt;version&gt;3.0&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.primefaces&lt;/groupId&gt;
              &lt;artifactId&gt;primefaces&lt;/artifactId&gt;
              &lt;version&gt;3.5&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.primefaces.themes&lt;/groupId&gt;
              &lt;artifactId&gt;all-themes&lt;/artifactId&gt;
              &lt;version&gt;1.0.9&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.faces&lt;/groupId&gt;
              &lt;artifactId&gt;jsf-api&lt;/artifactId&gt;
              &lt;version&gt;2.0&lt;/version&gt;
              &lt;scope&gt;compile&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.faces&lt;/groupId&gt;
              &lt;artifactId&gt;jsf-impl&lt;/artifactId&gt;
              &lt;version&gt;2.0.2-b10&lt;/version&gt;
              &lt;scope&gt;compile&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;jstl&lt;/artifactId&gt;
              &lt;version&gt;1.2&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- MySQL database driver --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;5.1.21&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.web&lt;/groupId&gt;
              &lt;artifactId&gt;el-impl&lt;/artifactId&gt;
              &lt;version&gt;2.2.1-b04&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;!-- OpenJPA framework --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.openjpa&lt;/groupId&gt;
              &lt;artifactId&gt;openjpa-all&lt;/artifactId&gt;
              &lt;version&gt;2.2.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.microsoft.sqlserver&lt;/groupId&gt;
              &lt;artifactId&gt;sqljdbc4&lt;/artifactId&gt;
              &lt;version&gt;4.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;net.sf.jasperreports&lt;/groupId&gt;
              &lt;artifactId&gt;jasperreports&lt;/artifactId&gt;
              &lt;version&gt;4.1.2&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
      &lt;build&gt;
          &lt;finalName&gt;Frutemu&lt;/finalName&gt;
          &lt;plugins&gt;
              &lt;!-- Open Jpa --&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.openjpa&lt;/groupId&gt;
                  &lt;artifactId&gt;openjpa-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.2.0&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;includes&gt;**/model/*.class&lt;/includes&gt;
                      &lt;addDefaultConstructor&gt;true&lt;/addDefaultConstructor&gt;
                      &lt;enforcePropertyRestrictions&gt;true&lt;/enforcePropertyRestrictions&gt;
                  &lt;/configuration&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;enhancer&lt;/id&gt;
                          &lt;phase&gt;process-classes&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;enhance&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
              &lt;!-- Plugin para levantar una instancia de Tomcat 7 liviana, única para este proyecto --&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.tomcat.maven&lt;/groupId&gt;
                  &lt;artifactId&gt;tomcat7-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.0&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;url&gt;http://127.0.0.1:8080/manager/text&lt;/url&gt;
                      &lt;server&gt;TomcatServer&lt;/server&gt;
                      &lt;path&gt;/Frutemu&lt;/path&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                  &lt;artifactId&gt;jasperreports-maven-plugin&lt;/artifactId&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;compile-reports&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
                  &lt;dependencies&gt;
                      &lt;!--note this must be repeated here to pick up correct xml validation --&gt;
                      &lt;dependency&gt;
                          &lt;groupId&gt;net.sf.jasperreports&lt;/groupId&gt;
                          &lt;artifactId&gt;jasperreports&lt;/artifactId&gt;
                          &lt;version&gt;4.1.2&lt;/version&gt;
                      &lt;/dependency&gt;
                  &lt;/dependencies&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>