error: package javax.servlet does not exist
I was trying to implement a login filter in my web app with jsf 2, following this guide:
https://stackoverflow.com/tags/servlet-filters/info
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"
it is weird because before it was working and i have javax.servlet in my pom.xml.. i tried cleaning the project, but nothing.
this is my filter class:
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 <init-param> 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 && 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.
}
}
this is the error:
UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[5,20] error: package javax.servlet does not exist
[ERROR] UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[6,20] error: package javax.servlet does not exist
[ERROR] UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[7,20] error: package javax.servlet does not exist
[ERROR] UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[8,20] error: package javax.servlet does not exist
[ERROR] UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[9,20] error: package javax.servlet does not exist
[ERROR] UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[10,20] error: package javax.servlet does not exist
[ERROR] UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[11,31] error: package javax.servlet.annotation does not exist
my pom.xml:
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>Frutemu</groupId>
<artifactId>Frutemu</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>Frutemu Maven Webapp</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>prime-repo</id>
<name>Prime Repo</name>
<url>http://repository.primefaces.org</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>ejb-api</artifactId>
<version>3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>all-themes</artifactId>
<version>1.0.9</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.0.2-b10</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- MySQL database driver -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.21</version>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>el-impl</artifactId>
<version>2.2.1-b04</version>
<scope>provided</scope>
</dependency>
<!-- OpenJPA framework -->
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-all</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>4.1.2</version>
</dependency>
</dependencies>
<build>
<finalName>Frutemu</finalName>
<plugins>
<!-- Open Jpa -->
<plugin>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<version>2.2.0</version>
<configuration>
<includes>**/model/*.class</includes>
<addDefaultConstructor>true</addDefaultConstructor>
<enforcePropertyRestrictions>true</enforcePropertyRestrictions>
</configuration>
<executions>
<execution>
<id>enhancer</id>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Plugin para levantar una instancia de Tomcat 7 liviana, única para este proyecto -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<url>http://127.0.0.1:8080/manager/text</url>
<server>TomcatServer</server>
<path>/Frutemu</path>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jasperreports-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile-reports</goal>
</goals>
</execution>
</executions>
<dependencies>
<!--note this must be repeated here to pick up correct xml validation -->
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>4.1.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
maven servlet-filters
|
show 2 more comments
I was trying to implement a login filter in my web app with jsf 2, following this guide:
https://stackoverflow.com/tags/servlet-filters/info
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"
it is weird because before it was working and i have javax.servlet in my pom.xml.. i tried cleaning the project, but nothing.
this is my filter class:
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 <init-param> 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 && 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.
}
}
this is the error:
UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[5,20] error: package javax.servlet does not exist
[ERROR] UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[6,20] error: package javax.servlet does not exist
[ERROR] UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[7,20] error: package javax.servlet does not exist
[ERROR] UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[8,20] error: package javax.servlet does not exist
[ERROR] UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[9,20] error: package javax.servlet does not exist
[ERROR] UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[10,20] error: package javax.servlet does not exist
[ERROR] UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[11,31] error: package javax.servlet.annotation does not exist
my pom.xml:
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>Frutemu</groupId>
<artifactId>Frutemu</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>Frutemu Maven Webapp</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>prime-repo</id>
<name>Prime Repo</name>
<url>http://repository.primefaces.org</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>ejb-api</artifactId>
<version>3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>all-themes</artifactId>
<version>1.0.9</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.0.2-b10</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- MySQL database driver -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.21</version>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>el-impl</artifactId>
<version>2.2.1-b04</version>
<scope>provided</scope>
</dependency>
<!-- OpenJPA framework -->
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-all</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>4.1.2</version>
</dependency>
</dependencies>
<build>
<finalName>Frutemu</finalName>
<plugins>
<!-- Open Jpa -->
<plugin>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<version>2.2.0</version>
<configuration>
<includes>**/model/*.class</includes>
<addDefaultConstructor>true</addDefaultConstructor>
<enforcePropertyRestrictions>true</enforcePropertyRestrictions>
</configuration>
<executions>
<execution>
<id>enhancer</id>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Plugin para levantar una instancia de Tomcat 7 liviana, única para este proyecto -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<url>http://127.0.0.1:8080/manager/text</url>
<server>TomcatServer</server>
<path>/Frutemu</path>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jasperreports-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile-reports</goal>
</goals>
</execution>
</executions>
<dependencies>
<!--note this must be repeated here to pick up correct xml validation -->
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>4.1.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
maven servlet-filters
Please use a valid package name like in the example. Write "package com.example;" instead of " package Bean;". Furthermore I suggest with regards to the Java naming conventions to start your class name with a capital letter (Filtro instead of filtro). Do you still get the error message?
– Matthias Herlitzius
Apr 28 '13 at 12:53
the package name is ok, it's is generated automathically in intellij when i create a new class inside of the folder "Bean", all my issues started after i compiled filtro.java and added the generated filtro.class in web-inf/classes, since i did that im getting this error.
– user1462933
Apr 28 '13 at 13:01
Please see this link regarding the package naming conventions: docs.oracle.com/javase/tutorial/java/package/namingpkgs.html
– Matthias Herlitzius
Apr 28 '13 at 13:05
thanks for the link, i know there are conventions about package and class names , but that doesnt explain my problem.. before i did what expalin in my first post everything was ok , so the problem is not related to the package name, i think something got messed up after i copied and deleted the filtro.class into web-inf/classes...
– user1462933
Apr 28 '13 at 13:11
The error appears during the compile phase. Most likely the error is in your pom.xml. I can reproduce the error messages by commenting out the javax.servlet dependency in the pom.xml. If you are not sure about this please post your pom.xml.
– Matthias Herlitzius
Apr 28 '13 at 13:34
|
show 2 more comments
I was trying to implement a login filter in my web app with jsf 2, following this guide:
https://stackoverflow.com/tags/servlet-filters/info
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"
it is weird because before it was working and i have javax.servlet in my pom.xml.. i tried cleaning the project, but nothing.
this is my filter class:
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 <init-param> 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 && 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.
}
}
this is the error:
UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[5,20] error: package javax.servlet does not exist
[ERROR] UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[6,20] error: package javax.servlet does not exist
[ERROR] UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[7,20] error: package javax.servlet does not exist
[ERROR] UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[8,20] error: package javax.servlet does not exist
[ERROR] UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[9,20] error: package javax.servlet does not exist
[ERROR] UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[10,20] error: package javax.servlet does not exist
[ERROR] UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[11,31] error: package javax.servlet.annotation does not exist
my pom.xml:
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>Frutemu</groupId>
<artifactId>Frutemu</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>Frutemu Maven Webapp</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>prime-repo</id>
<name>Prime Repo</name>
<url>http://repository.primefaces.org</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>ejb-api</artifactId>
<version>3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>all-themes</artifactId>
<version>1.0.9</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.0.2-b10</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- MySQL database driver -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.21</version>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>el-impl</artifactId>
<version>2.2.1-b04</version>
<scope>provided</scope>
</dependency>
<!-- OpenJPA framework -->
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-all</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>4.1.2</version>
</dependency>
</dependencies>
<build>
<finalName>Frutemu</finalName>
<plugins>
<!-- Open Jpa -->
<plugin>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<version>2.2.0</version>
<configuration>
<includes>**/model/*.class</includes>
<addDefaultConstructor>true</addDefaultConstructor>
<enforcePropertyRestrictions>true</enforcePropertyRestrictions>
</configuration>
<executions>
<execution>
<id>enhancer</id>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Plugin para levantar una instancia de Tomcat 7 liviana, única para este proyecto -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<url>http://127.0.0.1:8080/manager/text</url>
<server>TomcatServer</server>
<path>/Frutemu</path>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jasperreports-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile-reports</goal>
</goals>
</execution>
</executions>
<dependencies>
<!--note this must be repeated here to pick up correct xml validation -->
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>4.1.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
maven servlet-filters
I was trying to implement a login filter in my web app with jsf 2, following this guide:
https://stackoverflow.com/tags/servlet-filters/info
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"
it is weird because before it was working and i have javax.servlet in my pom.xml.. i tried cleaning the project, but nothing.
this is my filter class:
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 <init-param> 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 && 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.
}
}
this is the error:
UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[5,20] error: package javax.servlet does not exist
[ERROR] UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[6,20] error: package javax.servlet does not exist
[ERROR] UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[7,20] error: package javax.servlet does not exist
[ERROR] UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[8,20] error: package javax.servlet does not exist
[ERROR] UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[9,20] error: package javax.servlet does not exist
[ERROR] UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[10,20] error: package javax.servlet does not exist
[ERROR] UsersrodrigoIdeaProjectsFrutemusrcmainjavaBeanfiltro.java:[11,31] error: package javax.servlet.annotation does not exist
my pom.xml:
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>Frutemu</groupId>
<artifactId>Frutemu</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>Frutemu Maven Webapp</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>prime-repo</id>
<name>Prime Repo</name>
<url>http://repository.primefaces.org</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>ejb-api</artifactId>
<version>3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>all-themes</artifactId>
<version>1.0.9</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.0.2-b10</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- MySQL database driver -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.21</version>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>el-impl</artifactId>
<version>2.2.1-b04</version>
<scope>provided</scope>
</dependency>
<!-- OpenJPA framework -->
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-all</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>4.1.2</version>
</dependency>
</dependencies>
<build>
<finalName>Frutemu</finalName>
<plugins>
<!-- Open Jpa -->
<plugin>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<version>2.2.0</version>
<configuration>
<includes>**/model/*.class</includes>
<addDefaultConstructor>true</addDefaultConstructor>
<enforcePropertyRestrictions>true</enforcePropertyRestrictions>
</configuration>
<executions>
<execution>
<id>enhancer</id>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Plugin para levantar una instancia de Tomcat 7 liviana, única para este proyecto -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<url>http://127.0.0.1:8080/manager/text</url>
<server>TomcatServer</server>
<path>/Frutemu</path>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jasperreports-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile-reports</goal>
</goals>
</execution>
</executions>
<dependencies>
<!--note this must be repeated here to pick up correct xml validation -->
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>4.1.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
maven servlet-filters
maven servlet-filters
edited May 23 '17 at 12:03
Community♦
11
11
asked Apr 28 '13 at 12:38
user1462933user1462933
5892924
5892924
Please use a valid package name like in the example. Write "package com.example;" instead of " package Bean;". Furthermore I suggest with regards to the Java naming conventions to start your class name with a capital letter (Filtro instead of filtro). Do you still get the error message?
– Matthias Herlitzius
Apr 28 '13 at 12:53
the package name is ok, it's is generated automathically in intellij when i create a new class inside of the folder "Bean", all my issues started after i compiled filtro.java and added the generated filtro.class in web-inf/classes, since i did that im getting this error.
– user1462933
Apr 28 '13 at 13:01
Please see this link regarding the package naming conventions: docs.oracle.com/javase/tutorial/java/package/namingpkgs.html
– Matthias Herlitzius
Apr 28 '13 at 13:05
thanks for the link, i know there are conventions about package and class names , but that doesnt explain my problem.. before i did what expalin in my first post everything was ok , so the problem is not related to the package name, i think something got messed up after i copied and deleted the filtro.class into web-inf/classes...
– user1462933
Apr 28 '13 at 13:11
The error appears during the compile phase. Most likely the error is in your pom.xml. I can reproduce the error messages by commenting out the javax.servlet dependency in the pom.xml. If you are not sure about this please post your pom.xml.
– Matthias Herlitzius
Apr 28 '13 at 13:34
|
show 2 more comments
Please use a valid package name like in the example. Write "package com.example;" instead of " package Bean;". Furthermore I suggest with regards to the Java naming conventions to start your class name with a capital letter (Filtro instead of filtro). Do you still get the error message?
– Matthias Herlitzius
Apr 28 '13 at 12:53
the package name is ok, it's is generated automathically in intellij when i create a new class inside of the folder "Bean", all my issues started after i compiled filtro.java and added the generated filtro.class in web-inf/classes, since i did that im getting this error.
– user1462933
Apr 28 '13 at 13:01
Please see this link regarding the package naming conventions: docs.oracle.com/javase/tutorial/java/package/namingpkgs.html
– Matthias Herlitzius
Apr 28 '13 at 13:05
thanks for the link, i know there are conventions about package and class names , but that doesnt explain my problem.. before i did what expalin in my first post everything was ok , so the problem is not related to the package name, i think something got messed up after i copied and deleted the filtro.class into web-inf/classes...
– user1462933
Apr 28 '13 at 13:11
The error appears during the compile phase. Most likely the error is in your pom.xml. I can reproduce the error messages by commenting out the javax.servlet dependency in the pom.xml. If you are not sure about this please post your pom.xml.
– Matthias Herlitzius
Apr 28 '13 at 13:34
Please use a valid package name like in the example. Write "package com.example;" instead of " package Bean;". Furthermore I suggest with regards to the Java naming conventions to start your class name with a capital letter (Filtro instead of filtro). Do you still get the error message?
– Matthias Herlitzius
Apr 28 '13 at 12:53
Please use a valid package name like in the example. Write "package com.example;" instead of " package Bean;". Furthermore I suggest with regards to the Java naming conventions to start your class name with a capital letter (Filtro instead of filtro). Do you still get the error message?
– Matthias Herlitzius
Apr 28 '13 at 12:53
the package name is ok, it's is generated automathically in intellij when i create a new class inside of the folder "Bean", all my issues started after i compiled filtro.java and added the generated filtro.class in web-inf/classes, since i did that im getting this error.
– user1462933
Apr 28 '13 at 13:01
the package name is ok, it's is generated automathically in intellij when i create a new class inside of the folder "Bean", all my issues started after i compiled filtro.java and added the generated filtro.class in web-inf/classes, since i did that im getting this error.
– user1462933
Apr 28 '13 at 13:01
Please see this link regarding the package naming conventions: docs.oracle.com/javase/tutorial/java/package/namingpkgs.html
– Matthias Herlitzius
Apr 28 '13 at 13:05
Please see this link regarding the package naming conventions: docs.oracle.com/javase/tutorial/java/package/namingpkgs.html
– Matthias Herlitzius
Apr 28 '13 at 13:05
thanks for the link, i know there are conventions about package and class names , but that doesnt explain my problem.. before i did what expalin in my first post everything was ok , so the problem is not related to the package name, i think something got messed up after i copied and deleted the filtro.class into web-inf/classes...
– user1462933
Apr 28 '13 at 13:11
thanks for the link, i know there are conventions about package and class names , but that doesnt explain my problem.. before i did what expalin in my first post everything was ok , so the problem is not related to the package name, i think something got messed up after i copied and deleted the filtro.class into web-inf/classes...
– user1462933
Apr 28 '13 at 13:11
The error appears during the compile phase. Most likely the error is in your pom.xml. I can reproduce the error messages by commenting out the javax.servlet dependency in the pom.xml. If you are not sure about this please post your pom.xml.
– Matthias Herlitzius
Apr 28 '13 at 13:34
The error appears during the compile phase. Most likely the error is in your pom.xml. I can reproduce the error messages by commenting out the javax.servlet dependency in the pom.xml. If you are not sure about this please post your pom.xml.
– Matthias Herlitzius
Apr 28 '13 at 13:34
|
show 2 more comments
6 Answers
6
active
oldest
votes
The javax.servlet dependency is missing in your pom.xml. Add the following to the dependencies-Node:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
1
i have this one : <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> anyway, before i tried adding the one you are telling me and i got the same error.. now i added this one: <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>6.0</version> <type>jar</type> <scope>provided</scope> </dependency> and it worked. aarggh, the weird thing is that it worked before without that. thanks for your help
– user1462933
Apr 28 '13 at 13:55
I added that dependency to my POM as-is, @Matthias, but I'm still getting themissing symbol
errors for those classes. Any gotchas that I should know about?
– Kevin Meredith
May 10 '14 at 0:47
@KevinMeredith did you find a solution? If not, can you please post the full stacktrace?
– Matthias Herlitzius
May 17 '14 at 15:24
2
Be sure the servlet api version you use matches your application server.
– Erica Kane
Jan 30 '15 at 21:45
This solved my issue!
– Sabyasachi
Oct 19 '16 at 10:21
add a comment |
I only put this code in my pom.xml and I executed the command maven install.
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
add a comment |
The answer provided by @Matthias Herlitzius is mostly correct. Just for further clarity.
The servlet-api jar is best left up to the server to manage see here for detail
With that said, the dependency to add may vary according to your server/container. For example in Wildfly the dependency would be
<dependency>
<groupId>org.jboss.spec.javax.servlet</groupId>
<artifactId>jboss-servlet-api_3.1_spec</artifactId>
<scope>provided</scope>
</dependency>
So becareful to check how your container has provided the servlet implementation.
add a comment |
I needed to import javaee-api as well.
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
Unless I got following error:
package javax.servlet.http does not exist
javax.servlet.annotation does not exist
javax.servlet.http does not exist
...
add a comment |
In my case, migrating a Spring 3.1 app up to 3.2.7, my solution was similar to Matthias's but a bit different -- thus why I'm documenting it here:
In my POM I found this dependency and changed it from 6.0 to 7.0:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
Then later in the POM I upgraded this plugin from 6.0 to 7.0:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
...
<configuration>
...
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>7.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
add a comment |
maybe doesnt exists javaee-api-7.0.jar.
download this jar and on your project right clik
- on your project right click
- build path
- Configure build path
- Add external Jars
- javaee-api-7.0.jar choose
- Apply and finish
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f16262948%2ferror-package-javax-servlet-does-not-exist%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
The javax.servlet dependency is missing in your pom.xml. Add the following to the dependencies-Node:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
1
i have this one : <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> anyway, before i tried adding the one you are telling me and i got the same error.. now i added this one: <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>6.0</version> <type>jar</type> <scope>provided</scope> </dependency> and it worked. aarggh, the weird thing is that it worked before without that. thanks for your help
– user1462933
Apr 28 '13 at 13:55
I added that dependency to my POM as-is, @Matthias, but I'm still getting themissing symbol
errors for those classes. Any gotchas that I should know about?
– Kevin Meredith
May 10 '14 at 0:47
@KevinMeredith did you find a solution? If not, can you please post the full stacktrace?
– Matthias Herlitzius
May 17 '14 at 15:24
2
Be sure the servlet api version you use matches your application server.
– Erica Kane
Jan 30 '15 at 21:45
This solved my issue!
– Sabyasachi
Oct 19 '16 at 10:21
add a comment |
The javax.servlet dependency is missing in your pom.xml. Add the following to the dependencies-Node:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
1
i have this one : <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> anyway, before i tried adding the one you are telling me and i got the same error.. now i added this one: <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>6.0</version> <type>jar</type> <scope>provided</scope> </dependency> and it worked. aarggh, the weird thing is that it worked before without that. thanks for your help
– user1462933
Apr 28 '13 at 13:55
I added that dependency to my POM as-is, @Matthias, but I'm still getting themissing symbol
errors for those classes. Any gotchas that I should know about?
– Kevin Meredith
May 10 '14 at 0:47
@KevinMeredith did you find a solution? If not, can you please post the full stacktrace?
– Matthias Herlitzius
May 17 '14 at 15:24
2
Be sure the servlet api version you use matches your application server.
– Erica Kane
Jan 30 '15 at 21:45
This solved my issue!
– Sabyasachi
Oct 19 '16 at 10:21
add a comment |
The javax.servlet dependency is missing in your pom.xml. Add the following to the dependencies-Node:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
The javax.servlet dependency is missing in your pom.xml. Add the following to the dependencies-Node:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
answered Apr 28 '13 at 13:49
Matthias HerlitziusMatthias Herlitzius
3,14521418
3,14521418
1
i have this one : <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> anyway, before i tried adding the one you are telling me and i got the same error.. now i added this one: <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>6.0</version> <type>jar</type> <scope>provided</scope> </dependency> and it worked. aarggh, the weird thing is that it worked before without that. thanks for your help
– user1462933
Apr 28 '13 at 13:55
I added that dependency to my POM as-is, @Matthias, but I'm still getting themissing symbol
errors for those classes. Any gotchas that I should know about?
– Kevin Meredith
May 10 '14 at 0:47
@KevinMeredith did you find a solution? If not, can you please post the full stacktrace?
– Matthias Herlitzius
May 17 '14 at 15:24
2
Be sure the servlet api version you use matches your application server.
– Erica Kane
Jan 30 '15 at 21:45
This solved my issue!
– Sabyasachi
Oct 19 '16 at 10:21
add a comment |
1
i have this one : <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> anyway, before i tried adding the one you are telling me and i got the same error.. now i added this one: <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>6.0</version> <type>jar</type> <scope>provided</scope> </dependency> and it worked. aarggh, the weird thing is that it worked before without that. thanks for your help
– user1462933
Apr 28 '13 at 13:55
I added that dependency to my POM as-is, @Matthias, but I'm still getting themissing symbol
errors for those classes. Any gotchas that I should know about?
– Kevin Meredith
May 10 '14 at 0:47
@KevinMeredith did you find a solution? If not, can you please post the full stacktrace?
– Matthias Herlitzius
May 17 '14 at 15:24
2
Be sure the servlet api version you use matches your application server.
– Erica Kane
Jan 30 '15 at 21:45
This solved my issue!
– Sabyasachi
Oct 19 '16 at 10:21
1
1
i have this one : <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> anyway, before i tried adding the one you are telling me and i got the same error.. now i added this one: <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>6.0</version> <type>jar</type> <scope>provided</scope> </dependency> and it worked. aarggh, the weird thing is that it worked before without that. thanks for your help
– user1462933
Apr 28 '13 at 13:55
i have this one : <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> anyway, before i tried adding the one you are telling me and i got the same error.. now i added this one: <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>6.0</version> <type>jar</type> <scope>provided</scope> </dependency> and it worked. aarggh, the weird thing is that it worked before without that. thanks for your help
– user1462933
Apr 28 '13 at 13:55
I added that dependency to my POM as-is, @Matthias, but I'm still getting the
missing symbol
errors for those classes. Any gotchas that I should know about?– Kevin Meredith
May 10 '14 at 0:47
I added that dependency to my POM as-is, @Matthias, but I'm still getting the
missing symbol
errors for those classes. Any gotchas that I should know about?– Kevin Meredith
May 10 '14 at 0:47
@KevinMeredith did you find a solution? If not, can you please post the full stacktrace?
– Matthias Herlitzius
May 17 '14 at 15:24
@KevinMeredith did you find a solution? If not, can you please post the full stacktrace?
– Matthias Herlitzius
May 17 '14 at 15:24
2
2
Be sure the servlet api version you use matches your application server.
– Erica Kane
Jan 30 '15 at 21:45
Be sure the servlet api version you use matches your application server.
– Erica Kane
Jan 30 '15 at 21:45
This solved my issue!
– Sabyasachi
Oct 19 '16 at 10:21
This solved my issue!
– Sabyasachi
Oct 19 '16 at 10:21
add a comment |
I only put this code in my pom.xml and I executed the command maven install.
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
add a comment |
I only put this code in my pom.xml and I executed the command maven install.
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
add a comment |
I only put this code in my pom.xml and I executed the command maven install.
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
I only put this code in my pom.xml and I executed the command maven install.
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
edited Nov 23 '18 at 2:13
João Neves
5691815
5691815
answered Jul 26 '14 at 0:04
Igor MelãoIgor Melão
5113
5113
add a comment |
add a comment |
The answer provided by @Matthias Herlitzius is mostly correct. Just for further clarity.
The servlet-api jar is best left up to the server to manage see here for detail
With that said, the dependency to add may vary according to your server/container. For example in Wildfly the dependency would be
<dependency>
<groupId>org.jboss.spec.javax.servlet</groupId>
<artifactId>jboss-servlet-api_3.1_spec</artifactId>
<scope>provided</scope>
</dependency>
So becareful to check how your container has provided the servlet implementation.
add a comment |
The answer provided by @Matthias Herlitzius is mostly correct. Just for further clarity.
The servlet-api jar is best left up to the server to manage see here for detail
With that said, the dependency to add may vary according to your server/container. For example in Wildfly the dependency would be
<dependency>
<groupId>org.jboss.spec.javax.servlet</groupId>
<artifactId>jboss-servlet-api_3.1_spec</artifactId>
<scope>provided</scope>
</dependency>
So becareful to check how your container has provided the servlet implementation.
add a comment |
The answer provided by @Matthias Herlitzius is mostly correct. Just for further clarity.
The servlet-api jar is best left up to the server to manage see here for detail
With that said, the dependency to add may vary according to your server/container. For example in Wildfly the dependency would be
<dependency>
<groupId>org.jboss.spec.javax.servlet</groupId>
<artifactId>jboss-servlet-api_3.1_spec</artifactId>
<scope>provided</scope>
</dependency>
So becareful to check how your container has provided the servlet implementation.
The answer provided by @Matthias Herlitzius is mostly correct. Just for further clarity.
The servlet-api jar is best left up to the server to manage see here for detail
With that said, the dependency to add may vary according to your server/container. For example in Wildfly the dependency would be
<dependency>
<groupId>org.jboss.spec.javax.servlet</groupId>
<artifactId>jboss-servlet-api_3.1_spec</artifactId>
<scope>provided</scope>
</dependency>
So becareful to check how your container has provided the servlet implementation.
edited May 23 '17 at 12:10
Community♦
11
11
answered May 8 '16 at 12:19
Ntobeko MkhizeNtobeko Mkhize
6217
6217
add a comment |
add a comment |
I needed to import javaee-api as well.
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
Unless I got following error:
package javax.servlet.http does not exist
javax.servlet.annotation does not exist
javax.servlet.http does not exist
...
add a comment |
I needed to import javaee-api as well.
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
Unless I got following error:
package javax.servlet.http does not exist
javax.servlet.annotation does not exist
javax.servlet.http does not exist
...
add a comment |
I needed to import javaee-api as well.
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
Unless I got following error:
package javax.servlet.http does not exist
javax.servlet.annotation does not exist
javax.servlet.http does not exist
...
I needed to import javaee-api as well.
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
Unless I got following error:
package javax.servlet.http does not exist
javax.servlet.annotation does not exist
javax.servlet.http does not exist
...
answered Oct 5 '17 at 6:48
sandaru.nysandaru.ny
557
557
add a comment |
add a comment |
In my case, migrating a Spring 3.1 app up to 3.2.7, my solution was similar to Matthias's but a bit different -- thus why I'm documenting it here:
In my POM I found this dependency and changed it from 6.0 to 7.0:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
Then later in the POM I upgraded this plugin from 6.0 to 7.0:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
...
<configuration>
...
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>7.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
add a comment |
In my case, migrating a Spring 3.1 app up to 3.2.7, my solution was similar to Matthias's but a bit different -- thus why I'm documenting it here:
In my POM I found this dependency and changed it from 6.0 to 7.0:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
Then later in the POM I upgraded this plugin from 6.0 to 7.0:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
...
<configuration>
...
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>7.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
add a comment |
In my case, migrating a Spring 3.1 app up to 3.2.7, my solution was similar to Matthias's but a bit different -- thus why I'm documenting it here:
In my POM I found this dependency and changed it from 6.0 to 7.0:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
Then later in the POM I upgraded this plugin from 6.0 to 7.0:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
...
<configuration>
...
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>7.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
In my case, migrating a Spring 3.1 app up to 3.2.7, my solution was similar to Matthias's but a bit different -- thus why I'm documenting it here:
In my POM I found this dependency and changed it from 6.0 to 7.0:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
Then later in the POM I upgraded this plugin from 6.0 to 7.0:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
...
<configuration>
...
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>7.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
answered Apr 23 '15 at 21:42
BaneBane
1,15211626
1,15211626
add a comment |
add a comment |
maybe doesnt exists javaee-api-7.0.jar.
download this jar and on your project right clik
- on your project right click
- build path
- Configure build path
- Add external Jars
- javaee-api-7.0.jar choose
- Apply and finish
add a comment |
maybe doesnt exists javaee-api-7.0.jar.
download this jar and on your project right clik
- on your project right click
- build path
- Configure build path
- Add external Jars
- javaee-api-7.0.jar choose
- Apply and finish
add a comment |
maybe doesnt exists javaee-api-7.0.jar.
download this jar and on your project right clik
- on your project right click
- build path
- Configure build path
- Add external Jars
- javaee-api-7.0.jar choose
- Apply and finish
maybe doesnt exists javaee-api-7.0.jar.
download this jar and on your project right clik
- on your project right click
- build path
- Configure build path
- Add external Jars
- javaee-api-7.0.jar choose
- Apply and finish
answered Mar 6 '17 at 21:08
Barış MercanBarış Mercan
12
12
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f16262948%2ferror-package-javax-servlet-does-not-exist%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please use a valid package name like in the example. Write "package com.example;" instead of " package Bean;". Furthermore I suggest with regards to the Java naming conventions to start your class name with a capital letter (Filtro instead of filtro). Do you still get the error message?
– Matthias Herlitzius
Apr 28 '13 at 12:53
the package name is ok, it's is generated automathically in intellij when i create a new class inside of the folder "Bean", all my issues started after i compiled filtro.java and added the generated filtro.class in web-inf/classes, since i did that im getting this error.
– user1462933
Apr 28 '13 at 13:01
Please see this link regarding the package naming conventions: docs.oracle.com/javase/tutorial/java/package/namingpkgs.html
– Matthias Herlitzius
Apr 28 '13 at 13:05
thanks for the link, i know there are conventions about package and class names , but that doesnt explain my problem.. before i did what expalin in my first post everything was ok , so the problem is not related to the package name, i think something got messed up after i copied and deleted the filtro.class into web-inf/classes...
– user1462933
Apr 28 '13 at 13:11
The error appears during the compile phase. Most likely the error is in your pom.xml. I can reproduce the error messages by commenting out the javax.servlet dependency in the pom.xml. If you are not sure about this please post your pom.xml.
– Matthias Herlitzius
Apr 28 '13 at 13:34