Codeninja
Codeninja

Reputation: 322

Maven missing artifacts but files are in place - Eclipse

I am getting two errors in eclipse(2020-03) in my maven project as,

The container 'Maven Dependencies' references non existing library 'C:\Users\Shavindi\.m2\repository\javax\servlet\jsp\javax.servlet.jsp-api\4.0.1\javax.servlet.jsp-api-4.0.1.jar' ```

Missing artifact javax.servlet.jsp:javax.servlet.jsp-api:jar:4.0.1  pom.xml /ContactManager line 47 Maven Dependency Problem 

I have followed the answers in this question Maven2: Missing artifact but jars are in place . But it didn't work.

My javax.servlet.jsp-api:jar:4.0.1 files are already in place as shown below.

enter image description here

The pom.xml file is also atttached.

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>net.codejava.contact</groupId>
  <artifactId>ContactManager</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
        <configuration>
          <release>13</release>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>3.2.3</version>
        <configuration>
          <warSourceDirectory>WebContent</warSourceDirectory>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <properties>
    <spring.version>5.9.1.RELEASE</spring.version>
  </properties>

  <dependencies>
    <dependency>
        <groupId>org.springframework</groupId> 
        <artifactId>spring-webmvc</artifactId> 
        <version>4.2.2.RELEASE</version> 
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId> 
        <artifactId>spring-orm</artifactId> 
        <version>4.2.2.RELEASE</version> 
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId> 
        <artifactId>javax.servlet-api</artifactId> 
        <version>4.0.1</version> 
    </dependency>
      <dependency>
        <groupId>javax.servlet.jsp</groupId> 
        <artifactId>javax.servlet.jsp-api</artifactId> 
        <version>4.0.1</version> 
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId> 
        <artifactId>jstl</artifactId> 
        <version>1.2</version> 
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>8.0.19</version>
    </dependency>
  </dependencies>
</project>

Upvotes: 1

Views: 8350

Answers (2)

Anish B.
Anish B.

Reputation: 16439

Remove the unnecessary javax.servlet.jsp-api dependency from pom.xml.

<dependency>
        <groupId>javax.servlet.jsp</groupId> 
        <artifactId>javax.servlet.jsp-api</artifactId> 
        <version>4.0.1</version> 
</dependency>

Also, do Project -> Clean to check whether the error still persists or not ? If yes, then Right Click on project -> Maven -> Update Project -> Select update of snapshot and also enable Project -> Build automatically.

Moreover, they have moved the artifact as well. If you write the code later, you can use the dependency below.

<dependency>
    <groupId>javax.servlet.jsp</groupId>
    <artifactId>javax.servlet.jsp-api</artifactId>
    <version>2.3.1</version>
</dependency>

Your pom.xml is not proper. So, I have updated your pom.xml as well.

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>net.codejava.contact</groupId>
  <artifactId>ContactManager</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
        <configuration>
          <release>13</release>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>3.2.3</version>
        <configuration>
          <warSourceDirectory>WebContent</warSourceDirectory>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <properties>
    <spring.version>4.2.2.RELEASE</spring.version>
  </properties>

  <dependencies>
    <dependency>
        <groupId>org.springframework</groupId> 
        <artifactId>spring-webmvc</artifactId> 
        <version>${spring.version}</version> 
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId> 
        <artifactId>spring-orm</artifactId> 
        <version>${spring.version}</version> 
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId> 
        <artifactId>javax.servlet-api</artifactId> 
        <version>4.0.1</version> 
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>javax.servlet.jsp-api</artifactId>
        <version>2.3.1</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId> 
        <artifactId>jstl</artifactId> 
        <version>1.2</version> 
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>8.0.19</version>
    </dependency>
  </dependencies>
</project>

Upvotes: 1

redforce
redforce

Reputation: 25

I noticed your POM.xml has wrong version of javax.servlet.jsp. Try replacing it with the following which is the latest version.

<!-- https://mvnrepository.com/artifact/javax.servlet.jsp/javax.servlet.jsp-api -->
<dependency>
    <groupId>javax.servlet.jsp</groupId>
    <artifactId>javax.servlet.jsp-api</artifactId>
    <version>2.3.3</version>
    <scope>provided</scope>
</dependency>

If the issue doesn't get resolved after the changes have taken place, follow the steps mentioned below and see if it helps.

  • Right click your Spring MVC project, choose Run As -> Maven install. Observe the output console to see the installation progress. After the installation is finished, you can continue to the next step
  • Right click your Spring MVC project, choose Maven -> Update Project.
  • Choose your project and click OK. Wait until update process is finished.
  • The error still yet, then do Project->Clean and then be sure you have selected our project directory and then do the follow Project->Build.

Upvotes: 1

Related Questions