How to config maven to use servlet 3

angus picture angus · Jul 21, 2014 · Viewed 23.1k times · Source

I want to upgrade my webapp to use servlet 3.0 (insetd of 2.5). I am using WebLogic Server Version: 12.1.1.0 (12c),maven,java 7_10 and NetBeans 7.3.1

For some reason the only available servlet-api is 3.0-alpha-1 and not 3.0

<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>3.0-alpha-1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.myfaces.core</groupId>
        <artifactId>myfaces-api</artifactId>
        <version>2.1.8</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.myfaces.core</groupId>
        <artifactId>myfaces-impl</artifactId>
        <version>2.1.8</version>
        <scope>compile</scope>
    </dependency>

Answer

Craig Otis picture Craig Otis · Jul 21, 2014

Your options are actually 3.0.1 or 3.1.0 of the final releases, and the artifact ID has been changed. Using the old servlet-api artifact ID, the releases available are only 2.x, aside from the alpha you've found.

If you update to javax.servlet-api, you'll find the newer 3.x releases:

http://mvnrepository.com/artifact/javax.servlet/javax.servlet-api

You can update your POM to use:

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