25

i was using servlet 2.5 as follows:

<dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
</dependency>

and i want to use servlet 3 since i am migrating to tomcat 7 so i can use EL 2.2, when i added the following dependency, it couldn't be found:

<dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>3.0</version>
        <scope>provided</scope>
</dependency>

UPDATE:

I am using Spring 3, JSF 2, Tomcat 7

so what do you guys suggest ?

Mahmoud Saleh
  • 33,303
  • 119
  • 337
  • 498

2 Answers2

51

Looks like artifact ID has been renamed to javax.servlet-api

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.0.1</version>
    <scope>provided</scope>
</dependency>

Here is the search URL on maven central: http://search.maven.org/#search|gav|1|g%3A%22javax.servlet%22

To preempt your question about JSP and EL, here are the dependencies for jsp-api and el-api:

<dependency>
    <groupId>javax.servlet.jsp</groupId>
    <artifactId>javax.servlet.jsp-api</artifactId>
    <version>2.2.1</version>
    <scope>provided</scope>
</dependency>

<dependency>
    <groupId>javax.el</groupId>
    <artifactId>javax.el-api</artifactId>
    <version>2.2.2</version>
    <scope>provided</scope>
</dependency>
Alexander Pogrebnyak
  • 44,836
  • 10
  • 105
  • 121
  • I have really no idea if it works (Maven is beyond me), but this is at least more suitable for Tomcat as it's not a Java EE Web Profile compliant container at all (which would only result in future classpath troubles). So, here's a +1 to put it above the other answer suggesting that. – BalusC Oct 17 '11 at 18:20
  • i thought about that too, that's why i compared between this jar and the servlet-api in tomcat 7 lib but i found that the one from tomcat contains two additional packages jsp,resources, are you pretty sure that this is the correct one ? – Mahmoud Saleh Oct 17 '11 at 18:20
  • What happens then if you try that? – BalusC Oct 17 '11 at 18:21
  • @BalusC and @Alexander Pogrebnyak it couldn't parse the following: ` – Mahmoud Saleh Oct 17 '11 at 18:33
  • So, no compilation errors or abstract runtime errors due to classpath collisions anymore? Then your initial question is answered and your problem is solved! Your new problem is caused by something else (hint: `web.xml` version). – BalusC Oct 17 '11 at 18:35
  • @BalusC my web.xml is version 3, and i don't have any EL 2.1 version on my pom file, any other ideas ? – Mahmoud Saleh Oct 17 '11 at 18:40
  • @Mika. `` looks like a JSF tag. Do you have JSF in your web-app pom's dependency list? – Alexander Pogrebnyak Oct 17 '11 at 18:52
  • yes i do, ` com.sun.faces jsf-api 2.1.0-b11 compile com.sun.faces jsf-impl 2.1.0-b11 compile ` – Mahmoud Saleh Oct 17 '11 at 18:58
  • @Alexander Pogrebnyak but i guess i knew the problem, that maven tomcat plugin for maven 2 only runs the tomcat 6 instance, so i need to configure it to run the tomcat 7 instance, any useful links or ideas for this issue ? – Mahmoud Saleh Oct 17 '11 at 18:59
  • So, it doesn't look like these match exactly; I'm not seeing any runtime problems, the only thing is that the sources for that servlet library and the debug information is not really in sync. – Eugen Dec 10 '12 at 14:26
10

The library org.apache.tomcat contains Servlet 3.0

<dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>tomcat-servlet-api</artifactId>
    <version>7.0.30</version>
    <scope>provided</scope>
</dependency>

For further reference see:

  1. https://github.com/SpringSource/spring-mvc-showcase/blob/master/pom.xml
  2. https://github.com/SpringSource/spring-mvc-showcase/blob/master/src/main/webapp/WEB-INF/web.xml
user2601995
  • 6,463
  • 8
  • 37
  • 41